akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int memo[110000];

int rec(int N){
    if(N==0) return 0;
    if(memo[N]!=-1) return memo[N];

    int res=N;
    for(int i=1;i<=N;i*=6)
        res=min(res,rec(N-i)+1);
    for(int i=1;i<=N;i*=9)
        res=min(res,rec(N-i)+1);
    return memo[N]=res;
}

signed main()
{
    int N; cin>>N;
    REP(i,110000) memo[i]=-1;
    cout<<rec(N)<<endl;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define EPS (1e-10)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
 
int t[100],v[100];
int dp[50000][300];
 
int main(){
	int n;scanf("%d",&n);
	rep(i,n)scanf("%d",&t[i]),t[i]*=2;
	rep(i,n)scanf("%d",&v[i]),v[i]*=2;
	int k=0;
	int sum=t[0];
	memset(dp,-1,sizeof(dp));
	dp[0][0]=0;
	rep(i,50000){
		bool flag=false;
		if(i+1>=sum){
			if(k<n-1){
				flag=true;
				k++;sum+=t[k];
			}
		}
		rep(j,205){
			if(dp[i][j]==-1)continue;
			if(j&&j-1<=v[k])dp[i+1][j-1]=max(dp[i+1][j-1],dp[i][j]+j-1);
			if(j+1<=v[k]){
				if(flag){
					if(j+1<=v[k-1])dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+j+1);
				}
				else dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+j+1);
			}
			if(j<=v[k])dp[i+1][j]=max(dp[i+1][j],dp[i][j]+j);
		}
		if(i+1>=sum&&k==n-1)break;
	}
	printf("%.12lf\n",dp[sum][0]/4.);
}

