akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

struct Heap {
    int *set;
    int numberKeys;

    Heap() {
        this->set = new int[2000001];
        this->numberKeys = 0;
    }

    ~Heap() {
        delete [] this->set;
    }

    void insert(int key) {
        this->set[++this->numberKeys] = key;

        bool isHeap = false;
        for (int i = this->numberKeys; !isHeap && i > 1; i /= 2) {
            if (this->set[i] <= this->set[i / 2])
                isHeap = true;
            else {
                int aux = this->set[i];
                this->set[i] = this->set[i / 2];
                this->set[i / 2] = aux;
            }
        }
    }

    int extractMax() {
        int max = this->set[1];
        this->set[1] = this->set[this->numberKeys--];
        heapify(1);

        return max;
    }

    void heapify(int position) {
        if (position <= this->numberKeys / 2) {
            int sonPos = position * 2;

            if (sonPos + 1 <= this->numberKeys && this->set[sonPos + 1] > this->set[sonPos])
                sonPos++;

            if (this->set[sonPos] > this->set[position]) {
                int aux = this->set[position];
                this->set[position] = this->set[sonPos];
                this->set[sonPos] = aux;

                heapify(sonPos);
            }
        }
    }
};

int main() {
    Heap heap;
    string input;

    while (cin >> input && input != "end") {
        if (input == "insert") {
            int key;
            cin >> key;
            heap.insert(key);
        } else {
            int max = heap.extractMax();
            cout << max << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 6812
n = int(input())

i = 1
ans = []
while n > 0:
   v = (n % (26 ** i)) // (26 ** (i-1))
   if v == 0:
      ans.append('z')
      n -= (26 ** i)
      i += 1
   else:
      ans.append(chr(ord('a') + v - 1))
      n -= n % (26 ** i)
      i += 1
print("".join(reversed(ans)))


Measured memory_bytes: 61852
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

    int a, b, t;
    cin>>a>>b>>t;

    int c = t / a;
    cout<<b * c<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,i,in,j;
    while(cin>>a>>b,a||b){
        int d[100]={};
        for(i=0;i<a;i++){
            cin>>c;
            for(j=0;j<c;j++){
                cin>>in;
                d[in]++;
            }
        }
        in=0;
        for(i=1;i<100;i++)if(in<d[i]){in=d[i];c=i;}
        if(in>=b)cout<<c<<endl;
    else cout<<0<<endl;
    }
}
 

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//<W,E>
int main() {
    int n; cin >> n;
    string s; cin >> s;
    int left=0, right=0;
    rep(i, n-1) if(s[i+1] == 'E') right++;
    int ans = 1 << 30;
    rep(i, n) {
        ans = min(ans, left + right);
        if(i!=n-1) if(s[i+1]=='E') right--;
        if(s[i]=='W') left++;
    }
    cout << ans;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define il inline

namespace io {

#define in(a) a = read()
#define out(a) write(a)
#define outn(a) out(a), putchar('\n')

#define I_int ll
inline I_int read() {
    I_int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}
char F[200];
inline void write(I_int x) {
    if (x == 0) return (void) (putchar('0'));
    I_int tmp = x > 0 ? x : -x;
    if (x < 0) putchar('-');
    int cnt = 0;
    while (tmp > 0) {
        F[cnt++] = tmp % 10 + '0';
        tmp /= 10;
    }
    while (cnt > 0) putchar(F[--cnt]);
}
#undef I_int

}
using namespace io;

using namespace std;

#define N 100010

char s[N];

bool check(char c) {
	if(c == 'A') return 1;
	if(c == 'G') return 1;
	if(c == 'T') return 1;
	if(c == 'C') return 1;
	return 0;
}

int main() {
	 scanf("%s",s); int cnt = 0, ans = 0, n = strlen(s);
	 for(int i = 0; i < n; ++i) {
	 	if(check(s[i])) ++cnt;
	 	else ans = max(ans, cnt), cnt = 0;
	 }
	 ans = max(ans, cnt);
	 outn(ans);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){  
    int H, W, i, j, k;
    for(i = 0; i < 90000; i++){
    cin >> H >>W;
    if ( H == 0 && W == 0) break;
     
     for (j = 0; j < H; j++){
        if(j == 0 || j == H - 1){
        for(k = 0; k < W; k++){
        cout << "#";
        }}
        else{
        for(k = 0; k < W; k++){
        if(k == 0 || k == W -1) cout << "#";
        else cout <<".";
        }}
        cout << endl;
    }cout << endl;}
return 0;}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int main(){
    int n;
    cin >> n;
    vector<int> ans(n+1);
    for(int x=1;x<=100;x++){
        for(int y=1;y<=100;y++){
            for(int z=1;z<=100;z++){
                int s=x*x+y*y+z*z+x*y+y*z+z*x;
                if(s>n) continue;
                ans[s]++;
            }
        }
    }
    for(int i=1;i<=n;i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String s = sc.next();
        if (n % 2 != 0) {
            System.out.println("No");
            return;
        }
        if (s.substring(0, (n / 2)).equals(s.substring((n / 2)))) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
using namespace std;
const int match[10]={0,2,5,5,4,5,6,3,7,6};

int main(){
   int n,m; cin >> n >> m;
   vector<int> a(m);
   vector<int> dp(10005,-INF);
   rep(i,m) cin >> a[i];
   sort(all(a));
   reverse(all(a));
   dp[0]=0;
   for(int i=1; i<=n; i++){
       rep(j,a.size()){
           if(i-match[a[j]]<0) continue;
           dp[i]=max(dp[i-match[a[j]]]+1,dp[i]);
       }
   }
   int num=n;
   while(num>0){
       rep(j,a.size()){
           if(num-match[a[j]]<0) continue;
           if(dp[num-match[a[j]]]==dp[num]-1){
               printf("%d",a[j]);
               num-=match[a[j]];
               break;
           }
       }
   }
return 0;
}


Measured memory_bytes: 256
inputStr = input()
inputNum = len(inputStr)
string = "abcdefghijklmnopqrstuvwxyz"
count1, count2 = 0, 0
for i in string:
  count2 = 0
  for j in inputStr:
    if i == j:
      break
    else:
      count2 += 1
  if count2 == inputNum:
    break
  count1 += 1
if count1 == 26:
  print("None")
else:
  print(i)

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

using namespace std;

map <string,int> mp;
set <string> st;
int n,m;

int main(){
	cin >> n;
	int sol = 0;
	for(int i = 0; i < n; i++){
		string input;
		cin >> input;
		st.insert(input);
		mp[input]++;
	}
	cin >> m;
	for(int i = 0; i < m; i++){
		string input;
		cin >> input;
		mp[input]--;
	}
	for(auto x : st){
		sol = max(sol,max(0,mp[x]));
	}
	cout << sol;
	
}

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

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            //string[] str = Console.ReadLine().Split(' ');
            //int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            int n = s.Length;
            for(int i = 0; i < n/2; i++)
            {
                if (s[i] != s[n - 1 - i])
                {
                    Console.WriteLine("No");
                    return;
                }

            }

            for(int i = 0; i < (n - 1) / 2; i++)
            {
                if (s[i] != s[(n - 1) / 2 - 1 - i])
                {
                    Console.WriteLine("No");
                    return;
                }
            }


            for (int i= 0; i < (n-1)/2; i++)
            {
                if (s[(n + 3) / 2 - 1 + i] != s[n - 1 - i])
                {
                    Console.WriteLine("No");
                    return;
                }
            }

            Console.WriteLine("Yes");


            //ここまで
        }



    }

}


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

public class hello
{
    public static void Main()
    {
        var allcard = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 };
        var scard = new List<int>();
        var hcard = new List<int>();
        var ccard = new List<int>();
        var dcard = new List<int>();

        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            switch(line[0])
            {
                case "S":
                    scard.Add(int.Parse(line[1]));
                    break;
                case "H":
                    hcard.Add(int.Parse(line[1]));
                    break;
                case "C":
                    ccard.Add(int.Parse(line[1]));
                    break;
                 case "D":
                    dcard.Add(int.Parse(line[1]));
                    break;
                default:
                    break;
            }
        }
        var z = allcard.Except(scard).ToList();
        z.Sort();
        foreach (var ss in z)
            Console.WriteLine("S {0}", ss);
        var zz = allcard.Except(hcard).ToList();
        zz.Sort();
        foreach (var ss in zz)
            Console.WriteLine("H {0}", ss);
        var zzz = allcard.Except(ccard).ToList();
        zzz.Sort();
        foreach (var ss in zzz)
            Console.WriteLine("C {0}", ss);
        var zzzz = allcard.Except(dcard).ToList();
        zzzz.Sort();
        foreach (var ss in zzzz)
            Console.WriteLine("D {0}", ss);



    }
}



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

