akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE FlexibleContexts, OverloadedStrings #-}
import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Text.Printf
import Debug.Trace
import Data.List (sort)

f n = length $ takeWhile (\x -> x `mod` 2 == 0) $ iterate (`div`2) n

main = do
  [n] <- getInts
  let xs = sort $ take (n+1) $ iterate (\(x,y)->(f (y+1),y+1)) (0,0)
  print $ snd $ last xs
  
-- util
getInts :: IO [Int]
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine


Measured memory_bytes: 508
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
#define mp make_pair
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

ll gcd(ll a,ll b){
  if(a%b==0){
    return b;
  }
  else{
    return gcd(b,a%b);
  }
}

int main() {
  ll a,b,c;
  cin >> a >> b >> c;
  a=gcd(a,b);
  if(c%a==0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  string s, t; cin >> s >> t;
  int n = s.size(), m = t.size();
  VV<> dp; assign(dp, n + 1, m + 1, 0);
  for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) {
    if (s[i] == t[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
    else dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
  }
  auto rec = [&](const auto& rec, int i, int j) -> string {
    if (dp[i][j] == 0) return "";
    if (s[i - 1] == t[j - 1]) return rec(rec, i - 1, j - 1) + s[i - 1];
    if (dp[i][j] == dp[i][j - 1]) return rec(rec, i, j - 1);
    else {
      assert(dp[i][j] == dp[i - 1][j]);
      return rec(rec, i - 1, j);
    }
  };
  cout << rec(rec, n, m) << '\n';
}

Measured memory_bytes: 35968
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = (a), i_len = (b); i < b; ++i)

int main()
{
    string S;
    cin >> S;
    int A = (int)S.size();
    int Z = -1;
    REP(i, 0, S.size()) {
        if(S[i] == 'A') A = min(A, i);
        if(S[i] == 'Z') Z = max(Z, i);
    }
    cout << Z - A + 1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}


int main() {
    int a,b;
    cin >> a >> b;


    cout << a*b << ' ' << a+b+a+b << endl;
    return 0;
}
 
 



Measured memory_bytes: 3084
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
typedef pair<int,int> P;
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define rep(i, n) for (lint i = 0; i < (n); i++)
#define INF LLONG_MAX
#define all(x) (x).begin(),(x).end()
#define pb push_back
int main(){
    string s,t;
    cin>>s;
    cin>>t;
    bool flag=true;
    for(int i=0;i<s.size();i++){
        flag=true;
        for(int j=0;j<s.size();j++){
            int k=i+j;
            if(k>=s.size()){
                k-=s.size();
            }
            if(s[k]!=t[j]){
                flag=false;
                break;
            }
        }
        if(flag){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repp(i, l, r) for (long long i = (l); i < (r); i++)
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define per(i, n) for (long long i = (n); i >= 0; --i)
#define all(v) v.begin(), v.end()
const int INF = 1 << 30;  // int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
//ミョ(-ω- ?)
int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> table(h + 2, vector<char>(w + 2, '#'));
    ll cnt = 0;
    rep(i, h) {
        rep(j, w) {
            cin >> table[i + 1][j + 1];
            if (table[i + 1][j + 1] == '#') cnt++;
        }
    }
    static const int dx[] = {-1, 0, 0, 1};
    static const int dy[] = {0, -1, 1, 0};
    vector<vector<int>> seen(h + 2, vector<int>(w + 2, 0));
    queue<P> que;
    que.push(make_pair(1, 1));
    while (!que.empty()) {
        auto p = que.front();
        que.pop();
        int x, y;
        tie(x, y) = p;
        rep(i, 4) {
            if (seen[x + dx[i]][y + dy[i]] != 0) continue;
            if (table[x + dx[i]][y + dy[i]] == '#') continue;
            seen[x + dx[i]][y + dy[i]] = seen[x][y] + 1;
            que.push({x + dx[i], y + dy[i]});
        }
    }
    if (seen[h][w] == 0) cout << -1 << "\n";
    else cout << h * w - (seen[h][w] + 1) - cnt << "\n";
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
  int n;
  double a,b;
  cin>>n;
  if(n%2==0){
    if(n==1){
      cout<<1<<endl;
    }else{
      cout<<0.5<<endl;
    }
  }else{
    a=n/2+1;
    b=n;
    cout<<a/b<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int n,i,x,y,t;
    cin>>n;
    for (i=1;i<=n;i++)
    {
        cin>>t>>x>>y;
        if (x+y>t)
        {
            cout<<"No";
            return 0;
        }
        if ((x+y)%2!=t%2)
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  for (int i = 0; i < s.size() - 8; i++) putchar(s[i]);
  putchar('\n');
  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
h=list(map(int,input().split()))

tree=[[0] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())

  tree[a-1].append(h[b-1])
  tree[b-1].append(h[a-1])

cnt=0
for i in range(n):
  if h[i]>max(tree[i]):
    cnt+=1
print(cnt)

Measured memory_bytes: 26116
package main

import (
	"fmt"
	"unicode"
)

func main() {
	var s string
	fmt.Scan(&s)

	exec(rune(s[0]))
}

func exec(r rune) {
	if unicode.IsUpper(r) {
		fmt.Println("A")
	} else {
		fmt.Println("a")
	}
}


Measured memory_bytes: 1772
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
#define mod 1000000007LL

ll f[2010][2010],fac[4000010],inv[4000010],n,m;

inline ll rd()
{
	ll x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline ll ksm(ll x,ll y) { ll res=1;for (;y;y>>=1,x=x*x%mod) if (y&1) res=res*x%mod;return res; }

inline ll C(ll x,ll y)
{
	if (x<y) return 0;
	return fac[x]*inv[x-y]%mod*inv[y]%mod;
}

int main()
{
	n=rd();m=rd();
	if (m==1) { puts("1");return 0; }
	fac[0]=1LL;
	for (int i=1;i<=n*m;i++) fac[i]=fac[i-1]*i%mod;
	inv[n*m]=ksm(fac[n*m],mod-2);
	for (int i=n*m;i;i--) inv[i-1]=inv[i]*i%mod;
	f[0][0]=1LL;
	for (int i=1;i<=n;i++) for (int j=i;~j;j--)
	{
		f[i][j]=f[i][j+1];
		if (j) f[i][j]=(f[i][j]+f[i-1][j-1]*C(i*m-j-1,m-2))%mod;
	}
	printf("%lld\n",f[n][0]*fac[n]%mod);
	return 0;
}

Measured memory_bytes: 94208
a = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq

n = ni()
A = lma()
ans = 10**9
for i in range(-100,101):
    tmp=0
    for a1 in A:
        tmp+=(i-a1)**2
    ans = min(tmp,ans)
print(ans)


Measured memory_bytes: 9404
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int P[100001];
int C[100001];

int Find(int A) {
	if (P[A] == A) return A;
	else {
		P[A] = Find(P[A]);
		return P[A];
	}
}

ll Union(int A, int B) {
	int a = Find(A);
	int b = Find(B);
	if (a != b) {
		P[b] = a;
		C[a] += C[b];
	}
	return C[a];
}

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


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

	pair<int, int> E[100001];
	rep1(i, M) {
		int a, b;
		cin >> a >> b;
		E[i] = mp(a, b);
	}

	ll sum = 1ll * N * (N - 1) / 2;
	ll kotae[100001];
	kotae[M] = sum;

	rep1(i, N) {
		C[i] = 1;
		P[i] = i;
	}

	for (int i = M; i > 1; i--) {
		int A = E[i].first;
		int B = E[i].second;
		int ca = C[Find(A)];
		int cb = C[Find(B)];
		int cf = Union(A, B);
		if (cf != ca) {
			sum += 1ll * ca * (ca - 1) / 2;
			sum += 1ll * cb * (cb - 1) / 2;
			sum -= 1ll * cf * (cf - 1) / 2;
		}
		kotae[i - 1] = sum;
	}

	rep1(i, M) co(kotae[i]);
	
	Would you please return 0;
}

Measured memory_bytes: 3712
N,K,Q = map(int,input().split())
A = [int(input()) for i in range(Q)]
scores = [K-Q for i in range(N)]

for i in range(Q):
  scores[A[i]-1] += 1
  
for i in range(N):
  if scores[i] > 0:
    print("Yes")
  else:
    print("No")

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

int main()
{
    char c[6];
    scanf("%c%c%c\n", &c[0], &c[1], &c[2]);
    scanf("%c%c%c", &c[3], &c[4], &c[5]);
    if(c[0]==c[5] && c[1]==c[4] && c[2]==c[3])
        puts("YES");
    else
        puts("NO");
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        VI H(n); stack<int> S;
        FOR(i,1,n+1) { 
            cin >> H[i];
            if (S.empty() || (S.size() && H[i] >= H[S.top()]))
                S.push(i);
        }
        const int ans = S.size();
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    data = [input() for _ in range(n)]

    ok = True
    if len(set(data)) != n: ok = False
    for i in range(n-1):
        if data[i][-1] != data[i+1][0]:
            ok = False

    print("Yes" if ok else "No")

main()

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

int main() {
	string s; getline(cin, s);
	for (char c : s) {
		if (islower(c))printf("%c", toupper(c));
		else if (isupper(c))printf("%c", tolower(c));
		else cout << c;
	}
	cout << endl;
}

Measured memory_bytes: 3144
#include <iostream>

class Dice {
private:
    int n, s, w, e, t, b;
public:
    Dice(int u, int v, int w, int x, int y, int z);
    ~Dice() {};

    void north();
    void south();
    void west();
    void east();

    int get_top() { return this->t; };
};

Dice::Dice(int u, int v, int w, int x, int y, int z) {
    this->t = u;
    this->s = v;
    this->e = w;
    this->w = x;
    this->n = y;
    this->b = z;
}

void Dice::north() {
    int tmp = this->n;
    this->n = this->t;
    this->t = this->s;
    this->s = this->b;
    this->b = tmp;
}

void Dice::south() {
    int tmp = this->s;
    this->s = this->t;
    this->t = this->n;
    this->n = this->b;
    this->b = tmp;
}

void Dice::west() {
    int tmp = this->w;
    this->w = this->t;
    this->t = this->e;
    this->e = this->b;
    this->b = tmp;
}

void Dice::east() {
    int tmp = this->e;
    this->e = this->t;
    this->t = this->w;
    this->w = this->b;
    this->b = tmp;
}

int main() {
    int u, v, w, x, y, z;
    std::string s;
    std::cin >> u >> v >> w
             >> x >> y >> z
             >> s;
    Dice dice(u, v, w, x, y, z);
    for (int i=0; i<s.size(); ++i) {
        if (s[i] == 'N') {
            dice.north();
        } else if (s[i] == 'S') {
            dice.south();
        } else if (s[i] == 'W') {
            dice.west();
        } else {
            dice.east();
        }
    }
    std::cout << dice.get_top() << std::endl;
    return 0;
}



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

int main(){
  int N;
  string S;
  cin >> N >> S;
  int R[2] = {};
  for(auto& c : S){
    if(c == 'R') c = '0';
    else c = '1';
    ++R[c-'0'];
  }
  int ans = min(R[0],R[1]);
  int L[2] = {};
  for(auto c : S){
    --R[c-'0'];
    ++L[c-'0'];
    ans = min(ans,max(L[1],R[0]));
  }
  cout << ans << endl;
}


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

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

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

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;

    ans += (b - a) + 1;
  }

  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 256
n, a = gets.split.map(&:to_i)
x = gets.split.map {|e| e.to_i - a}

h = Hash.new(0)
h[0] = 1
x.each do |s|
    t = {}
    h.each {|k,v| t[k+s] = v}
    t.each {|k,v| h[k] += v}
end

p h[0] - 1

Measured memory_bytes: 14828
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main() {

	string str,str_l,str_r;
	cin >> str;

	for (int i = 0; i < str.length()/2; i++) {
		if (str[i] != str[str.length() - i - 1]) {
			cout << "No";
			return 0;
		}
	}
	str_l = str.substr(0, str.length() / 2);
	str_r = str.substr(str.length() / 2 + 1, str.length() / 2);
	for (int i = 0; i < str_l.length() / 2; i++) {
		if (str[i] != str[str_l.length() - i - 1]) {
			cout << "No";
			return 0;
		}
	}
	if (str_l != str_r) {
		cout << "No";
		return 0;
	}
	cout << "Yes";
	return 0;
	
}

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

int main(){
    int n, k;
    string s;
    cin >> n >> k >> s;
    s[k - 1] = s[k - 1] - 'A' + 'a';
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3536
X, N = list(map(int,input().split()))
P = list(map(int,input().split()))

Ps = sorted(P)

for z in range(0,101):
    if not(X-z in P):
        print(X-z)
        break
    if not(X+z in P):
        print(X+z)
        break
    

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = n; i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
int a[500005];
int main() {
	string s;
	cin >> s;
	int n = s.size();
	rep(i, n) {
		if (s[i] == '<') a[i+1] = max(a[i]+1, a[i+1]);
	}
	for (int i = n-1; i >= 0; i--)
	{
		if (s[i] == '>') a[i] = max(a[i], a[i+1]+1);
	}
	ll ans = 0;
	rep(i, n+1) ans += a[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2820
#include<iostream>
#include<string>
using namespace std;
int main() {
	int o, e, p;
	string odd, even, pas;
	cin >> odd >> even;
	o = odd.size();
	e = even.size();
	p = o + e;
	for (int x = 0; x < p ; x++) {
		if (x % 2 == 1) {
			cout << even[x / 2];
		}
		else {
			cout << odd[x / 2];
		}
	}
	cout << pas << endl;
	//cin >> o;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
long long int p[10000000];
long long int b,i,k=0;
long long int m=1000000000000000000;
unsigned long long mul=1;  

scanf("%lld",&b);

for(i=0;i<b;i++)
{
scanf("%lld\n",&p[i]);

}

for(i=0;i<b;i++)
{
if(p[i]==0)
{
k=1;
break;
}
if(mul<=m/p[i])
{
mul=mul*p[i];
}
else
k=2;
}
if(k==1)
{
printf("0\n");
}
else if(k==2)
{
printf("-1\n");
}
else if(k==0)
printf("%llu\n",mul);

return 0;
} 



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

int main(){

    while(1){
        int n; cin >> n;
        if(!n) break;
        vector<string> table(n, "");
        for(int i = 0; i < n; i++){
            cin >> table[i];
        }

        for(int i = 0; i < n; i++){
            for(int j = 0; j < table[i].size() - 1; j++){
                if(table[i][j] == '.' && table[i][j + 1] != '.'){
                    table[i][j] = '+';       
                    break;
                }
            }
        }


        for(int i = 0; i < n; i++){
            for(int j = 0; j < table[i].size(); j++){
                if(table[i][j] == '.'){

                    bool u = false, d = false;
                    for(int k = i - 1; k >= 0; k--){
                        if(table[k].size() <= j) break;
                        else if(table[k][j] == '+'){
                            u = true;
                            break;
                        }else if(table[k][j] != '.' && table[k][j] != '|'){
                            break;
                        }
                    }

                    for(int k = i + 1; k < n; k++){
                        if(table[k].size() <= j) break;
                        else if(table[k][j] == '+'){
                            d = true;
                            break;
                        }else if(table[k][j] != '.' && table[k][j] != '|'){
                            break;
                        }
                    }

                    if(u && d) table[i][j] = '|';
                    else table[i][j] = ' ';
                }
            }
        }

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

    return 0;
}


Measured memory_bytes: 3656
import java.util.Scanner;

/**
 * Created by paz on 17-3-18.
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        long sum = 0;
        for(int i = 1; ;i++) {
            sum += i;
            if(sum >= x) {
                System.out.println(i);
                break;
            }
        }
    }
}

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

int main() {
    int n;
    cin >> n;
    int x[n];
    int y[n];
    for(int i = 0; i < n; i++) {
       cin >> x[i]; 
       y[i] = x[i];
    }
    sort(x, x+n);
    int left = x[n/2 - 1];
    int right = x[n/2];
    for(int i = 0; i < n; i++) {
        if (y[i] <= left) {
            cout << right << endl;
        } else {
            cout << left << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3712
#include<stdio.h>

int main(){
  long ans = 0;
  int N,x;
  scanf("%d %d", &N, &x);
  int A[N];
  for(int i = 0;i < N;i++){
    scanf("%d",&A[i]);
  }
  for(int i = 0;i<N-1;i++){
    int sa = A[i]+A[i+1] - x;
    if(sa > 0){
      ans += sa;
      if(A[i+1]>=sa){
        A[i+1]-=sa;
      }else{
        A[i+1]=0;
      }
    }
  }
printf("%ld",ans);
}


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

using namespace std;

typedef long long int64;

int main()
{
  int N, A[2] = {}, P;

  cin >> N >> P;
  for(int i = 0; i < N; i++) {
    int X;
    cin >> X;
    ++A[X % 2];
  }

  int64 mat[55][55] = {{}};
  for(int i = 0; i < 52; i++) {
    for(int j = 0; j <= i; j++) {
      if((j == 0) || (j == i)) {
        mat[i][j] = 1;
      } else {
        mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j];
      }
    }
  }

  int64 ret = 0;
  for(int i = 0; i <= A[0]; i++) {
    for(int j = 0; j <= A[1]; j++) {
      int mod = (i * 2 + j) % 2;
      if(mod == P) {
        ret += mat[A[0]][i] * mat[A[1]][j];
      }
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <map>
#include <set>
typedef long long int64;
static const int LOGN = 61;
static const int MODULUS = 1e9 + 7;
#define _  %  MODULUS
#define __ %= MODULUS

std::map<int64, int> mem;

// For clarity; this is not used
inline int calcx(int64 n)
{
    /*std::set<int64> s;
    for (int64 i = 0; i <= n / 2; ++i) s.insert(i ^ (n - i));
    return s.size();*/
    if (n <= 1) return 1;
    else return (n % 2 == 0 ? (calcx(n / 2 - 1) + calcx(n / 2))_ : calcx(n / 2));
}

inline int64 calc(int64 n)
{
    if (n == 0) return 1;
    else if (n == 1) return 2;
    int &ans = mem[n];
    if (!ans) ans = (calc(n / 2) + calc(n / 2 - 1) + calc(n / 2 - (1 - n % 2)))_;
    return ans;
}

int64 n;

int main()
{
    scanf("%lld", &n);
    printf("%lld\n", calc(n));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pw(x) (1LL << (x))
#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl

using namespace std;
typedef long long ll;
typedef double dbl;
const int INF = 1.01e9;

ll fast(vector<int> a) {
    int n = a.size();

    ll ans = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (i - a[i] < 0) return -1;
        if (i < n - 1 && a[i] + 1 == a[i + 1]) continue;
        ans += a[i];
        if (i < n - 1 && a[i] < a[i + 1] - 1) return -1;
    }

    return ans;
}

int main() {
#ifdef HOME
    assert(freopen("in", "r", stdin));
#endif

    int n;
    while (cin >> n) {
        vector<int> a(n);
        for (int i = 0; i < n; i++) scanf("%d", &a[i]);

        printf("%lld\n", fast(a));
    }

#ifdef HOME
    cerr << "time = " << (clock() * 1. / CLOCKS_PER_SEC) << "\n";
#endif
    return 0;
}


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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

ll N;
VL dp;

int main() {
    cin >> N;
    dp.assign(N + 1, LINF);
    dp[0] = 0;
    FOR(i, 1, N + 1) {
        for(ll j = 1; j <= i; j *= 6) {
            dp[i] = min(dp[i], dp[i - j] + 1);
        }
        for(ll j = 1; j <= i; j *= 9) {
            dp[i] = min(dp[i], dp[i - j] + 1);
        }
    }
    cout << dp[N] << "\n";
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define fo(i,n) for(ll i=0;i<n;i++)
#define fok(i,k,n) for(ll i=k;i<n;i++)
#define ci(x) cin>>x
#define ci2(x,y) cin>>x>>y
#define co(x) cout<<x<<"\n"
#define co2(x,y) cout<<x<<" "<<y<<"\n"
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define deb1(x) cout<<#x<<" "<<x<<endl
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n"
#define deb3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n"
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;	
int gcd(int a, int b){ if(a==0) return b; return gcd(b%a, a);}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tc=1;
	//ci(tc);
	while(tc--){
		ll n;
		ci(n);
		vl h(n);
		fo(i,n){
			ci(h[i]);
		}	
		ll ans =0;	
		fok(i,1,n){
			if(h[i]<h[i-1]){
				ans+=(h[i-1]-h[i]);
				h[i] = h[i-1];
			}
		}
		co(ans);
	}
	return 0;
}


Measured memory_bytes: 4764
#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>;

const int N = 1e3+1;

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

vector<int> prime;

void enum_prime() {
  vector<bool> is_prime(N, true);
  for (int i = 2; i < N; ++i) {
    if (is_prime[i] == false) continue;
    prime.push_back(i);
    for (int j = 2 * i; j < N; j += i) is_prime[j] = false;
  }
  return;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> b(n);
  rep(i, n) b[i] = a[i];
  
  enum_prime();
  vector<bool> appear(prime.size(), false);
  map<int, int> mp; 
  bool p = true;

  rep(i, n) {
    rep(j, prime.size()) {
      if (b[i] % prime[j] == 0) {
        if (appear[j]) p = false;
        appear[j] = true;
        while (b[i] % prime[j] == 0) b[i] /= prime[j];
      }
    }
    if (b[i] > 1) {
      if (mp[b[i]]) p = false;
      mp[b[i]] = 1;
    }
  }

  int g = a[0];
  for (int i = 1; i < n; ++i) g = gcd(g, a[i]);

  if (p) cout << "pairwise coprime" << endl;
  else if (g == 1) cout << "setwise coprime" << endl;
  else cout << "not coprime" << endl;
  return 0;
}

Measured memory_bytes: 14776
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

using real = double;
static constexpr real EPS = 1e-10;
struct Point {
    real x, y;
    Point& operator+=(const Point a) { x += a.x; y += a.y;  return *this; }
    Point& operator-=(const Point a) { x -= a.x; y -= a.y;  return *this; }
    Point& operator*=(const real k) { x *= k; y *= k;  return *this; }
    Point& operator/=(const real k) { x /= k; y /= k;  return *this; }
    Point operator+(const Point a) const {return Point(*this) += a; }
    Point operator-(const Point a) const {return Point(*this) -= a; }
    Point operator*(const real k) const {return Point(*this) *= k; }
    Point operator/(const real k) const {return Point(*this) /= k; }
    bool operator<(const Point &a) const { return (x != a.x ? x < a.x : y < a.y); }
    explicit Point(real a = 0, real b = 0) : x(a), y(b) {};
};

istream& operator>> (istream& s, Point& P){
    s >> P.x >> P.y;
    return s;
}
inline real dot(Point a, Point b){ return a.x*b.x + a.y*b.y; }

int main() {
    Point A, B, C, D;
    while(cin >> A >> B >> C >> D){
        puts(abs(dot(B-A, D-C)) < EPS ? "YES" : "NO");
    }
    return 0;
}


Measured memory_bytes: 3008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll max_N = 1e5 + 50, INF = 1e15, MOD = 1e9 + 7;
ll happiness[max_N][3], N;
ll DP[max_N][3];
// 0 for swimming, 1 for catching bugs and 2 for homework

int main()
{
    cin >> N;
    for (int i = 0; i < N; ++i)
        for (int j = 0; j < 3; ++j)
            cin >> happiness[i][j];
    for (int j = 0; j < 3; ++j)
        DP[0][j] = happiness[0][j];
    for (int i = 1; i < N; ++i)
    {
        for (int j = 0; j < 3; ++j)
        {
            DP[i][j] = -INF;
            for (int k = 0; k < 3; ++k)
            {
                if (j == k)
                    continue;
                DP[i][j] = max(DP[i][j], happiness[i][j] + DP[i - 1][k]);
            }
        }
    }
    cout << max(DP[N - 1][0], max(DP[N - 1][1], DP[N - 1][2])) << "\n";
    return 0;
}

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

char s[105];
vector <int> pos[26];

int main(){
	int n, ans, maxx;
	scanf("%s", s + 1);
	n = strlen(s + 1);
	for (int i = 0; i < 26; i++) pos[i].push_back(0);
	for (int i = 1; i <= n; i++) pos[s[i] - 'a'].push_back(i);
	for (int i = 0; i < 26; i++) pos[i].push_back(n + 1);
	ans = 1e9;
	for (int i = 0; i < 26; i++){
		maxx = 0;
		for (int j = 1; j < (int)pos[i].size(); j++)
			maxx = max(maxx, pos[i][j] - pos[i][j - 1] - 1);
		ans = min(ans, maxx);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;
 
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)
 
typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;
 
constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
 
int main() {
    string S; cin>>S;
    int ans = 0;
    REP(i,S.size()-2) {
        int tmp = stoi(S.substr(i,3));
        cerr << tmp << endl;
        if (abs(753-tmp)<abs(753-ans)) {
            ans = tmp;
        }
    }
    cout<<abs(ans-753)<<endl;
}


Measured memory_bytes: 256
#ABC129-C
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n,m=IL()
D=[True]*n
for i in range(m):
    D[I()-1]=False
A=[0]*n
if n==1:
    if D[0]:
        print(1)
    else:
        print(0)

else:
    if D[0]:
        A[0]=1
        if D[1]:
            A[1]=2
        else:
            A[1]=0
    else:
        A[0]=0
        if D[1]:
            A[1]=1
        else:
            A[1]=0
    for i in range(2,n):
        if D[i]:
            A[i]=A[i-1]+A[i-2]
        else:
            A[i]=0
    print(A[n-1]%1000000007)

Measured memory_bytes: 470648
N = int(input())
H = list(map(int,input().split()))
flag = 0
hmax = H[0]
for i in range(N):
    if H[i]<hmax-1:
        flag = 1
        break
    hmax = max(hmax,H[i])
if flag==1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 20664
a = gets.split
x = []
while k = a.shift
    l = x.length
    case k
    when "+" then
        x[l-2] = x[l-2] + x[l-1]
        x.pop
    when "-" then
        x[l-2] = x[l-2] - x[l-1]
        x.pop
    when "*" then
        x[l-2] = x[l-2] * x[l-1]
        x.pop
    else
        x.push(k.to_i)
    end
end

puts x


Measured memory_bytes: 6868
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

// rep(i, 100) { cout << i << endl; } => 0 1 2 ... 99
#define rep(i, n) for(int i = 0, i##_len = (n); i < (int)n; i++)

// std::sort(all(v));
#define all(x) (x).begin(), (x).end()

// long long int
using ll = long long;

// utility to cast return value of size function to int
#define SZ(x) ((int)(x).size())

// VS defines "_DEBUG" macro when debug configuration.
#if _DEBUG
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define dump(x)
#define debug(x)
#endif

// update max
template<class T>bool chmax(T & prov, const T & cur)
{
	if (cur > prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

// update min
template<class T>bool chmin(T & prov, const T & cur)
{
	if (cur < prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

int main()
{
	int N;
	cin >> N;
	string ans = "No";
	for (int i = 1; i <= 9; i++)
	{
		for (int j = 1; j <= 9; j++)
		{
			if (i * j == N)
			{
				ans = "Yes";
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main() {

    long long n,a,b;
    cin >> n >> a >> b;

    long long dv = n / (a + b);

    long long ans = dv * a;
    
    long long md = n % (a + b);
    if(md >= a) ans += a;
    else ans += md;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  long long a,b,k;
  scanf("%lld%lld%lld",&a,&b,&k);
  if((a-k)==0){
    printf("0 %lld",b);
    return 0;
  }else if((a-k)>0){
    printf("%lld %lld",a-k,b);
    return 0;
  }else{
    if((b-(k-a))>0){
      printf("0 %lld",(b-(k-a)));
      return 0;
    }else{
      printf("0 0");
    }
  }
}


Measured memory_bytes: 128
S = input()
N = len(S)
S1 = S[0:(N-1)//2]
S2 = S[(N+3)//2-1]

if (S == S[::-1]) and (S1 == S1[::-1]) and (S2 == S2[::-1]):
    
    print('Yes')
else:
    print('No')


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

void printbin(int x, int b = 5) {
    for (int i = b; i >= 0; i--) {
        cout << (x >> i & 1);
    }
    cout << endl;
}

vector<int> make(int x) {
    vector<int> ret;
    for (int i = 0; i < 1 << x; i++) {
        ret.push_back(i ^ (i >> 1));
    }
    for (int i = 30; i >= 0; i--) {
        if (ret.back() >> i & 1) {
            for (int j = 0; j < 1 << x; j++) {
                int a = ret[j] >> i & 1;
                int b = ret[j] & 1;
                int x = a ^ b;
                x = (x << i) | x;
                ret[j] ^= x;
            }
            break;
        }
    }
    return ret;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    if (__builtin_parity(a) == __builtin_parity(b)) {
        cout << "No" << endl; 
        return 0;
    }
    cout << "Yes" << endl;
    int c = __builtin_popcount(a ^ b);
    vector<int> ret;
    int x = 0;
    for (int i = 0; i < c; i++) {
        vector<int> tmp = make(n - 1 - i);
        if (i & 1) {
            reverse(tmp.begin(), tmp.end());
        }
        for (int a : tmp) {
            ret.push_back(x | a);
        }
        x |= 1 << (n - 1 - i);
    }
    vector<int> tmp = make(n - c);
    reverse(tmp.begin(), tmp.end());
    for (int a : tmp) {
        ret.push_back(x | a);
    }
    if (ret.size() != (1 << n)) {
        cerr << "ret size: " << ret.size() << " , while expected: " << (1 << n) << endl;
        assert(0);
    }

    vector<int> zeros, ones;
    for (int i = n - 1; i >= 0; i--) {
        if ((a ^ b) >> i & 1) {
            ones.push_back(n - 1 - i);
        } else {
            zeros.push_back(n - 1 - i);
        }
    }
    vector<int> order;
    for (int a : ones) {
        order.push_back(a);
    }
    for (int a : zeros) {
        order.push_back(a);
    }
    function<int(int x)> convert = [&](int x) {
        vector<pair<int, int>> tmp;
        for (int i = n - 1; i >= 0; i--) {
            if (x >> i & 1) {
                tmp.emplace_back(order[n - 1 - i], 1);
            } else {
                tmp.emplace_back(order[n - 1 - i], 0);
            }
        }
        sort(tmp.begin(), tmp.end());
        int ret = 0;
        for (int i = 0; i < n; i++) {
            ret |= (tmp[i].second) << (n - 1 - i);
        }
        return ret;
    };
    vector<int> ans;
    for (int a : ret) {
        ans.push_back(convert(a));
    }
    for (int t : ans) {
        cout << (t ^ a) << ' ';
    }
}

Measured memory_bytes: 2172
import sys

input = sys.stdin.readline


def main():
    R, G, B, N = map(int, input().split())

    ans = 0
    for r in range(N // R + 1):
        gGbB = N - r * R
        for g in range(gGbB // G + 1):
            bB = gGbB - g * G
            if bB % B == 0:
                ans += 1
    
    print(ans)


if __name__ == "__main__":
    main()


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

#define ls (t<<1)
#define rs ((t<<1)|1)
#define mid ((l+r)>>1)

#define mk make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;

int i,j,m,n,p,k;

int main()
{
	scanf("%d%d",&n,&m);
	if (n%3==0||m%3==0) printf("0\n");
	else 
	{
			long long ans=min(n,m);
			for (i=1;i<=n;++i)	
			{
					long long A=1ll*i*m,B=1ll*(n-i)*(m/2),C=1ll*(n-i)*((m+1)/2);
					ans=min(ans,max(A,max(B,C))-min(A,min(B,C))); 
			}
			for (i=1;i<=m;++i)
			{
					long long A=1ll*i*n,B=1ll*(m-i)*(n/2),C=1ll*(m-i)*((n+1)/2);
					ans=min(ans,max(A,max(B,C))-min(A,min(B,C)));
			}
			cout<<ans<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<int> A(N);
    REP(i, 0, N) cin >> A[i];

    unordered_map<int, int> M;
    REP(i, 0, N) M[A[i]]++;

    ll total = 0;
    for (auto m : M) {
        total += (ll)m.second * (m.second - 1) / 2;
    }

    REP(i, 0, N) {
        if (M[A[i]] > 0) {
            cout << total - M[A[i]] + 1 << endl;
        } else {
            cout << total << endl;
        }
    }
    return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define sz(v) (int)v.size()
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " is " << x << "\n";

using ll = long long;
using ii = pair<int,int>;

vector<ii> v;

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  int n; cin >> n;
  for(int i = 0; i < n; i++) {
    int x, y; cin >> x >> y;
    v.push_back({x + y, x - y});
  }
  sort(all(v));
  int ans = v.back().fi - v[0].fi;
  for(int i = 0; i < n; i++) swap(v[i].fi, v[i].se);
  sort(all(v));
  ans = max(ans, v.back().fi - v[0].fi);
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 5268
def c():
    n = int(input())
    hs = list(map(int, input().split()))

    if n <= 1:
        print(0)
        return

    max_count, count = 0, 0
    for i in range(1, n):
        if hs[i] <= hs[i-1]:
            count += 1
        else:
            max_count = max(max_count, count)
            count = 0

    max_count = max(max_count, count)
    print(max_count)


if __name__ == '__main__':
    c()


Measured memory_bytes: 63984
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    string tmp[3];
    tmp[0] = s.substr(0,4);
    tmp[1] = s.substr(5,2);
    tmp[2] = s.substr(8,2);
    int num[3];
    for (int i=0;i<3;i++){
        num[i] = atoi(tmp[i].c_str());
    }
    if(num[0] > 2019){
        printf("TBD\n");
        return 0;
    }else if(num[1] > 4){
        printf("TBD\n");
        return 0;
    }
    printf("Heisei\n");
}

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

using Graph = vector<vector<int>>;
// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

const int MOD = 1000000007;
using mint = Fp<MOD>;

// 木上の探索
vector<int> depth;
vector<int> subtree_size;
vector<mint> n_black;
vector<mint> n_white;

void dfs(const Graph &G, int v, int p, int d) {
    depth[v] = d;
    for (auto nv : G[v]) {
        if (nv == p) continue; // nv が親 p だったらダメ
        dfs(G, nv, v, d+1);
    }

    // 帰りがけ時に、部分木サイズを求める
    subtree_size[v] = 1; // 自分自身
    n_black[v] = 1;
    n_white[v] = 1;
    for (auto c : G[v]) {
        if (c == p) continue;
        subtree_size[v] += subtree_size[c]; // 子のサイズを加える
        n_black[v] = n_black[v] * n_white[c];
        n_white[v] = n_white[v] * (n_black[c] + n_white[c]);
    }
}

int main() {
    // 頂点数 (木なので辺数は N-1 で確定)
    int N; 
    cin >> N;

    // グラフ入力受取
    Graph G(N);
    for (int i = 0; i < N-1; ++i) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // 探索
    int root = 0; // 仮に頂点 0 を根とする
    depth.assign(N, 0);
    subtree_size.assign(N, 0);
    n_black.assign(N, -1);
    n_white.assign(N, -1);
    
    dfs(G, root, -1, 0);

    // 結果
    cout << n_white[0] + n_black[0] << endl;
}


Measured memory_bytes: 16384
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func main() {
	n, m := readInt(), readInt()
	if n == m {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 640
n = int(input())
h_list = list(map(int, input().split()))

counter = 0
for i in range(100):
    count_flag = False
    for index, h in enumerate(h_list):
        if h > 0:
            count_flag = True
            h_list[index] = h - 1
        if (h == 0 or index == len(h_list) - 1) and count_flag:
            counter += 1
            count_flag = False

print(counter)

Measured memory_bytes: 3060
"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let N = cin.getInt()
    let X = cin.getIntArray(N).map((v, i) => { return { value: v, index: i } });
    X.sort((a, b) => a.value - b.value);
    let P = new Array(N);
    for (let n = 0; n < N; n++) {
        P[X[n].index] = n;
    }
    let c = N / 2;
    for (let n = 0; n < N; n++) {
        let i = P[n] >= c ? c - 1 : c;
        console.log(X[i].value);
    }
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 69520