Measured memory_bytes: 58880
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pairA
#define REP(i,n) for(int i=0;i<(n);i++)
bool ok(int i){
    int c=0;
    while(i>0){
        i/=10;
        c++;
    }
    return c%2==1;
}
int main()
{
    int n;
    cin>>n;
    int cnt=0;
    for(int i=1;i<=n;i++){
        if(ok(i))cnt++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
def main():
  S = list(input())
  T = list(input())
  
  l_S = len(S)
  l_T = len(T)
  
  best = l_S
  
  for i in range(l_S - l_T + 1):
    X = S[i : i + l_T]
    count = l_T
    for j, y in enumerate(X):
      if T[j] == y:
        count -= 1
    if best > count:
      best = count
    
  print(best)
    
main()

Measured memory_bytes: 67708
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
    
    ll x,a,b;
    cin>>x;
    for(ll i=-1000;i<=1000;i++){
        for(ll j=-1000;j<=1000;j++){
            if(pow(i,5)-pow(j,5)==x){
                a=i;
                b=j;
                break;
            }
        }
    }
    cout<<a<<" "<<b<<endl;
}
   



Measured memory_bytes: 4100
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

Int soinsu[105];

int main(){
    cin.tie(0);

    for (int i = 2; i <= 100; i++){
        soinsu[i]++;
    }
    int n; cin >> n;
    for (int i = 2; i <= n; i++){
        int tmp = i;
        for (int j = 2; j <= i; j++){
            while (tmp % j == 0){
                soinsu[j]++;
                tmp /= j;
            }
        }
    }

    for (int i = 0; i <= n; i++){
        //cout << i << " " << soinsu[i] << endl;
    }

    int cnt5 = 0;
    int cnt3 = 0;
    for (int i = 2; i <= 100; i++){
        if (soinsu[i] >= 5) cnt5++;
        if (soinsu[i] >= 3) cnt3++;
    }
    long long ans = 0;
    for (int i = 2; i <= 100; i++){
        if (soinsu[i] >= 3){
            if (soinsu[i] >= 5){
                ans += 0<(cnt5-1)*(cnt5-2)/2LL?(cnt5-1)*(cnt5-2)/2LL:0;
            }else{
                ans += 0<(cnt5)*(cnt5-1)/2LL?(cnt5)*(cnt5-1)/2LL:0;
            } 
        }
    }
    for (int i = 2; i <= 100; i++){
        if (soinsu[i] >= 15){
            ans += (cnt5-1);
        }
    }
    for (int i = 2; i <= 100; i++){
        if (soinsu[i] >= 25) ans += (cnt3-1);
    }
    for (int i = 2; i <= 100; i++){
        if (soinsu[i] >= 75) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 384
A,B=map(int,input().split(" "))
if A<0 or B<0 or B >10**9 or A > 10**9 or A==B:
	print ('Illegal')
else:
	if (A-B)%2!=0:
		print ('IMPOSSIBLE')
	else:
		print(int((A+B)/2))


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>

#define div 1000000000+7

typedef long long ll;

using namespace std;

void solve() {
    int a, b, c;
    string s;
    cin >> a >> s >> b;
    if(s == "+"){
        c = a + b;
    }else{
        c = a - b;
    }
    cout << c << endl;
}

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


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void SMTB2019D()
{
	int N;
	cin >> N;
	string S;
	cin >> S;
	vi d1(10, -1);
	for (int k = 0; k < N; ++k)
	{
		int i = S[k] - '0';
		if (d1[i] < 0)
			d1[i] = k;
	}
	vi d2(100, -1);
	for (int k = 1; k < N; ++k)
	{
		int i = S[k] - '0';
		for (int j = 0; j < 10; ++j)
		{
			if (d1[j] >= 0 && d1[j] < k && d2[j * 10 + i] < 0)
				d2[j * 10 + i] = k;
		}
	}
	vi d3(1000, -1);
	for (int k = 2; k < N; ++k)
	{
		int i = S[k] - '0';
		for (int j = 0; j < 100; ++j)
		{
			if (d2[j] >= 0 && d2[j] < k && d3[j * 10 + i] < 0)
				d3[j * 10 + i] = k;
		}
	}
	int ct = 0;
	for (int i = 0; i < 1000; ++i)
	{
		if (d3[i] > 0)
		{
			++ct;
		}
	}
	cout << ct << endl;
}
int main()
{
	SMTB2019D();
	return 0;
}

Measured memory_bytes: 384
s=input(); n=len(s)
if s=="zyxwvutsrqponmlkjihgfedcba":
    print(-1);exit()
if len(s)!=26:
    for c in range(ord("a"),ord("z")+1):
        c=chr(c)
        if not (c in s):
            print(s+c);exit()

now="zz"
for i in range(n-1,-1,-1):
    if s[i-1]<s[i]:
        if i==1:
            print(chr(ord(s[0])+1));exit()
        qq=s[i]
        for nowc in s[i+1:]:
            if nowc> s[i-1] and qq>nowc:
                qq=nowc
        print(s[:i-1]+qq);exit()

Measured memory_bytes: 9176
import java.util.Scanner;

public class Main {
	int w, h;
	char[][] f;
	int[] dx = {-1, 0, 0, 1};
	int[] dy = {0, -1, 1, 0};
	boolean flgW, flgB;

	int dfs(int x, int y) {
		if (x < 0 || w <= x || y < 0 || h <= y) {
			return 0;
		}
		if (f[y][x] != '.') {
			if (f[y][x] == 'W') flgW = true;
			if (f[y][x] == 'B') flgB = true;
			return 0;
		}

		f[y][x] = 'X';
		int res = 1;
		for (int i = 0; i < 4; i++) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			res += dfs(nx, ny);
		}
		return res;
	}

	void run() {
		Scanner sc = new Scanner(System.in);

		while (true) {
			w = sc.nextInt();
			h = sc.nextInt();
			if ((w | h) == 0) {
				break;
			}
			f = new char[h][];
			for (int i = 0; i < h; i++) {
				f[i] = sc.next().toCharArray();
			}

			int sumW = 0, sumB = 0;
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (f[i][j] != '.') continue;
					flgW = flgB = false;
					int tmp = dfs(j, i);
					if (flgB && !flgW) {
						sumB += tmp;
					} else if (!flgB && flgW) {
						sumW += tmp;
					}
				}
			}

			System.out.println(sumB + " " + sumW);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 28596
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f
using namespace std;
int n,k;
int main()
{
	cin>>n>>k;
	if (n%2==0)
	{
		if (k<=n/2) cout<<"YES";
		else cout<<"NO";
	}
	else
	{
		if (k<=n/2+1) cout<<"YES";
		else cout<<"NO";
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        int[] V = new int[N];
        for (int i = 0; i < N; i++) {
            V[i] = scanner.nextInt();
        }
        int ans = 0;
        for (int k = 1; k <= K && k <= N; k++) {
            for (int l = 0; l <= k; l++) {
                List<Integer> list = new ArrayList<>();
                int sum = 0;
                for (int a = 0; a < l; a++) {
                    list.add(V[a]);
                    sum += V[a];
                }
                for (int b = 0; b < k - l; b++) {
                    list.add(V[N - b - 1]);
                    sum += V[N - b - 1];
                }
                Collections.sort(list);
                int idx = 1;
                for (Integer integer : list) {
                    if (integer > 0 || idx + k > K) {
                        break;
                    }
                    sum -= integer;
                    idx++;
                }
                ans = Math.max(ans, sum);
            }
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 25940
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


#define PI 3.1415926535897

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

	long double a, b, x, ans, degree, aa, bb, cc, xx, vol;

	cin >> a >> b >> x;
	x /= a;

	aa = 0; bb = 90;
	while (aa + 1E-10 < bb) {
		cc = (aa + bb) / 2;
		xx = tan(cc * PI / 180.0) * a;

		if (xx <= b) vol = a * xx / 2;
		else vol = b * (a + a / xx * (xx - b)) / 2;
		vol = a * b - vol;

		//cout << setprecision(10) << fixed << cc << " " << vol << "\n";
		if (vol > x) aa = cc; 
		else bb = cc;
	}

	cout << setprecision(10) << fixed << aa << "\n";

	return 0;
}


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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;

typedef long long int ll;

vector<int> h;
vector<int> ans;

int f(int N){
	if(ans[N] != -1) return ans[N];
	if(N == 0){
		ans[N] = 0;
	}
	else if(N == 1){
		ans[N] = abs(h[1]-h[0]);
	}
	else{
		int t1 = abs(h[N]-h[N-1]) + f(N-1);
		int t2 = abs(h[N]-h[N-2]) + f(N-2);
		ans[N] = min(t1,t2);
	}
	
	return ans[N];
}

void solve(){
	int N;
	cin >> N;
	
	h.clear(); ans.clear();
	h.resize(N); ans.resize(N);
	for(int i = 0; i < N; i++) ans[i] = -1;
	for(int i = 0; i < N; i++) cin >> h[i];
	
	cout << f(N-1) << endl;
}

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

	int T;
	//cin >> T;
	T = 1;
	while(T--){
		solve();
	}
	return 0;
}





Measured memory_bytes: 5760
#include <cstdio>
#include <algorithm>

typedef long long ll;

const int MaxN = 100005;

int n;
ll stk[MaxN], coef[MaxN], buk[MaxN];

void solve(ll rem, ll val, int pos) {
	while (rem) {
		pos = std::upper_bound(stk + 1, stk + pos, rem) - stk - 1;
		if (pos == 0) {
			buk[rem] += val;
			break;
		}
		ll quot = rem / stk[pos];
		rem = rem % stk[pos];
		coef[pos] += quot * val;
	}
}

int main() {
	int q;
	scanf("%d%d", &n, &q);
	int top = 0;
	stk[++top] = n;
	while (q--) {
		ll x; scanf("%lld", &x);
		while (top && x <= stk[top]) --top;
		stk[++top] = x;
	}
	coef[top] = 1;
	for (int i = top; i > 1; --i) {
		ll quot = stk[i] / stk[i - 1];
		ll rem  = stk[i] % stk[i - 1];
		solve(rem, coef[i], i - 1);
		coef[i - 1] += quot * coef[i];
	}
	buk[stk[1]] += coef[1];
	for (int i = stk[1]; --i; ) buk[i] += buk[i + 1];
	for (int i = 1; i <= n; ++i) printf("%lld\n", buk[i]);
	return 0;
}

Measured memory_bytes: 3968
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>


using namespace std;

void Solution()
{
    int n;
    
    
    
    cin >> n;
    
    while(n--)
    {
        
        string str;
        
        int point = 0;
        
        int out = 0;
        
        int base[3] = {0, 0, 0};
        
        while(cin>>str)
        {
            
            if(str == "HIT")
            {
                if(base[2] == 1)
                {
                    ++point;
                    
                    base[2] = 0;
                }
                
                if(base[1] == 1)
                {
                    base[2] = 1;
                    base[1] = 0;
                }
                
                if(base[0] == 1)
                {
                    base[1] = 1;
                    base[0] = 0;
                }
                
                base[0] = 1; //point
            }
            else if(str == "HOMERUN")
            {
                for(int i=0; i < 3; ++i)
                {
                    point += base[i];
                }
                
                point++;
                
                base[0] = 0;
                base[1] = 0;
                base[2] = 0;
            }
            else
            {
                ++out;
                
                if(out >= 3)
                {
                    cout<<point<<endl;
                    
                    point = 0;
                    out = 0;
                    
                    base[0] = 0;
                    base[1] = 0;
                    base[2] = 0;
                    
                    continue;
                }
            }
        }
    }
    
}

int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;

int main() {
  vector<int> res(9, 0);
  cin >> res[0] >> res[1] >> res[4];
  res[6] = res[0] + res[1] - res[4];
  res[5] = res[0] + res[6] - res[4];
  res[2] = res[0] + res[4] - res[5];
  int sum = res[0] + res[1] + res[2];
  res[3] = sum - res[0] - res[6];
  res[7] = sum - res[1] - res[4];
  res[8] = sum - res[2] - res[5];
  rep(i,3) {
    rep(j,3) cout << res[3 * i + j] << " ";
    cout << endl;
  }
  return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s;
    cin>>n;
    cin>>s;
    int a=s.length();
    if(a>n)
    {
        for(int i=0;i<n;i++)
        {
            cout<<s[i];
        }
        cout<<"..."<<endl;
    }
    else
        cout<<s<<endl;
}

Measured memory_bytes: 3588
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String x = sc.next();
		String y = sc.next();
		if(Character.getNumericValue(x.charAt(0))>Character.getNumericValue(y.charAt(0))) {
			System.out.println(">");
		} else if (Character.getNumericValue(x.charAt(0))==Character.getNumericValue(y.charAt(0))) {
			System.out.println("=");
		} else {
			System.out.println("<");
		}
	}
	
	static int binarySearch(int[] A, int x) {
		int l = 0;
		int r = A.length;
		while(l<r) {
			int mid = (l+r)/2;
			if(A[mid] == x) return mid;
			else if(x<A[mid]) r = mid;
			else l = mid+1;
		}
		return -1;
	}
	
	static long upper_bound(int[] A, int b) {
		// bよりおおきい値がはじめて出てくるindexを返す
		return lower_bound(A, b+1);
	}

	static long lower_bound(int[] A, int b) {
		// b以上の値がはじめて出てくるindexを返す
		int lb=0;
		int ub=A.length;
		while(ub>lb) {
			int mid = (lb+ub)/2;
			if(A[mid]>=b) ub = mid;
			else lb = mid+1;
		}
		return lb;
	}
	
	// union find lib
	// usage:
	// 最初にinitを呼ぶ
	// root: 直接は呼ばないで
	// unite: まとめる
	// same: グループ判定
	static void init(int par[], int N) {
		for(int i=0; i<N; i++) {
			par[i] = i;
		}
	}
	
	static int root(int x, int [] par) {
		if(par[x] == x) {
			return x;
		} else {
			return (par[x] = root(par[x], par));
		}
	}
	
	static boolean same(int x, int y, int[] par) {
		return root(x, par) == root(y, par);
	}
	
	static void unite(int x, int y, int[] par) {
		x = root(x, par);
		y = root(y, par);
		if(x == y) return;
		par[x] = y;
	}
	
	// end union find lib
	
	// number lib
	
	static int max(int...ls) {
		int ans = Integer.MIN_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.max(ans, ls[i]);
		}
		return ans;
	}
	
	static int min(int...ls) {
		int ans = Integer.MAX_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.min(ans, ls[i]);
		}
		return ans;
	}
	
	static long lcm(long a, long b) {
		return a*(b/gcd(a, b));
	}
	
	static long gcd(long a, long b) {
		long ta = Math.max(a, b);
		long tb = Math.min(a, b);
		long tmp;
		while((tmp = ta%tb) != 0) {
			ta = tb;
			tb = tmp;
		}
		return tb;
	}
	
	static long modcomb(long n, long k, long mod) {
		if(k==1) {
			return n;
		}
		
		long ans = 1;
		for(long i=n; i>=n-k+1; i--) {
			ans = (ans * i)%mod;
		}
		for(long i=k; 0<i; i--) {
			ans = (ans * modpow(i, mod-2, mod)) % mod;
		}
		return ans;
	}
	
	static long modpow(long a, long b, long mod) {
		if(b==0) return 1;
		if(b%2==0) {
			long d = modpow(a, b/2, mod);
			return (d*d)%mod;
		} else {
			return (a*modpow(a, b-1, mod))%mod;
		}
	}
	
	static int disit(long a, long d) {
		int count = 0;
		while(a!=0) {
			a = a/d;
			count++;
		}
		return count;
	}
	
	// end number lib
}