int main()
{
        ll N; cin >> N;
        vector<ll> a(N, 0);
        ll wari4 = 0;
        ll wari2 = 0;
        ll elc = 0;
        for (int i = 0; i < N; ++i) {
                ll a; cin >> a;
                if (a % 4 == 0) wari4++;
                else if (a % 2 == 0) wari2++;
                else elc++;
        }
        if (wari2) {
                elc++;
                wari2 = 0;
        }
        if (wari4 >= (elc -1)) {
                cout << "Yes" << endl;
        }
        else {
                cout << "No" << endl;
        }
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll a, b;

	cin >> a >> b;

	if (a + b >= 10) {
		cout << "error" << endl;
	}
	else {
		cout << a + b << endl;
	}
}

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


int N;

int count(int a, int b) {
  int ans = 0;
  for (int i = 1; i <= N; ++i) {
    int n = i;
    int head = 0;
    while (n != 0) {
      head = n % 10;
      n /= 10;
    }
    int back = i % 10;
    if (a == head && b == back) {
      ans++;
    }
  }

  return ans;
}

void Main() {
  cin >> N;
  ll ans = 0;

  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      ans += count(i, j) * count(j, i);
    }
  }

  cout << ans << endl;
}

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

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

bool cmp(long long x, long long y){
    return x>y;
}
int main()
{
    int ca, cb, cc, k;
    cin>>ca>>cb>>cc>>k;
    
    //vector<long long> a, b, c; 错解，会RE，搞不明白；
    vector<long long> a(ca), b(cb), c(cc);
    for (int i=0; i<ca; i++) cin>>a[i];
    for (int i=0; i<cb; i++) cin>>b[i];
    for (int i=0; i<cc; i++) cin>>c[i];

    vector<long long> tmp;
    for (int i=0; i<ca; i++) 
        for (int j=0; j<cb; j++) 
            tmp.push_back(a[i]+b[j]);

    sort(tmp.begin(), tmp.end(), cmp);
    //reverse(tmp.begin(), tmp.end());

    vector<long long> ans;
    for (int i = 0; i < min(k, (int)tmp.size()); i++) {
        for (int j = 0; j < cc; j++) {
            ans.push_back(tmp[i] + c[j]);
        }
    }
    sort(ans.begin(), ans.end(), cmp);
    //reverse(ans.begin(), ans.end());

    for (int i = 0; i < k; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}


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

using namespace std;

#define ll long long

int main()
{
	ll N;
	cin >> N;
	vector < ll > A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	vector < ll > cnt(N + 1, 0);
	for (int i = 0; i < N; i++) {
		cnt[A[i]]++;
	}

	vector < ll > combi(N + 1, 0);
	ll totalCombi = 0;
	for (int i = 1; i <= N; i++) {
		combi[i] = cnt[i] * (cnt[i] - 1) / 2;
		totalCombi += combi[i];
	}

	for (int i = 0; i < N; i++) {
		ll ans = totalCombi - combi[A[i]];
		ans += (cnt[A[i]] - 1) * (cnt[A[i]] - 2) / 2;
		cout << ans << endl;
	}

	return 0;
}


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

#define debug(x) cerr << #x << ": " << x << endl

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n, k;
  cin >> n >> k;
  cout << ((n + k - 1) / k) - (n / k) << '\n';  
  return 0;
}

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