Measured memory_bytes: 21844
import java.util.Scanner;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.ArrayList;
import java.util.Set;
import java.util.Queue;
import java.text.DecimalFormat;

public class Main {

    public static void main(String[] args) {

        /*
        Scanner input = new Scanner(System.in);
        String word = input.nextLine();
        int n = word.length();
        int maximumLength = 0;
        boolean zFound = false;
        for (int i = 0; i < n; i++) {
            if(word.charAt(i) == 'A')
            {
                for (int j = i+1; j < n; j++) {
                    if(word.charAt(j) == 'Z')
                    {
                        zFound = true;
                        if(j-i+1 > maximumLength)
                        {
                            maximumLength = j - i + 1;
                        }
                    }
                    else if(zFound && word.charAt(j) != 'Z')
                    {
                        zFound = false;
                        break;
                    }
                }
            }
        }
        System.out.println(maximumLength);
        */
        Scanner input = new Scanner(System.in);
        int n =Integer.parseInt(input.nextLine());
        String word = input.nextLine();
        int x = 0;
        int maximumX = 0;

        for (int i = 0; i  < n ; i++) {
            if(word.charAt(i) == 'I')
                x++;
            else
                x--;
            if(x > maximumX)
                maximumX = x;
        }
        System.out.println(maximumX);

        }
}

Measured memory_bytes: 23124
let () = Scanf.scanf "%d" @@ fun n ->
  print_endline @@
    (function true -> "Yes" | false -> "No") @@ 
      Array.fold_left (Array.fold_left ( || )) false @@
        Array.init (n + 1) @@ fun i ->
          Array.init (n + 1) @@ fun j -> 4 * i + 7 * j = n


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
using matrix = vector<vector<uint>>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

int trans(char &c) {
    if (c == 'R')
        return 0;
    if (c == 'G')
        return 1;
    return 2;
}

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

    int N;
    string S;
    cin >> N >> S;

    vector<vector<int>> bcnt(N + 1, vector<int>(3));
    for (int i = N - 1; i >= 0; --i) {
        bcnt[i] = bcnt[i + 1];
        bcnt[i][trans(S[i])]++;
    }

    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            if (S[i] == S[j])
                continue;
            int cnt = N - j - 1;
            cnt -= bcnt[j + 1][trans(S[i])];
            cnt -= bcnt[j + 1][trans(S[j])];
            if (2 * j - i < N) {
                char c = S[2 * j - i];
                if (c != S[i] && c != S[j])
                    cnt--;
            }
            ans += cnt;
        }
    }

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


Measured memory_bytes: 3852
use std::io::prelude::*;

fn main() {
    let stdin_ = std::io::stdin();
    let mut stdin = stdin_.lock();
    let mut buf = String::new();
    let (a, _b, _c, _d, e, k) = {
        let mut v = Vec::new();
        for _ in 0..6 {
            buf.clear();
            stdin.read_line(&mut buf).unwrap();
            v.push(buf.trim().parse::<i64>().unwrap());
        }
        (v[0], v[1], v[2], v[3], v[4], v[5])
    };

    let ans = if e - a <= k { "Yay!" } else { ":(" };
    println!("{}", ans);
}


Measured memory_bytes: 4352
N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

ret = 1
MOD = 10 ** 9 + 7

A.sort(reverse=True)
B.sort(reverse=True)

aidx = bidx = 0

for n in range(N * M, 0, -1):

    # 両方みつけた
    if aidx < N and bidx < M and n == A[aidx] and n == B[bidx] and A[aidx] == B[bidx]:
        aidx += 1
        bidx += 1

    # Bの方だけ見つけた
    elif bidx < M and n == B[bidx]:
        ret *= aidx
        bidx += 1

    # Aの方だけ見つけた
    elif aidx < N and n == A[aidx]:
        ret *= bidx
        aidx += 1

    # 両方なかった
    else:
        ret *= (aidx * bidx - (N * M - n))
    ret = ret % MOD