long long int lcm(long long int c, long long int d) {
  long long int M = max(c, d);
  long long int m = min(c, d);
  long long int LCM;
  while(true) {
    int k = M / m;
    if (k * m == M) {
      LCM = c * d / m;
      break;
    }
    int l = m;
    m = M - k * m;
    M = l;
  }
  return LCM;
}

int main() {
  long long int A, B, C, D, ac, ad, bc, bd, CD, acd, bcd, x, y;
  cin >> A >> B >> C >> D;
  CD = lcm(C, D);
  ac = (A - 1) / C;
  ad = (A - 1) / D;
  acd = (A - 1) / CD;
  bc = B / C;
  bd = B / D;
  bcd = B / CD;
  x = bc + bd - bcd - (ac + ad -acd);
  y = B -A +1 -x;
  printf("%lld\n", y);
}

Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect
sys.setrecursionlimit(10**7)
INF = 10**10
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

N,Q = LI()
N0 = 2 ** (N.bit_length())
node = [0 for _ in range(N0*2)]
lazy = [0 for _ in range(N0*2)]


def gindex(l,r):
    L = l + N0; R = r + N0
    lm = (L // (L & -L)) // 2
    rm = (R // (R & -R)) // 2
    while L < R:
        if R <= rm:
            yield R-1
        if L <= lm:
            yield L-1
        L //= 2; R //= 2
    while L > 0:
        yield L-1
        L //= 2

def eval(*ids):
    for i in reversed(ids):
        v = lazy[i]
        if v:
            lazy[i*2+1] += v
            lazy[i*2+2] += v
            node[i*2+1] += v
            node[i*2+2] += v
        lazy[i] = 0

def data_add(l,r,v):
    *ids, = gindex(l,r)
    eval(*ids)

    L = l + N0; R = r + N0
    while L < R:
        if R % 2:
            R -= 1
            lazy[R-1] += v
            node[R-1] += v
        if L % 2:
            lazy[L-1] += v
            node[L-1] += v
            L += 1
        L //= 2; R //= 2

    for i in ids:
        node[i] = min(node[i*2+1],node[i*2+2])

def data_get(l,r):
    eval(*gindex(l,r))

    ret = INF
    L = l + N0; R = r + N0
    while L < R:
        if R % 2:
            R -= 1
            ret = min(ret,node[R-1])
        if L % 2:
            ret = min(ret,node[L-1])
            L += 1
        L //= 2; R //= 2
    return ret

for _ in range(Q):
    s = LI()
    if s[0] == 0:
        data_add(s[1],s[2]+1,s[3])
    else:
        print (data_get(s[1],s[2]+1))




Measured memory_bytes: 22096
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static readonly int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			//System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start();
			//Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//string s = Console.ReadLine();
			//int x = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			int x = vs[0];
			int y = vs[1];
			//int redCount = vs[2];
			//int greenCount = vs[3];
			//int whiteCount = vs[4];
			long[] red = new long[] { 0 }.Concat(Console.ReadLine().Split().Select(long.Parse).OrderByDescending(i => i)).ToArray();
			long[] green = new long[] { 0 }.Concat(Console.ReadLine().Split().Select(long.Parse).OrderByDescending(i => i)).ToArray();
			long[] white = new long[] { 0 }.Concat(Console.ReadLine().Split().Select(long.Parse).OrderByDescending(i => i)).ToArray();
			for (int i = 1; i < red.Length; i++) {
				red[i] += red[i - 1];
			}
			for (int i = 1; i < green.Length; i++) {
				green[i] += green[i - 1];
			}
			for (int i = 1; i < white.Length; i++) {
				white[i] += white[i - 1];
			}

			int a = x;
			int b = y;
			int c = 0;
			long sum = 0;
			long ans = 0;

			// 赤色 + 無色 で X 個 食べた時の最大値
			for (int i = x; i >= 0; i--) {
				int j = x - i;
				if (j < white.Length) {
					long k = red[i] + white[j];
					if (sum < k) {
						a = i;
						c = j;
						sum = k;
						ans = Math.Max(ans, sum + green[b]);
					} else {
						break;
					}
				} else {
					break;
				}
			}
			//System.Diagnostics.Debug.WriteLine($"a={a} b={b} c={c} sum={sum}({red[a]}+{white[c]}) ans={ans}");

			// 赤色 + 無色 で X+(1～Y) 個 食べた時の最大値
			for (int i = 1; i <= y; i++) {
				if (a + 1 <= x && c + 1 < white.Length) {
					if (red[a + 1] + white[c] > red[a] + white[c + 1]) {
						// 赤+1
						a++;
					} else {
						// 白+1
						c++;
					}
				} else if (a + 1 <= x) {
					// 赤+1
					a++;
				} else if (c + 1 < white.Length) {
					// 白+1
					c++;
				} else {
					break;
				}
				sum = red[a] + white[c];
				b = y - i;
				ans = Math.Max(ans, sum + green[b]);
				//System.Diagnostics.Debug.WriteLine($"a={a} b={b} c={c} sum={sum}({red[a]}+{white[c]}) ans={ans}");
			}
			Console.WriteLine(ans);


			//Console.Out.Flush();
			//System.Diagnostics.Debug.WriteLine(sw.Elapsed);
		}
	}
}

Measured memory_bytes: 41644
#include<iostream>
using namespace std;
int main () {
  int a, b, c, d, l, r;
  cin >> a >> b >> c >> d;
  l = a+b;
  r = c+d;
  if (l>r) {
    cout << "Left" << endl;
  } else if (l<r) {
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}

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

int main()
{
    ll H,W;
    ll mod=1000000007;
    cin>>H>>W;
    ll dp[H+1][W+1]={0};
    for(ll i=0;i<=H;i++)
        for(ll j=0;j<=W;j++)
            dp[i][j]=0;
    dp[1][0]=1;
    for(int i=1;i<=H;i++)
        for(int j=1;j<=W;j++)
        {
            char x;
            cin>>x;
            if(x=='#')
                dp[i][j]=0;
            else
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
        }
    cout<<dp[H][W]<<endl;
    return 0;
}


Measured memory_bytes: 8064
#include <cstdio>

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    int max= a + b;
    if (a*b > max) {
        max = a*b;
    }
    if (a-b > max) {
        max = a-b;
    }
    printf("%d", max);
}


Measured memory_bytes: 128
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

using ll = long long;

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

#define mp make_pair
#define mt make_tuple

/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)

/* ---------- container ---------- */

#define gsort(b, e) sort(b, e, greater<decltype(*b)>())

/* ----------- debug ---------- */

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.first << "," << p.second << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
inline T sq(T a) { return a * a; }

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

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