print(ret)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define fi                first
#define se                 second
#define ll               long long
#define mod              1000000007
#define endl              "\n"
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb                push_back
#define all(v)             v.begin(),v.end()
#define inp(V,n)      for(int i=0;i<n;i++){cin >> V[i];}
#define oup(V,n)     {for(int i=0;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
using namespace std;
ll factorial(ll n)
{
    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
ll gcd(ll a, ll b)
{
    if (a == 0)
      return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
   return (a*b)/gcd(a, b);
}
bool sortByVal(const pair<ll,ll> &a,
               const pair<ll,ll> &b)
{
    return (a.second < b.second);
}
ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%mod;}
    else{return (b*((temp*temp)%mod))%mod;}
}
ll sumofdigit(ll n)
{
    ll c=0,d=0,sum=0,i;
    while(n>0)
    {
        c=n%10;
        sum+=c;
        n/=10;
    }
    return sum;
}

int main()
{
     fast;
     int t=1;
     //cin>>t;
     while(t--)
     {
       ll  m,k,i,j,c=0,d=0,e=0,f=0,sum=0,g=0,h=0,n,maxi=0;
      cin>>k;
      cin>>n>>m;
      for(i=n;i<=m;i++)
      {
          if(i%k==0)
          {
              e++;
              break;
          }
      }
      if(e!=0)
      {
          cout<<"OK"<<endl;
      }
      else
        cout<<"NG"<<endl;
     }


}


Measured memory_bytes: 3656
from sys import stdin, stdout

def print(x):
    stdout.write(str(x))

def solve():
    A = [int(x) for x in stdin.readline().split()]
    sum = 0
    for a in A:
        sum += a
    if sum < 22 :
        print("win")
    else:
        print("bust")

def main():
    solve()


if __name__ == "__main__":
    main()

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