ll pcnt(ll b) {
    return __builtin_popcountll(b);
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

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

    int ans = 1000;
    for (int i = 0; i < S.size() - 2; ++i) {
        ans = min(ans, abs(753 - stoi(S.substr(i, 3))));
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main(){

  int N,X,Y,i,j;
  int ans[2000]={};

  cin>>N>>X>>Y;

  for(i=1;i<N;i++){
    for(j=i+1;j<N+1;j++){
      if((abs(X-i)+abs(Y-j)+1)<j-i){
	ans[(abs(X-i)+abs(Y-j)+1)]+=1;
	//cout<<i<<" "<<j<<" "<<j-i+Y-X+1<<endl;
      }
      else{
	ans[j-i]+=1;
      }
    }
  }
  for(i=1;i<N;i++){
    cout << ans[i] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
n, k ,q = map(int,input().split())
A = []
for i in range(n):
    A.append(k)
for i in range(q):
    tmp = int(input()) - 1
    A[tmp] += 1
for i in range(n):
    if A[i] - q <= 0:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 6592
import Data.List
main=do
    n<-readLn::IO Int
    as<-map read.words<$>getLine::IO[Int]
    let t = (sum as) `div` n
    print $ minimum $ map (\t -> foldl (\s a->s+(a-t)^2) 0 as) [t-1..t+1]


Measured memory_bytes: 1020
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x) // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    unordered_map<string, ll> mp;
    for (ll i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        sort(ALL(s));
        mp[s]++;
    }
    ll ans = 0;
    for (auto p : mp)
    {
        ans += (p.second - 1) * p.second / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 10660
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;
using pii = pair<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}
int binary_search_index(Int Y, vi &q){
    int left = 0, right = q.size() - 1;
    while (right >= left) {
        int mid = left + (right - left) / 2;
        if (q[mid] == Y) return mid;
        else if (q[mid] > Y) right = mid - 1;
        else if (q[mid] < Y) left = mid + 1;
    }
    return -1;
}


Int combination(Int n, Int r) {
    if(n == 1){return 0;}
    if ( r * 2 > n ) r = n - r;
    uintmax_t dividend = 1;
    uintmax_t divisor  = 1;
    for ( unsigned int i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

int main() {
    Int N;
    cin >> N;
    vector<double> v = vector<double>(N);

    rep(i,N){
        cin>>v[i];
    }

    double ans =0;

    sort(v.begin(),v.end());

    double pre = (v[0]+v[1])/2;

    if(N==2){
        cout << pre << endl;
        return 0;
    }

    REP(i,2,N){
      ans = (pre+v[i])/2;
      pre=(pre+v[i])/2;
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	string s;
	cin>>s;
	int left,right;
	for (int i = 0; i < s.size(); i++){
		if(s[i] == 'A'){
			left=i;
			break;
		}
	}
	for (int i = s.size()-1; i >= 0; i--){
		if(s[i]=='Z'){
			right=i;
			break;
		}
	}
	cout<<right-left+1<<endl;
	return 0;
}

Measured memory_bytes: 640
// Problem : C - Maximum Volume
// Contest : AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	ld a = (n / 3.0);
	cout << fixed << setprecision(10) << a * a * a << endl;
	return 0;
}
 


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from heapq import heappush, heappop, heapify
from collections import defaultdict

"""
・最小値のある場所を調べる。左右にまたがる辺は結ばない。
・最小値の両隣は必ず最小値と結ぶ。
・結んだあと1点に縮約していく。
"""

N,D,*A = map(int,read().split())

A = [0] + A + [0] # 番兵

# (value<<32) + (index)
mask = (1<<32)-1
q = [(x<<32)+i for i,x in enumerate(A[1:-1],1)]
heapify(q)
removed = defaultdict(int)

cost = []
while q:
    while q:
        x = q[0]
        if not removed[x]:
            break
        heappop(q); removed[x] -= 1
    if not q:
        break
    x = heappop(q)
    val,ind = x>>32, x&mask
    L = A[ind-1]; R = A[ind+1]
    if L:
        cost.append(L+val+D)
        # Lの値を書き換える
        newL = val+D
        if L > newL:
            A[ind-1] = newL
            removed[(L<<32)+(ind-1)] += 1
            heappush(q,(newL<<32)+(ind-1))
    if R:
        cost.append(R+val+D)
        # Lの値を書き換える
        newR = val+D
        if R > newR:
            A[ind+1] = newR
            removed[(R<<32)+(ind+1)] += 1
            heappush(q,(newR<<32)+(ind+1))
    A[ind] = 0

answer = sum(cost)
print(answer)

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define pi  3.14159265359
#define mod 1000000007
int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);


    int n;
    cin>>n;
    if(n>=400&&n<=599){
        cout<<8;
    }else if(n>=600&&n<=799){
    cout<<7;
    }else if(n>=800&&n<=999){
    cout<<6;
    }else if(n>=1000&&n<=1199){
    cout<<5;
    }else if(n>=1200&&n<=1399)
    {
        cout<<4;
    }else if(n>=1400&&n<=1599){
        cout<<3;
    }else if(n>=1600&&n<=1799){
    cout<<2;
    }else if(n>=1800&&n<=1999){
    cout<<1;
    }


    return 0;
}


Measured memory_bytes: 3616
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();
        System.out.println(GreatestCommonDivisor(a, b));
   
    }
    public static int GreatestCommonDivisor(int a, int b){
        int x = Math.max(a,b);
        int y = Math.min(a,b);
        int temp = 0;
        while(y > 0){
            temp = x % y;
            x = y;
            y = temp;
            
        }
    return x;
        
    }
}


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


int main(){
  long long a,b,c,x,y,ans;
  cin >>a>>b>>c>>x>>y;

  for(int i=0;i<=max(x,y);i++){
    int p=x-i;
    int q=y-i;
    if(i==0){
      ans = a*(x-i)+b*(y-i)+c*2*i;
    }
    if(a*max(0,p)+b*max(0,q)+c*2*i <=ans){
      ans =a*max(0,p)+b*max(0,q)+c*2*i;
    }

  }
  cout <<ans <<endl;
}


Measured memory_bytes: 256
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.append(0)
ans = 0

for i in range(n):
    if a[i] + a[i-1] > x:
        b = x - a[i-1]
        ans += a[i] - b
        a[i] = b 

print(ans)


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

#define loop(s, e, i) for (int i = s; i < e; ++i)
#define print(s) cout << s << endl;
#define DIV 1000000007
#define ll = long long
using namespace std;

/*
浮動小数点の入力
cout << fixed << setprecision(9) << endl;
*/

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

  int count = 0;
  loop(0, 1000, n) {
    int f = 0;
    int c[3] = {n/100, (n/10)%10, n%10};
    loop(0, N, j) {
      if (c[f] == S[j]-'0') {
        f++;
      }
      if (f == 3) {
        count++;
        break;
      }
    }
  }
  print(count);
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, a, b) for(int i=(a);i<=(b);++i)

main(){
    while(1){
        int n;
        cin >> n;
        if(!n) break;
        vector<string> s(n);
        rep(i, n) cin >> s[i];
        int ans = 0;
        rep(i, n / 2) {
            if(s[i * 2][0] != s[i * 2 + 1][0]) ans++;
        }
        cout << ans << "\n";
    }
}


Measured memory_bytes: 3156
#include <iostream>
#include <cstring>

using namespace std;

typedef long long ll;

int main() {
  string s;
  int q;
  cin >> s;
  cin >> q;
  string l,r;
  bool on = false;
  for(int i = 0; i < q; i++) {
    int Q;
    cin >> Q;
    if(Q == 1) {
      on = !on;
    }
    else {
      int f;
      char c;
      cin >> f >> c;
      if(f == 2) {
	if(on) {
	  l = c + l;
	}
	else r += c;
      }
      else {
	if(on) {
	  r += c;
	}
	else {
	  l = c + l;
	}
      }
    }
  
  }
  string ans = l + s + r;
  if(on) {
    for(int i = ans.size() - 1; i >= 0; i--) cout << ans[i];
    cout << endl;
  }
  else cout << ans << endl;
}
    
  



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

int main(){
    int n, k;
    cin >> n >> k;
    if(k <= n/2 + n%2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

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

using namespace std;

int w, h;
int field[51][51];
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

void dfs(int x, int y)
{
    field[y][x] = -1;

    for (int i = 0; i < 8; i++)
    {
        int nx = x + dx[i];
        int ny = y + dy[i];

        if (nx < 0 || ny < 0 || nx >= w || ny >= h)
            continue;

        if (field[ny][nx] == 1)
            dfs(nx, ny);
    }
}

int main()
{
    while (cin >> w >> h, w || h)
    {
        for (int y = 0; y < h; y++)
        {
            for (int x = 0; x < w; x++)
            {
                cin >> field[y][x];
            }
        }

        int ans = 0;

        for (int y = 0; y < h; y++)
        {
            for (int x = 0; x < w; x++)
            {
                if (field[y][x] == 1)
                {
                    dfs(x, y);
                    ans++;
                }
            }
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
#define INF 100

int main(void) {
    int n, count[26];
    string s[50];
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> s[i];
    fill (count, count + 26, INF);
    for (int i = 0; i < n; i++) {
        int temp[26] = {};
        for (int j = 0; j < s[i].size(); j++)
            temp[s[i][j] - 'a']++;
        for (int j = 0; j < 26; j++)
            count[j] = min(count[j], temp[j]);
    }
    for (int i = 0; i < 26; i++) {
        for (int j = 0; j < count[i]; j++)
            cout << (char)('a' + i);
    }
}

Measured memory_bytes: 256
N=int(input())
B=input().split()
A=[]
A.append(int(B[0]))
for i in range(1,N-1):
  A.append(min(int(B[i-1]),int(B[i])))
A.append(int(B[N-2]))
ans=0
for i in A:
  ans=ans+i
print(ans)


Measured memory_bytes: 3060
S = input()

odd = {c for i, c in enumerate(S, 1) if i % 2 != 0}
even = {c for i, c in enumerate(S, 1) if i % 2 == 0}

if odd.issubset({ 'R', 'U', 'D' }) and even.issubset({ 'L', 'U', 'D' }):
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int A[200005],n,k,sum,B[200005],m,ans;
int cmp(int i,int j) {return i<j;}
int main()
{
	scanf("%d%d",&n,&k);
	for (int i=1; i<=n; i++ )scanf("%d",&A[i]);
	sort(A+1,A+n+1,cmp);
	for (int i=1; i<=n; i++)
	{
	  if (i!=1 && A[i]==A[i-1]) B[m]++; else {B[++m]=1;}
	}
	sort(B+1,B+m+1,cmp);
	for (int i=1; i<=m-k; i++) ans+=B[i];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include <stdexcept>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
typedef long long ll;
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int dx[]={1,0,-1,0,1,-1,-1,1};
const int dy[]={0,1,0,-1,1,1,-1,-1};
int ceil(int a,int b){
    return (a+b-1)/b;
}
int stoii(string s){ //stoi関数の代用//
    return atoi(s.c_str());
}
int main(void){
    int w,h,n;
    cin>>w>>h>>n;
    int x[n],y[n],a[n];
    rep(i,n){
        cin>>x[i]>>y[i]>>a[i];
    }
    int x1=0,y1=0,x2=w,y2=h;
    rep(i,n){
        if(a[i]==1){
            if(x1<x[i]) x1=x[i];
        }
        if(a[i]==2){
            if(x2>x[i]) x2=x[i];
        }
        if(a[i]==3){
            if(y1<y[i]) y1=y[i];
        }
        if(a[i]==4){
            if(y2>y[i]) y2=y[i];
        }
    }
    if(x1<x2 && y1<y2) cout<<(x2-x1)*(y2-y1)<<endl;
    else cout<<"0"<<endl;
    return 0;
}    
    

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;
int main(void)
{
    priority_queue<long long>q;
    long long i,n,num,x,limit,step=0;
    scanf("%lld",&n);limit=n-1;
    for(i=1;i<=n;++i)
    {
        scanf("%lld",&x);q.push(x);
    }
    while(q.top()>limit)
    {
        x=q.top();q.pop();
    	num=ceil((x-limit)/(n+1.00));
    	q.push(x-num*(n+1));
    	limit-=num;step+=num;
    }
    printf("%lld\n",step);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep_start(a,i,n) for(ll i=a;i<=n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define rev1(i,n) for(ll i=n;i>0;i--)
#define sort(x) sort(x.begin(),x.end())
#define reverse(x) reverse(x.begin(),x.end())
#define zero0(x,n) fill(x.begin(),x.begin()+n,0)
#define zero1(x,n) fill(x.begin(),x.begin()+n,1)
#define zero(x) fill(x.begin(),x.end(),0)
#define pb push_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int> >
#define vb vector<bool>
#define pii pair<int,int>
#define F first
#define S second
#define INF 1e9+7
typedef long long int ll;

void solve(){
    double l;
    cin>>l;
    double ans=pow(l/3,3);
    cout<<fixed<<ans;
}

signed main() {
    // your code goes here
    IOS
    ll t=1;
    //cin>>t;
    rep1(i,t){
        solve(); 
    }
}

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

//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3", "Ofast", "unroll-loops", "fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


#define int long long
#define endl '\n'

using namespace std;

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int i, n;
    cin >> n;
    vector < int > a(n);
    map < int, int > m;
    for (i = 0; i < n; i++){
        cin >> a[i];
        m[a[i]]++;
    }
    int ans = 0;
    for (auto cur : m){
        ans += (cur.second) * (cur.second - 1) / 2;
    }
    for (i = 0; i < n; i++){
        ans -= m[a[i]] * (m[a[i]] - 1) / 2;
        m[a[i]]--;
        ans += m[a[i]] * (m[a[i]] - 1) / 2;;
        cout << ans << endl;
        ans -= m[a[i]] * (m[a[i]] - 1) / 2;
        m[a[i]]++;
        ans += m[a[i]] * (m[a[i]] - 1) / 2;
    }
    return 0;
}


Measured memory_bytes: 11136
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  for(int i = 0; 4*i <= N; ++i){
    if((N-4*i)%7 == 0){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int H,W,A,B;cin>>H>>W>>A>>B;
    mat s(1010,vec(1010,0));
    for(int i=1;i<=B;i++){
        for(int j=1;j<=A;j++)
            s[i][j]=1;
    }
    for(int i=B+1;i<=H;i++){
        for(int j=A+1;j<=W;j++)
            s[i][j]=1;
    }
    for(int i=1;i<=H;i++){
        for(int j=1;j<W;j++)
            cout<<s[i][j];
        cout<<s[i][W]<<endl;
    }
    return 0;
}

Measured memory_bytes: 5248
N = int(input())
H = [int(i) for i in input().split()]
ar = [0]*N
count = 0
r = 0
ans = 0
for l in range(N):
  if r <= l:
    r = l
    count = 0
  while r+1 <= N-1 and H[r] >= H[r+1]:
    count += 1
    r += 1
  ar[l] = count
  ans = max(ans,count)
  count -= 1
print(ans)

Measured memory_bytes: 14228
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
ll A, B, C, D;

ll calc(ll n, ll x){
    ll a = n /C;
    ll b = n /D;
    ll c = n/x; 
    return n - (a+b-c);
}

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

    cin >> A >> B >> C >> D;
    ll tmp1 = C;
    ll tmp2 = D;
    ll r = tmp2 % tmp1;
    while(r!=0){
    tmp2 = tmp1;
    tmp1 = r;
    r = tmp2 % tmp1;
    }
    
    ll x = (C*D) / tmp1;
    ll ans = calc(B, x) - calc(A-1, x);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int p[n],q[n];
  int s,t=0,u=0;
  int d=1;
  for(int i=2;i<=n;i++){
    d=d*i;
  }
  int z=n;
  for(int i=0;i<n;i++){
    cin>>p[i];
    s=p[i];
    for(int j=0;j<i;j++){
      if(p[i]>p[j]){
        s--;
      }
    }
    t=t+s*(d/z);
    z=z*(n-i-1);
  }
  z=n;
  for(int i=0;i<n;i++){
    cin>>q[i];
    s=q[i];
    for(int j=0;j<i;j++){
      if(q[i]>q[j]){
        s--;
      }
    }
    u=u+s*(d/z);
    z=z*(n-i-1);
  }
  int aa;
  if(u-t<0){
    aa=u;
    u=t;
    t=aa;
  }
  cout << u-t;
}


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

#define mp make_pair
#define sz(x) (int)((x).size())
#define all(x) (x).begin(),(x).end()
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define eb emplace_back

typedef pair< int, int > pii;
typedef pair< long long, long long > pll;
typedef long long ll;
typedef unsigned long long ull;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< ll > vll;
typedef vector< vll > vvll;
typedef vector< pii > vpii;
typedef vector< vpii > vvpii;
typedef vector< pll > vpll;
typedef long double ld;
typedef vector< ld > vld;
typedef unsigned int uint;
 
template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    const bool operator<(const M& o) const {return v < o.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
 
using Mint = ModInt<(int)998244353>;
 
int main() { 
    #ifdef BLAT
        freopen("stdin", "r", stdin);
        freopen("stderr", "w", stderr);
    #endif
 
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(12);
    srand(time(NULL));

    int n;
    cin >> n;

    vi a(n);
    vi b(n);

    for(int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }

    sort(all(a));
    sort(all(b));

    if(n&1) { 
        cout << max(0, b[n/2] - a[n/2] + 1) << '\n';
    } else {
        cout << max(0, b[n/2]+b[n/2-1] - a[n/2] - a[n/2-1] + 1) << '\n';
    }
    return 0;
}

Measured memory_bytes: 4752
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m;
vvi a,b;

int main(){
	cin>>m>>n;
	a=vvi(n,vi(n));
	b=vvi(m,vi(m));
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin>>a[i][j];
	for(int i=0;i<m;i++) for(int j=0;j<m;j++) cin>>b[i][j];
	vvl c(n,vl(3));
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++) for(int k=0;k<m;k++) c[i][(j+k)%3]+=a[b[j][k]-1][i];
	}
	ll res=INF;
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) for(int k=0;k<n;k++) if(i!=j&&j!=k&&k!=i) res=min(res,c[i][0]+c[j][1]+c[k][2]);
	cout<<res<<endl;
}

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


int main() {
    int N; cin >> N;
    int odd_num;
    if (0 == N % 2) {
        odd_num = N / 2;
    } else {
        odd_num = N / 2 + 1;
    }
    cout << static_cast<float>(odd_num) / static_cast<float>(N) << endl;

    return 0;
}


Measured memory_bytes: 256
using System;

namespace abc139_2
{
    class Program
    {
        static void Main(string[] args)
        {
            // input
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);

            // output
            int ans = 0;
            bool flg = true;
            int tmp = b - a;

            if(b == 1)
            {
                ans = 0;
                flg = false;
            }

            if (flg)
            {
                if (tmp <= 0)
                {
                    ans = 1;
                    flg = false;
                }
                else
                {
                    ans++;
                }
            }

            while(flg)
            {
                tmp -= a - 1;
                if(tmp <= 0)
                {
                    ans++;
                    break;
                }
                ans++;
            }

            Console.WriteLine(ans.ToString());

        }
    }
}


Measured memory_bytes: 11092
const fs = require('fs')
const stdin = fs.readFileSync('/dev/stdin', 'utf8')

const [N_Q, S, ...l_r] = stdin.split('\n').filter(el=>el)

const [N, Q] = N_Q.split(' ').map(Number)
const [...lr] = l_r.map(el => el.split(' ').map(Number))

let count = 0
const a = S.split('').map((el, i, arr) => {
  if (el === 'C' && arr[i - 1] === 'A') {
    count++
  }
  return count
})

const res = lr.map(el => {
  const [l, r] = el
  return a[r - 1] - a[l - 1]
})

console.log(res.join('\n'))


Measured memory_bytes: 56652