int main() {
  int a,b,c,d,e;
  cin>>a>>b>>c;
  d=min(a,min(b,c));
  e=a+b+c-d-max(a,max(b,c));
  cout<<d+e<<endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;
using System.Runtime.InteropServices.ComTypes;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (A, B, K) = Slice3<int>();
            var cdt = new List<long>();
            for (var i = 1; i <= Min(A, B); ++i)
            {
                if (A % i == 0 && B % i == 0)
                    cdt.Add(i);
            }
            cdt.Reverse();
            WriteLine(cdt[K - 1]);
        }

        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 27836
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N ;
  cin >> N ;
  int result=pow(10,9);
  rep(i,N){
    int A,cont;
    cin >> A;
    cont=0;
    while(A%2==0){
      A/=2;
      cont++;
    }
    if(cont<result){
      result=cont;
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    set<int> a;
    int x;
    for(int i = 0; i < n; i++)
    {
        cin >> x;
        if(a.count(x) == 1)
            a.erase(x);
        else
            a.insert(x);

    }
    printf("%d",a.size());
    return 0;

}

Measured memory_bytes: 4864
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
    int c[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }
    int flag = 0;
    for (int i = 0; i < 2; i++) {
        int x1 = c[i][0] - c[i+1][0];
        int y1 = c[i][1] - c[i+1][1];
        int z1 = c[i][2] - c[i+1][2];
        if (x1 != y1 || y1 != z1) {
            flag = 1;
            break;
        }
        int x2 = c[0][i] - c[0][i+1];
        int y2 = c[1][i] - c[1][i+1];
        int z2 = c[2][i] - c[2][i+1];
        if (x2 != y2 || y2 != z2) {
            flag = 1;
            break;
        }
    }
    cout << ((flag == 1)? "No" : "Yes") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()

{
  int a, b, c, d, i, k =0,l;
  int bx = 0;
  scanf("%d %d", &a, &b);
  d=b;
  while(b!=0){
    b = b/10;
    bx++;
  }

  for(l=0;l<bx;l++){
    a = a*10;
  }
  c = a + d;

  for(i=1; i<=1000; i++){
    if(c == i*i)k++;
  }
  if(k==1) printf("Yes\n");
  else printf("No\n");

  return 0;
}


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

using namespace std;

using Value = int32_t;

constexpr Value mod = 998244353;

std::string calc(Value n) {
  if (n <= 999) {
    return "ABC";
  } else {
    return "ABD";
  }
}

int main() {
  Value n;
  std::cin >> n;
  auto ret = calc(n);
  std::cout << ret << std::endl;
  return 0;
}


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

int n, m;
vector<int> sw(10);
int x(int bit) {
	int result = 0;
	for (int i = 0; bit > 0; bit >>= 1, i++) {
		if (bit & 1)
			result ^= sw[i];
	}
	return result;
}

int main() {
	cin >> n >> m;
	for (int k, bit = 1 << (m - 1), s; bit > 0; bit >>= 1) {
		cin >> k;
		for (int j = 0; j < k; j++) {
			cin >> s;
			s--;
			sw[s] |= bit;
		}
	}

	int p = 0;
	for (int i = 0, q; i < m; i++) {
		cin >> q;
		p <<= 1;
		p += q;
	}

	int result = 0;
	for (int bit = 0; bit < 1 << n; bit++) {
		if (x(bit) == p)
			result++;
	}
	cout << result << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
int N;
string S[202];
vector<int> calc(int v){
    
    vector<int> dist(N, INF);
    dist[v] = 1;
    queue<int> que;
    que.push(v);
    while(!que.empty()){
        int now = que.front();
        que.pop();
        rep(i,0,N){
            if(S[now][i] == '0')continue;
            if(dist[i] == INF){
                dist[i] = dist[now] + 1;
                que.push(i);
            }else{
                if(abs(dist[i] - dist[now]) % 2 == 0){
                    cout << -1 << endl;
                    exit(0);
                }
                if(dist[i] > dist[now] + 1){
                    dist[i] = dist[now] + 1;
                    que.push(i);
                }
            }
        }
    }
    return dist;
}
main(){
    cin >> N;
    rep(i,0,N)cin >> S[i];
    int maxi = 0, maxn;
    
    auto dist = calc(0);
    //rep(i,0,N)cout << dist[i] << endl;
    rep(i,0,N){
        if(maxi < dist[i]){
            maxi = dist[i];
            maxn = i;
        }
    }
    auto dist2 = calc(maxn);
    int ans = 0;
    rep(i,0,N)ans = max(ans, dist2[i]);
    //cout << maxi << endl;
    //cout << ans << endl;
    rep(i,0,N){
        auto d = calc(i);
        ans = max(ans, *max_element(d.begin(), d.end()) );
    }
    cout << ans << endl;
}

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

int main() {

  while( true ) {

    long long int n;
    cin >> n;
    if ( n == 0 ) break;

    long long int ans = 0;

    long long int k = 0;
    long long int l = 0;
    long long int r = 0;

    for ( long long int i = 0; i < n; i++ ) {

      string in;
      cin >> in;

      if ( in == "lu" ) {
	l = 1;
      }else if ( in == "ru" ) {
	r = 1;
      }else if ( in == "ld" ) {
	l = 0;
      }else {
	r = 0;
      }

      if ( k == 0 && l == 1 && r == 1 ) {
	k = 1;
	ans++;
      }
      if ( k == 1 && l == 0 && r == 0 ) {
	k = 0;
	ans++;
      }

    }

    cout << ans << endl;

  }

  return 0;

}

Measured memory_bytes: 1204
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int main(void) {
	int a, b, t; cin >> a >> b >> t;
	int ans = 0;
	for (int i = a; i <= t; i+=a) {
		ans += b;
	}
	cout << ans << endl;
	return 0;
}

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

#define MAXN 50
#define WHITE 0
#define BLACK 2
#define GRAY 1

using namespace std;

struct {
  int i,j;
} typedef masu;

int A[MAXN][MAXN];
int color[MAXN][MAXN];
int d[MAXN][MAXN];
int p[MAXN][MAXN];
int H,W;

void bfs ( void )
{
  queue<masu> Q;

  Q.push({0,0});
  color[0][0] = GRAY;
  d[0][0] = 0;

  while(!Q.empty()) {
    int i = Q.front().i;
    int j = Q.front().j;
    Q.pop();

    if ( i-1 >= 0 && color[i-1][j] == WHITE && A[i-1][j] == WHITE ) {
      color[i-1][j] = GRAY;
      d[i-1][j] = d[i][j]+1;
      Q.push({i-1,j});
    }

    if ( i+1 < H && color[i+1][j] == WHITE && A[i+1][j] == WHITE  ) {
      color[i+1][j] = GRAY;
      d[i+1][j] = d[i][j]+1;
      Q.push({i+1,j});
    }

    if ( j-1 >= 0 && color[i][j-1] == WHITE && A[i][j-1] == WHITE ) {
      color[i][j-1] = GRAY;
      d[i][j-1] = d[i][j]+1;
      Q.push({i,j-1});
    }

    if ( j+1 < W && color[i][j+1] == WHITE && A[i][j+1] == WHITE ) {
      color[i][j+1] = GRAY;
      d[i][j+1] = d[i][j]+1;
      Q.push({i,j+1});
    }

    color[i][j] = BLACK;
  }
}


int main()
{
  int cnt = 0;

  cin >> H >> W;
  for ( int i = 0; i < H; ++i ) {
    for ( int j = 0; j < W; ++j ) {
      char c;
      cin >> c;
      if ( c == '.' ) {
        A[i][j] = WHITE;
        ++cnt;
      }
      else A[i][j] = BLACK;
    }
  }

  bfs();

  if ( color[H-1][W-1] == WHITE ) cout << -1 << "\n";
  else {
    cout << cnt-d[H-1][W-1]-1 << "\n";
  }

}


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

int main() {
    int n;
    bool flag = false;
    std::cin >> n;

    std::vector<long> v(n);
    for (int i = 0; i < n; i++) {
        std::cin >> v[i];
    }

    for (int i = n-1; i > 0; --i) {
        if (v[i-1] <= v[i]) continue;
        else if (v[i-1] - v[i] == 1) v[i-1] -= 1;
        else {
            std::cout << "No" << std::endl;
            return 0;
        }
    } 
    std::cout << "Yes" << std::endl;

}

Measured memory_bytes: 1024
import sys
from math import factorial
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

N, M = i_l()

a = 0
b = 0
if N > 1:
    a = factorial(N) / factorial(2) / factorial(N - 2)

if M > 1:
    b = factorial(M) / factorial(2) / factorial(M - 2)

print(int(a+b))

Measured memory_bytes: 3064
/*
 
                              Jai Shree Krishna !!
                                 Radhe Radhe !!
                                 
             उद्यमेन हि सिद्ध्यन्ति कार्याणि न मनोरथैः। नहि सुप्तस्य सिंहस्य मुखे प्रविशन्ति मृगाः।।
             
*/
   
   
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
typedef long long ll;
#define loop(i,n)  for(int i=0;i<n;i++)
#define read(a) int a; cin >>a;
#define readarr(a,n) int a[n] ; for(int i=0;i<n;i++) cin >> a[i];
#define readmat(a,n,m) int a[n][m]; for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin >> a[i][j];
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define pi pair<int,int>
#define vvi vector<vector<int>>
#define sti set<int>
#define vpi vector<pair<int,int>>
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define printmat(a,n,m) for(int i=0;i<n;i++) {for(int j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define endl "\n"
#define mp make_pair
#define ins insert
#define rep(i,s,e)   for(int i=s;i<=e;i++)
#define repd(i,s,e)  for(int i=e;i>=s;i--)
#define vb vector<bool>
#define read2(n,m) int n,m; cin >> n >> m;
#define range(v) v.begin(),v.end()
#define sortd(v) sort(v.begin(),v.end(),greater<int>())
#define sorti(v) sort(v.begin(),v.end())
 
const ll inf = 1e18;
const ll mod = 1e9 + 7;
 
 
int divisors(int n){
	int ans=0;
	if(n%2==0){
		int c=0;
		while(n%2==0){
			c++;
			n=n/2;
		}
		int r=0,i=1;
		while(c>r){
		 r += i;
		 i++;
		}
		if(c==r) ans+=(i-1);
		else ans+=(i-2);
	}
	
	for(int j=3;j*j<=n;j++){
		if(n%j==0){
		int c=0;
		while(n%j==0){
			c++;
			n=n/j;
		}
		int r=0,i=1;
		while(c>r){
		 r+=i;
		 i++;
		}
		if(c==r) ans+=(i-1);
		else ans+=(i-2);
		}
	}
	if(n>1) ans++;
	return ans;
}
signed main()
{
 
    fast;
    read(n);
    int ans = divisors(n);
    cout<<ans<<endl;
    return 0;
}
 
/* Pooja Yadav */

Measured memory_bytes: 3652
#import sys

#input = sys.stdin.readline



def main():
#    h,w,a,b = map(int, input().split())
    n=int(input())
    s=input()
    if n>=2:
        for i in range(1,n):
            if s[i]==s[i-1]:
                n-=1
    print(n)






if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
mod = 1000000007


def modpow(a, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        h = modpow(a, p // 2)
        return h * h % mod
    else:
        return a * modpow(a, p - 1) % mod


def calc(a, b):
    if b > a - b:
        return calc(a, a - b)
    am = 1
    ad = 1
    for i in range(b):
        am *= (a - i)
        ad *= (i + 1)
        am %= mod
        ad %= mod
    return am * modpow(ad, mod - 2) % mod


def main():
    N, M = map(int, input().split())
    res = M
    ans = 1
    i = 2
    while res >= i * i:
        if res % i == 0:
            c = 0
            while res % i == 0:
                c += 1
                res //= i
            ans *= calc(N + c - 1, N - 1)
            ans %= mod
        i += 1
    if res != 1:
        ans *= calc(N, N - 1)
        ans %= mod
    print(ans)


main()


Measured memory_bytes: 3064
var
s:String;
L,i,j,f:Longint;
begin
readln(s);
for L:=length(s)downto 1 do begin
for i:=1 to length(s)-L+1 do begin
f:=1;
for j:=0 to L-1 do begin
if(s[i+j]<>'A')and(s[i+j]<>'T')and(s[i+j]<>'G')and(s[i+j]<>'C')then begin
f:=0;
break;
end;
end;
if f=1 then begin
writeln(L);
exit;
end;
end;
end;
writeln(0);
end.

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

int main(){
  int n;
  cin>>n;
  int vec[n];
  for(int i=0;i<n;i++){
    cin>>vec[i];
  }
  int ans[n];
  int size=n;
  int now=0;
  while(size>=1){
    int flag=0;
    for(int i=size-1;i>=0;i--){
      if(vec[i]==i+1){
        ans[now]=vec[i];
        now++;
        flag++;
        for(int j=0;j<size;j++){
          if(j<i){
            vec[j]=vec[j];
          }
          if(j>i){
            vec[j-1]=vec[j];
          }
        }
        size--;
        break;
      }
    }
    if(flag==0){
      cout<<-1<<endl;
      return 0;
    }
  }
  for(int i=n-1;i>=0;i--){
    cout<<ans[i]<<endl;
  }
}

Measured memory_bytes: 3524
#include <iostream>
using namespace std;
int main() {
        int n;
        while(cin>>n) {
                int jwb=0;
                for(int i=0;i<10;i++) {
                        for(int j=0;j<10;j++) {
                                for(int k=0;k<10;k++) {
                                        for(int l=0;l<10;l++) {
                                                if(i+j+k+l==n) jwb++;
                                        }
                                }
                        }
                }
        cout<<jwb<<endl;
        }
        return 0;
}

Measured memory_bytes: 1160
use std::io;
use std::cmp::min;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let n: usize = buf.trim().parse().unwrap();
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let mut a: Vec<i64> = buf.trim().split_whitespace().enumerate().map(|(i, s)| {
        s.parse::<i64>().unwrap() - (i as i64) - 1
    }).collect();
    a.sort();
    if n % 2 == 0 {
        let m1: i64 = a.iter().map(|x| (x - a[n / 2]).abs()).sum();
        let m2: i64 = a.iter().map(|x| (x - a[n / 2 - 1]).abs()).sum();
        println!("{}", min(m1, m2));
    } else {
        println!("{}", a.iter().map(|x| (x - a[n / 2]).abs()).sum::<i64>());
    }
}


Measured memory_bytes: 10492
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N; cin >> N;
  vector<int> H(N);
  rep(i, N) cin >> H[i];

  int ans = 0;
  int tmp = 0;
  for (int i = 0; i < N; ++i){
    if (H[i] >= H[i + 1] && i + 1 < N) {
      tmp++;
    }
    else {
      ans = max(ans, tmp);
      tmp = 0;
    }
  }
  ans = max(ans, tmp);
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <numeric>

#define repAll(n) (n).begin(), (n).end()
#define repConAll(n) (n).cbegin(), (n).cend()

using namespace std;

namespace {
	const set<int> numbersStandard{ 3, 5, 7 };
}
void DspNumbers(const vector<int>& numbers) // for Debug
{
	for (auto itr = numbers.rbegin(); itr != numbers.rend(); ++itr){
		cout << *itr << ",";
	}
	cout << endl;
}

long long MakeNumber(const vector<int>& numbers)
{
	long long multi = 1;
	long long sum = 0;
	for (const auto& elem : numbers){
		sum += elem * multi;
		multi *= 10;
	}
	return sum;
}

void DFS_5(long long tmpN, long long N, vector<int> numbers, int& countAll)
{
	for (int digit = 0 ; digit <= 7; ++digit){
		switch (digit){
		case 0: // 最上位桁は0が許される。
		case 3:
		case 5:
		case 7:
			{
				vector<int>numbers2(numbers);
				if (digit == 0){ // ここで終わり。
					set<int> tmpSet(numbers2.begin(), numbers2.end());
					if (tmpSet == numbersStandard
						&& MakeNumber(numbers) <= N)
					{
						++countAll;
					}
					if (tmpN == 0){
						return;
					}
				}
				else {
					numbers2.push_back(digit);
					// DspNumbers(numbers2);
					DFS_5(tmpN / 10, N, numbers2, countAll);
				}
			}
			break;
		default:
			break;
		}
	}
	
}
int main()
{
	long long N = 0;
	cin >> N;

	vector<int> numbers;
	int countAll(0);
	DFS_5(N, N, numbers, countAll);

	cout << countAll << endl;

	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define fi first
#define se second
#define pb push_back
#define read(type, ...)type __VA_ARGS__; macro_scan(__VA_ARGS__);
#define debug(...)cerr<<"["<<#__VA_ARGS__<<"] : ",deb(__VA_ARGS__);

using namespace std;

template<typename T> void macro_scan(T& t){cin>>t;};
template<typename F, typename ...R>void macro_scan(F& f , R& ...r){
  cin>>f;macro_scan(r...);
}

void deb(){
    cerr<<endl;
}
template<typename T , typename... t>
void deb(T a , t...b){
    cerr<<a<<",";
    deb(b...);
}
template<typename T>
void dev(vector<T>v){
    int c = 0;
    for(auto i : v){
        cerr<<i<<" ";
        c++;
    }
    cerr<<endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //int t; cin>>t;for(;t--;)done();
    read(int , n);
    int rem = n % 10;
    string ans = "";
    if(rem == 0 || rem == 1 || rem == 6 || rem == 8)ans = "pon";
    else if(rem == 2 || rem == 4 || rem == 5 || rem == 7 || rem == 9)ans = "hon";
    else ans = "bon";
    cout<<ans<<"\n";
}


//@01928419790ar epic games ar7iq r7e

Measured memory_bytes: 3580
#include<iostream>
#include<vector>
#include<set>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  int n; cin >>n;
  vector<li> a(n),pos(n);
  rep(i,n){
    int t; cin >>t;
    a[i]=t;
    pos[t-1]=i;
  }
  li s=0;
  set<int> st;
  st.insert(-1); st.insert(n);
  rep(i,n){
    auto itr=st.upper_bound(pos[i]);
    li next=*itr; itr--;
    li prev=*itr;
    if(df)print(i+1,prev,pos[i],next);
    s+=(i+1)*(next-pos[i])*(pos[i]-prev);
    st.insert(pos[i]);
  }
  print(s);
}


Measured memory_bytes: 15628
max_score = 0
total = int(input())
now = 0
count = 0 
i = 0
if total == 1:
    print(0)
    exit()
number_list = list(map(int,input().split(" ")))
while i == 0:
    if number_list[now] >= number_list[now+1] and now+1 != total-1:
        count += 1
        now += 1
    elif number_list[now] >= number_list[now+1] and now+1 == total-1:
        count += 1
        now += 1
        if max_score < count:
            max_score = count
        break
    elif number_list[now] < number_list[now+1] and now+1 == total-1:
        break
    else:
        now += 1
        if max_score < count:
            max_score = count
            count = 0
        else:
            count = 0
            continue
print(max_score)

Measured memory_bytes: 14400
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-12 12:06:42
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

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

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int f(int x)
{
    if (x < 10) return x;
    else return x%10 + f(x/10);
}

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

    if (n % f(n) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256