akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
int main(void)
{
  cout << fixed << setprecision(10) << endl;
  for(;;){
    int r,n;
    cin >> r >> n;
    if(!r) return 0;
    map<int,int> a,b;
    REP(i,n){
      int xl,xr,h;
      cin >> xl >> xr >> h;
      FOR(j,xl,xr){
	a[j]=max(a[j],h);
	b[j+1]=max(b[j+1],h);
      }
    }
    double answer=1000.0;
    answer=min(answer,r+1.0*a[-r]);
    FOR(i,-r+1,r) answer=min(answer,r-sqrt(r*r-i*i)+min(a[i],b[i]));
    answer=min(answer,r+1.0*b[r]);
    cout << answer << endl;
  }
}

Measured memory_bytes: 3200
/*
Dont BLUNDER
*/
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize ("-ffloat-store")
#pragma GCC optimization ("unroll-loops")
//for n2 loops
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;


 */
//#define d long double
#define int long long
#define pii pair<int,int>
#define pb push_back
#define endl '\n'
#define pi acos(-1)

#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
int const mod = 998244353;
int const mod1 = 1000000007;
#define l first
#define r second
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// * Using PBDS *
/*typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
               os; */



int modexp(int x, int n) {
	if (n == 0) {
		return 1;
	}
	else if (n & 1) {
		return (modexp((x * x) % mod, n / 2) % mod * x % mod) % mod;
	}
	else {
		return (modexp((x * x) % mod, n / 2) % mod);
	}
}

int modinv(int n)
{
	return modexp(n, mod - 2);
}

int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}
bool comp(pii a, pii b) {
	return a.second < b.second;

}
struct hash_pair {

	size_t operator()(const pair<int, int>& p) const
	{

		return ((  p.second ^ p.first) << 32);
	}
};



signed main()
{
	haha

	int x, k, d;
	cin >> x >> k >> d;

	int ans1;
	x=abs(x);


	
		int m1 = x / d;
		if(m1>k){
			cout<<x-k*d;
			return 0;
		}
		int x1 = x - m1 * d;
		if (m1 % 2 == k % 2) {
			cout << abs(x1);
		}
		else {
			
				int x2 = x1 - d;
				cout << abs(x2);
			
		}


	

















}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n, m, t, a[200005];
vector< ll > adj[100005];
#define ari for( int i = 0 ; i < n ; i++ ) cin >> a[i];
#define ginp for( int i = 0 ; i < m ; i++ ){ int u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u);}

int main(){
	// cin >> t;
	// t = 1;
	// while( t-- ){
		cin >> n;
		ari;
		ll u = 0;
		for(int i = 0 ; i < n ; i++)
			u = u ^ a[i];
		for(int i = 0 ; i < n ; i++)
			cout << (u ^ a[i]) << " ";
		cout << endl;
	// }
	return(0);
}

Measured memory_bytes: 7316
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <limits>
#include <numeric>

using ld = long double;
using ll = long long int;
using ul = unsigned long long int;

namespace lamlib
{
	/* constant */
	constexpr double epsilon = std::numeric_limits<double>::epsilon();

	/* math */
	template<class T> inline T abs(const T &a){ return (a>0) ? a : -a; }
	ul inline digit(const ul &num){ return static_cast<ul>(std::log10(num+epsilon))+1; }

	/* algorithm */
	ul gcd(const ul &a,const ul &b) { return (!b) ? a : gcd(b,a%b); }
	ul lcm(const ul &a,const ul &b) { return (a/gcd(a,b))*b; } // a/gcd(a,b)*b <=> (a*b)/gcd(a,b)
	std::vector<bool> eratosthenes(const ul &n)
	{
		std::vector<bool> prime_candidate(n,true);
		prime_candidate[0] = prime_candidate[1] = false;
		for(ul i = 2;i*i < n;++i)
		{
			if(!prime_candidate[i]) continue;
			for(ul j = 2;i*j < n;++j) prime_candidate[i*j] = false;
		}
		return prime_candidate;
	}
	ll rho_method(const ll &n)
	{
		auto f = [&](const ll &xi){ return (xi*xi+1)%n; };
		ll x = 2, y = 2, d = 1;
		while(d == 1)
		{
			x = f(x);
			y = f(f(y));
			d = lamlib::gcd(lamlib::abs(x-y),n);
		}
		return d;
	}
	// 素因数分解(試し割)
	std::vector<ll> prime_factorization_trial(const ll &n)
	{
		ll num = n;
		std::vector<ll> prime;
		for(ll i = 2;i*i <= n;++i)
		{
			while((num%i) == 0)
			{
				prime.emplace_back(i);
				num /= i;
			}
		}
		if(num > 1) prime.emplace_back(num);
		return prime;
	}

	/* string */
	inline ul same_char_count(const std::string s,const char &ch){ return std::count(std::cbegin(s),std::cend(s),ch); }
}

// std::cout << std::fixed << std::setprecision(15) << std::endl;

int main(int argc,char *argv[])
{
	int x,y;
	std::cin >> x >> y;

	for(int i = 0;i <= x;++i)
	{
		int tmp = i*2 + (x-i)*4;
		if(tmp == y)
		{
			std::cout << "Yes" << std::endl;
			return 0;
		}
	}

	std::cout << "No" << std::endl;

	return 0;
}

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

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

  ll N = S.length(), M = T.length();
  vector<vector<ll>> dp(N + 1, vector<ll>(M + 1, 0));
  vector<vector<ll>> pi(N + 1, vector<ll>(M + 1, -1));
  vector<vector<ll>> pj(N + 1, vector<ll>(M + 1, -1));

  REP(i, 0, N) {
    REP(j, 0, M) {
      dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j]);
      if (dp[i + 1][j + 1] == dp[i + 1][j]) {
        pi[i + 1][j + 1] = i + 1;
        pj[i + 1][j + 1] = j;
      }

      dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1]);
      if (dp[i + 1][j + 1] == dp[i][j + 1]) {
        pi[i + 1][j + 1] = i;
        pj[i + 1][j + 1] = j + 1;
      }

      dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + (S[i] == T[j] ? 1 : 0));
      if (dp[i + 1][j + 1] == dp[i][j] + (S[i] == T[j] ? 1 : 0)) {
        pi[i + 1][j + 1] = i;
        pj[i + 1][j + 1] = j;
      }
    }
  }

  string ans = "";
  for (ll i = N, j = M;;) {
    ll ii = pi[i][j], jj = pj[i][j];
    if (ii == -1 && jj == -1) break;
    if (dp[ii][jj] != dp[i][j]) {
      ans = S[ii] + ans;
    }
    i = ii;
    j = jj;
  }
  cout << ans << endl;
}

Measured memory_bytes: 211712
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <utility>
#include <set>
#include <queue>

typedef long long ll;
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

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



#define MOD 1000000007
#define PI 3.14159265359

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

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

ll mypow(ll a, ll b) {
    a %= MOD;
    ll res = 1;
    while (b > 0) {
        if (b % 2 == 1)res = res * a % MOD;
        a = a * a % MOD;
        b /= 2;
    }
    return res;
}


using Graph = vector<vector<int>>;

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = v;
            que.push(nv);
        }
    }

    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    cout << "Yes" << endl;
    for (int v = 1; v < N; ++v) cout  << dist[v] + 1<< endl;
}

//int main(){
//    int n, m;
//    cin >> n >> m;
//    vector<vector<int>> ind(n+1, vector<int>());
//
//
//    rep(i, m) {
//        int at, bt; cin >> at >> bt;
//        ind[at].push_back[bt];
//        ind[bt].push_back[at];
//    }
//
//    queue<int> q;
//    q.push(1);
//    vector<int> res(n + 1, -1);
//    res[1] = 1;
//    while (q.empty) {
//        int now = q.front();
//        q.pop();
//        if (res[now] != -1) {
//            for(i:)
//        }
//    }
//}




Measured memory_bytes: 10172
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    char op;
    for(int i=0;i<=100;i++){
    cin>>a>>op>>b;
    if(op=='+'){
        cout<< a+b <<endl;
    }else if(op=='-'){
        cout<< a-b <<endl;
    }else if(op=='*'){
        cout<< a*b <<endl;
    }else if(op=='/'){
        cout<< a/b <<endl;
    }else if(op=='?'){
        break;
    }
    }
}


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

int main() {
    int N;
    string S;
    cin >> N >> S;
    if(N%2==0 && S.substr(0,N/2) == S.substr(N/2,N/2))
        cout << "Yes";
    else
        cout << "No";
    cout << endl;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  
  if(n==1 || n==0){
    cout<<n<<endl;
    return 0;
  }
  bool first=true;
  ll ma;
  vll ans(100);
  while(n!=0){
    if(n>0){
      ll now=1, sum=1, pos=0;
      while(sum<n) now*=4, sum+=now, pos+=2;
      ans[pos]=1;
      n-=now;
      if(first){
        first=false;
        ma=pos;
      }
    }else{
      ll now=-2, sum=-2, pos=1;
      while(sum>n) now*=4, sum+=now, pos+=2;
      ans[pos]=1;
      n-=now;
      if(first){
        first=false;
        ma=pos;
      }
    }
    // cout<<n<<endl;
  }
  
  rrep(i,ma+1){
    cout<<ans[i];
  }
  cout<<endl;
  
}

Measured memory_bytes: 3620
N, A, B, C, D=map(int, input().split())
S='#'+input()

def f(x, y, s):
  tmp=[0]*(N+1)
  tmp[x]=1
  if s[x+1]=='.':
    tmp[x+1]=1
  i=x+2
  while i<=y:
    if s[i]=='.' and (tmp[i-2]==1 or tmp[i-1]==1):
      tmp[i]=1
    i+=1
  if tmp[y]>0:
    out=True
  else:
    out=False
    
  return out

if C<D:
  if f(A, C, S)==True and f(B, D, S)==True:
    print('Yes')
  else:
    print('No')
  exit()

def g(x, y, s):
  out=False
  for i in range(x, y+1):
    if s[i-1:i+2]=='...':
      out=True
  return out
  
if f(A, C, S)==True and f(B, D, S)==True and g(B, D, S)==True:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 5004
a = []
for i in range(3):
    x,y = map(int,input().split())
    a.append(x)
    a.append(y)

odd = 0
for i in range(1,5):
    x = a.count(i)
    if x % 2 == 1:
        odd += 1
if odd <= 2:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_set>
using namespace std;
typedef long long ll;

int main(){
  int N;
  cin >> N;
  unordered_set<int> data_set;
  int a;
  for(int i = 0; i < N; i++){
    cin >> a;
    auto it = data_set.find(a);
    if(it == data_set.end()){
      data_set.insert(a); 
    } else {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  
  return 0;
}


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

int main()
{
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        if((a+b)==(c+d))
                cout<<"Balanced"<<endl;
        if((a+b)>(c+d))
                cout<<"Left"<<endl;
        if((a+b)<(c+d))
                cout<<"Right"<<endl;
        return 0;
}


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

#define int long long
const int INF = 1e15;
typedef pair<int, int> P;

struct Edge {
	int to, cost;
};

int n;
vector<Edge> G[801];
int ss;

int dfs(int v, int p) {
	//if ( ss == 3 ) cout << v << " " << p << endl;
	bool flg = false;
	for ( Edge e : G[v] ) {
		int to = e.to, cost = e.cost;		
		if ( to == p ) continue;
		if ( G[to].size() >= 2 ) flg = true;
	}

	if ( !flg ) return 0;
	
	int ret = 0;	
	for ( Edge e : G[v] ) {
		int to = e.to, cost = e.cost;
		if ( to == p ) continue;
		if ( G[to].size() == 1 ) continue;
		ret += dfs(to, v)+cost;		
	}

	return ret;
}

int calc(int s) {
	ss = s;
	int ret = 0;
	int ma = 0;
	for ( Edge e : G[s] ) {
		int to = e.to, cost = e.cost;
		if ( G[to].size() == 1 ) continue;
		int tmp = dfs(to, s)+cost;
		//if ( s == 7 ) cout << tmp << endl;
		ma = max(ma, tmp);
		ret += tmp*2;
	}

	queue<P> q;
	vector<int> d(n, -1);
	q.push(P(s, 0));
	while ( !q.empty() ) {
		P p = q.front(); q.pop();
		int v = p.first, c = p.second;

		if ( d[v] >= 0 ) continue;
		if ( G[v].size() == 1 ) continue;

		d[v] = c;

		for ( Edge e : G[v] ) {
			int to = e.to, cost = e.cost;
			if ( G[to].size() == 1 ) continue;
			q.push(P(to, c+cost));
		}
	}

	ma = 0;
	for ( int i = 0; i < n; i++ ) ma = max(ma, d[i]);

	//if ( s == 3 ) cout << ma << endl;

	return ret-ma;
}

signed main() {
	
	while ( cin >> n, n ) {
		for ( int i = 0; i < 801; i++ ) G[i].clear();
		int sum = 0;

		{		
			vector<int> p(n);
			for ( int i = 0; i < n-1; i++ ) cin >> p[i], p[i]--;
			for ( int i = 1; i < n; i++ ) {
				int d;
				cin >> d;
				sum += d;
				G[i].push_back(Edge{p[i-1], d});
				G[p[i-1]].push_back(Edge{i, d});
			}
		}

		//for ( int i = 0; i < n; i++ ) cout << G[i].size() << endl;

		int ans = INF;
		int id = 0;
		for ( int i = 0; i < n; i++ ) {
			//if ( ans > calc(i) ) id = i;
			ans = min(ans, calc(i));
		}

		//cout << id << endl;
		cout << ans+sum << endl;
	}	
	return 0;
}



Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
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 n;

int main() {
    cin >> n;
    vector< vector<int> > Amap(n, vector<int>(n-1, 0));
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n-1; ++j) {
            cin >> Amap[i][j];
            Amap[i][j]--;
        }
        reverse(Amap[i].begin(), Amap[i].end());
    }

    vector<P> q;
    auto check = [&](int i) {
        if(Amap[i].size() == 0) return;
        int j = Amap[i].back();     // 対戦相手
        if(Amap[j].size() == 0) return;
        if(Amap[j].back() == i) {
            // 相手の次の対戦相手が自分だった時
            P p(i, j);
            if(p.second < p.first) swap(p.first, p.second);
            q.push_back(p);
        }
    };

    // それぞれの1回戦の相手を突っ込んでみる
    for(int i = 0; i < n; ++i) {
        check(i);
    }

    int day = 0;
    while(q.size() > 0) {
        day++;
        vector<P> prevQ;    // prevQは最初は空でqと入れ替える
        sort(q.begin(), q.end());
        q.erase(unique(q.begin(), q.end()), q.end());   // ユニークな試合だけ残す
        swap(prevQ, q);
        for(auto p : prevQ) {
            // この試合は行われたので消す
            int i = p.first, j = p.second;
            Amap[i].pop_back();
            Amap[j].pop_back();
        }
        for(auto p : prevQ) {
            // 次の試合を確認する
            int i = p.first, j = p.second;
            check(i);
            check(j);
        }
    }
    // 全試合消化できていればクリア
    for(int i = 0; i < n; ++i) {
        if(Amap[i].size() != 0) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << day << endl;
}

Measured memory_bytes: 7592
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,flag=0;
    cin>>n;
    for(i=1; i<=9; i++)
    {
       for(int j=1;j<=9;j++){
        if(i*j==n){
            flag=1;break;
        }
       }


        /*if(n%i<=9&&(n/i)<=9)
        {
            flag=1;
            break;
        }*/
    }
    if(flag)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;







    return 0;
}


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

using namespace std;

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

int gcd(int x, int y){
    if(y == 0) return x;
    return gcd(y, x % y);    
}

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    int ans = a[0];
    rep(i, n - 1) ans = gcd(ans, a[i+1]);
    cout << ans << endl;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

struct UnionFindTree{
	vector<int>par,sz;
	UnionFindTree(int n){
		par.resize(n);
		sz.resize(n);
		for(int i=0;i<n;i++){
			par[i]=i;
			sz[i]=1;
		}
	}
	int find(int x){
		return x==par[x]?x:par[x]=find(par[x]);
	}
	void unite(int x,int y){
		x=find(x);y=find(y);
		if(x==y)return;
		if(sz[x]<sz[y])swap(x,y);
		sz[x]+=sz[y];
		par[y]=x;
	}
	bool areSame(int x,int y){
		return find(x)==find(y);
	}
	int size(int x){
		return sz[find(x)];
	}
};

int N;
int G[222][222];
int dist[222][222];

signed main(){
	cin>>N;
	rep(i,N){
		string s;cin>>s;
		rep(j,N){
			G[i][j]=s[j]=='1';
		}
	}
	UnionFindTree uf(2*N);
	rep(i,N)rep(j,N)if(G[i][j]){
		uf.unite(i*2,j*2+1);
		uf.unite(i*2+1,j*2);
	}

	rep(i,N)if(uf.areSame(i*2,i*2+1)){
		cout<<-1<<endl;
		return 0;
	}
	const int INF=1001001001;
	fill_n(*dist,222*222,INF);
	rep(i,N)dist[i][i]=0;
	rep(i,N)rep(j,N)if(G[i][j])dist[i][j]=1;
	rep(k,N)rep(i,N)rep(j,N)chmin(dist[i][j],dist[i][k]+dist[k][j]);

	int ma=0;
	rep(i,N)rep(j,N)chmax(ma,dist[i][j]);
	cout<<ma+1<<endl;
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i< (int)(n); i++)
#define rep2(i,x,n) for(int i = (int)x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	vector<string> a(n);
	vector<string> b(m);
	rep(i, n) cin >> a.at(i);
	rep(i, m) cin >> b.at(i);

	rep(i, n-m+1){
		rep(j, n-m+1){
			bool flag = true;
			rep(k1, m){
				int l1 = i+k1;
				rep(k2, m){
					int l2 = j + k2;
					if(a.at(l1)[l2] != b.at(k1)[k2]){
						flag = false;
						break;
					}
				}
				if(flag == false) break;
			}
			if(flag == true){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;

	return 0;
}

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

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ll long long
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000000000
const ll mod=1e9+7;

void dfs(int s, vector<bool>&vis, vector<int>&top, vector<int>adj[])
{
	if(vis[s]) return;
	vis[s]=true;
	for(auto u:adj[s]) dfs(u,vis,top,adj);
	top.push_back(s);
}

int main()
{
	int nT; nT=1; //cin>>nT;
	while(nT--)
	{
		int n,m; cin>>n>>m;
		vector<int>adj[n+1];
		rep(i,m)
		{
			int x,y; cin>>x>>y;
			adj[x].push_back(y);
		} 
		vector<bool>vis(n+1,false);
		vector<int>top(n+1);
		rep(i,n+1)
		{
			if(!vis[i]) dfs(i,vis,top,adj);
		}
		reverse(top.begin(), top.end());
		vector<int>dp(n+1,0);
		rep(i,n+1) for(auto u:adj[top[i]]) dp[u]=max(dp[u],1+dp[top[i]]);
		cout<<*max_element(dp.begin(), dp.end());
	}
	return 0;
}


Measured memory_bytes: 9592
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int q;
    cin >> q;
    while (q--) {
        int b, e, k;
        cin >> b >> e >> k;
        int res = 0;
        for (int i = b; i < e; ++i) {
            if (a[i] == k) res++;
        }
        cout << res << endl;
    }
}



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

int main(){
  int n,hmax,ans=0,h;cin>>n>>hmax;h=hmax;
  vector<int> a(n,0),b(n,0);
  REP(i,n) cin>>a.at(i)>>b.at(i);
  sort(a.begin(),a.end(),greater<int>());
  sort(b.begin(),b.end(),greater<int>());

  REP(i,n){
    if(a.at(0)<b.at(i)){
      h-=b.at(i);
      ans++;
      if(h<=0) break;
    }
  }
  if(h>0) ans+=(h+a.at(0)-1)/a.at(0);
  //ans=min(ans,(hmax+a.at(0)-1)/a.at(0));  

  cout<<ans;
}

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

using namespace std;

int main() {
  int n, a[100], tmp, cnt = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = n - 1; i > 0; i--) {  
    for (int j = n - 1; j > 0; j--) {
      if (a[j] < a[j - 1]) {
        tmp = a[j - 1];
        a[j - 1] = a[j];
        a[j] = tmp;
        cnt++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    i == n - 1 ? printf("%d\n", a[i]) : printf("%d ", a[i]);
  }
  printf("%d\n", cnt);
  return 0;
}



Measured memory_bytes: 3228
import sys

INF = 2**31 - 1


class RUQ:

    def __init__(self, n):
        tmp = 1
        while tmp < n:
            tmp *= 2
        self.n = tmp * 2
        self.A = [INF] * (2 * self.n - 1)

    def update(self, a, b, x=-1, k=0, l=0, r=0):
        if r <= a or b <= l:
            return
        if a <= l and r <= b:
            if x >= 0:
                self.A[k] = x
            return
        if self.A[k] != INF:
            self.A[k*2+1] = self.A[k*2+2] = self.A[k]
        self.A[k] = INF
        self.update(a, b, x, k*2+1, l, (l+r)/2)
        self.update(a, b, x, k*2+2, (l+r)/2, r)


line = sys.stdin.readline()
n, q = map(int, line.split())
ruq = RUQ(n)
for i in range(q):
    line = sys.stdin.readline()
    if line[0] == "0":
        com, s, t, x = map(int, line.split())
        ruq.update(s, t+1, x, 0, 0, ruq.n)
    else:
        com, i = map(int, line.split())
        ruq.update(i, i+1, -1, 0, 0, ruq.n)
        print(ruq.A[i+ruq.n-1])



Measured memory_bytes: 11060
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>

using namespace std;
typedef long long ll;
ll N;

int main(){

    ll N, K;
    cin >> N >> K;

    ll ans = 0;

    if(K % 2 == 0){
        ans = pow(N / K, 3);
        //K/2余る数
        ll t = 0;
        for(ll i = 1; i <= N; i++){
            if(i % K == K / 2){
                t++;
            }
        }
        ans += pow(t, 3);

        cout << ans << endl;

    }else{
        ans = pow(N / K, 3);
        cout << ans << endl;
    }

} 

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

int n;
vector<int> g[111111];
vector<int> vs;
int dep[111111],par[22][111111];

void dfs(int v,int pre,int d){
  dep[v]=d;
  par[0][v]=pre;
  for(int nv: g[v]){
    if(nv!=pre){
      dfs(nv,v,d+1);
    }
  }
}

int lca(int u,int v){
  if(dep[u]>dep[v])swap(u,v);
  rep(k,20){
    if((dep[v]-dep[u])>>k&1){
      v=par[k][v];
    }
  }
  if(u==v)return v;
  for(int k=20-1;k>=0;k--){
    if(par[k][u]!=par[k][v]){
      u=par[k][u]; v=par[k][v];
    }
  }
  return par[0][u];
}

int main(){
	cin.sync_with_stdio(false);
  cin>>n;
  rep(i,n-1){
    int par;
    cin>>par; par--;
    g[par].push_back(i+1); g[i+1].push_back(par);
  }

  dfs(0,-1,0);
  for(int k=0;k+1<20;k++){
    for(int v=0;v<n;v++){
      if(par[k][v]<0)par[k+1][v]=-1;
      else par[k+1][v]=par[k][par[k][v]];
    }
  }

  queue<int> que;
  que.push(0);
  while(que.size()){
    int v=que.front(); que.pop();
    vs.push_back(v);
    for(int nv : g[v]){
      if(dep[nv]>dep[v])que.push(nv);
    }
  }

  ll res=0;
  rep(i,vs.size()-1){
    int u=vs[i],v=vs[i+1];
    res+=dep[u]+dep[v]-dep[lca(u,v)]*2;
  }
  cout<<res<<endl;
	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    ll n, a, b;
    cin >> n >> a >> b;
    cout << n / (a + b) * a + min(a, n % (a + b)) << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#define INF 2147483647
#define lli long long int

using namespace std;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;

void printv(vi v){
	for(int i = 0; i < v.size(); i++){
		cout << v[i] << " ";
		}cout << endl;
		return ;
		}

bool check(vi list,int a){
	for (int i = 0; i < list.size(); i++){
		if (list[i] == a){
			return true;
		}
	}
	return false;
}

void vecA(vi &A,int a){
		int keta = 10;
		int tmp = a;
		for (int i = 0; i < A.size(); i++){
			A[i] = (tmp  % keta) / (keta / 10);
			tmp -= tmp % keta;
			keta *= 10;
		}
		return ;
	
}
int main() {
	while(1){
	
		int a,l; cin >> a >> l;
		if (a + l == 0) break;
		vi A(l);
		vi list(20,INF);

		vecA(A,a);

		int index_i = 0;
		bool flag = true;
		int index_j = 0;
		while( flag ){ 
			vi max(l);
			max = A;
			sort(max.begin(),max.end());
			//printv(max);

			vi min(l);
			min = A;
			sort(min.begin(),min.end());
			reverse(min.begin(),min.end());
			//printv(min);
			int keta = 1;
			int max_a = 0;
			int min_a = 0;
			list[index_i] = a;

			for (int i = 0; i < l; i++){
				max_a += max[i] * keta;
				min_a += min[i] * keta;
				a = max_a - min_a;
				keta *= 10;
			}
			//	cout << max_a << " " << min_a << endl;
			vecA(A,a);
			index_i++;
			for (int i = 0; i < list.size(); i++){
				if (list[i] == a){
					flag = false;
					index_j = i;
					break;
				}
			}
		}
		cout << index_j << " " << a << " " << index_i - index_j << endl;




	}
	
	
	return 0;

}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount _builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace __gnu_pbds;
using namespace std;
//typedef
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
//constants
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
// gcd of a and b
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
// distance between (a,b) and (c,d)
long double dis(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
// simple prime check
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
// fast expo
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
// modular inverse
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	assert(_gcd==1);
	return mpow(a,mod-2,mod);
}

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*
ll dx[]={1,0,-1,0,1,1,-1,-1};
ll dy[]={0,-1,0,1,1,-1,-1,1};
*/

/*
void sieve(int N){
	for(int i=0;i<=N;i++){
		spf[i]=i;
	}
	for(int i=2;i*i<=N;i++){
		if(spf[i]==i){
			for(int j=i*i;j<=N;j+=i){
				spf[j]=min(spf[j],i);
			}
		}
	}
	return;
}
*/

/*
void nCr(ll n,ll k){
	ll i,j;
	for(i=0;i<=n;i++){
		for(j=0;j<=min(i,k);j++){

			if(j==0 or j==i)C[i][j]=1LL;
			else  C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

		}
	}
	return;
}
*/
/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll h,w,H,W;

int main(){FAST;
cin>>H>>W>>h>>w;
ll ans=H*W - (h*W + (H-h)*w);
cout<<ans;
return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int size = Integer.parseInt(s.nextLine());
		int heap[] = new int[size];
		String inputString[] = s.nextLine().split(" ");
		for (int i = 0; i < size; i++) {
			heap[i] = Integer.parseInt(inputString[i]);
		
		}
		System.out.println("node 1: key = "+heap[0]+", left key = "+heap[1]+", right key = "+heap[2]+ ", ");
		for (int i =1; i < size; i++) {
			System.out.print("node " + (i+1) +":"+ " key = "+heap[i]+", parent key = " + heap[(i-1)/2]+", ");
			if (i*2+1 <= (size-1)) {
			System.out.print("left key = " +heap[i*2+1]+", " );
			}
			if(2*i+2 <=(size-1)) {
			System.out.print("right key = " + heap[2*i+2]+", ");
			}
			System.out.println();
	}

}
}


Measured memory_bytes: 26796
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<queue>
#define ll long long
#define inf 0x3f3f3f3f
#define maxn 1000010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static int buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10;
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
int a[maxn],b[maxn];
int n,m,k;
int main()
{
	n=read(); m=read(); k=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	for(int i=1;i<=m;i++)
		b[i]=read();
	int mn1=inf,mn2=inf;
	for(int i=1;i<=n;i++)
		mn1=std::min(mn1,a[i]);
	for(int i=1;i<=m;i++)
		mn2=std::min(mn2,b[i]);
	int ans=mn1+mn2;
	for(int i=1;i<=k;i++){
		int x=read(),y=read(),z=read();
		ans=std::min(ans,a[x]+b[y]-z);
	}
	writeln(ans);
	return 0;
}

Measured memory_bytes: 4608
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		long a = sc.nextLong();
		long b = sc.nextLong();
		int c = sc.nextInt();
		int d = sc.nextInt();
		long cd = lcm(c, d);
		long cnum, dnum, cdnum, ans;
		cnum = b / c - (a - 1) / c;
		dnum = b / d - (a - 1) / d;
		cdnum = b / cd - (a - 1) / cd;
		ans = b - a + 1 - cnum - dnum + cdnum;
		System.out.println(ans);
	}

	private static long gcd(long m, long n) {
		if (m < n)
			return gcd(n, m);
		if (n == 0)
			return m;
		return gcd(n, m % n);
	}

	private static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
const int mxN=1e3+10;
int n,m,a,b,k;
int vis[mxN],pai[mxN];
vector<int>adj[mxN];
vector<int>resp;

void bfs(int x){
    queue<int>fila;
    fila.push(x);
    vis[x]=1;

    while(!fila.empty()){
        int u=fila.front();
        fila.pop();
        for(int v:adj[u])   {
            if(!vis[v]){
                vis[v]=1;
                pai[v]=u;
                fila.push(v);

            }
            if(v==x){
                vector<int>ans;
                while(u!=v){
                    ans.push_back(u);
                    u=pai[u];
                }
                ans.push_back(v);
                if(resp.size()==0 || ans.size()< resp.size())resp=ans;
                return;
            }
        }

    }
}

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

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

    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            pai[j]=-1;
            vis[j]=0;            
        }
        bfs(i);       
    }
    if(resp.size()){
        cout<<resp.size()<<"\n";
        for(auto x:resp){
            cout<<x<<"\n";
        }
        return 0;
    }
    cout<<-1<<"\n";

     

}

Measured memory_bytes: 384
import java.util.*;

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

    while(true){
      int n = sc.nextInt();
      if(n == 0) break;

      int maxScore = 0;
      int minScore = Integer.MAX_VALUE;

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

        for(int j = 0; j < 5; j++){
          int score = sc.nextInt();
          sumScore += score;
        }

        maxScore = Math.max(maxScore, sumScore);
        minScore = Math.min(minScore, sumScore);
      }

      System.out.println(maxScore + " " + minScore);
    }
  }
}

Measured memory_bytes: 12000
#include <stdio.h>
#define MAX 10

int main(void){
	int B[MAX];
	int C[MAX];
	int bc,cc;/*counter*/
	int n,i,j;
	int ball;
	int possible;
	scanf("%d",&n);
	for(i = 0; i < n; i++){
		for(j = 0; j < 10; j++){
			B[j] = 0;
			C[j] = 0;
		}
		bc = 0;
		cc = 0;
		possible = 1;
		for(j = 0; j < 10; j++){
			scanf("%d",&ball);
			if(possible){
				if(bc == 0){
					B[bc] = ball;
					bc++;
				}else if(B[bc-1] < ball){
					B[bc] = ball;
					bc++;
				}else if(cc == 0){
					C[cc] = ball;
					cc++;
				}else if(C[cc-1] < ball){
					C[cc] = ball;
					cc++;
				}else{
					possible = 0;
				}
			}
		}
		puts(possible?"YES":"NO");
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
constexpr int MOD = 1000000007;
constexpr int INF = 1e18;

using namespace std;


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

  vector<int> H(N);
  int cnt = 0, ans = 0;
  REP(i, N){
    cin >> H[i];
    if(i == 0) continue;
    if(H[i-1] >= H[i]) cnt++;
    else cnt = 0;
    ans = max(ans, cnt);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define all(a) a.begin(),a.end()
#define ull unsigned long long
#define endl '\n'
#define y1 yaumru
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define iter vector<int>::iterator
#define int long long
using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

template<class T>
using ordered_multiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rnd1(chrono::steady_clock::now().time_since_epoch().count());

//find_by_order
//order_of_key

const int N=5e5+7;
const int inf=1e9+5;
const int mod=1e9+7;
const ld eps=1e-9;

int pref[N];
int suf[N];

main ()
{
    ios;
    string s;
    cin>>s;
    int n=s.size();
    s='#'+s;
    for (int i=1;i<=n+1;++i){
        if (s[i]=='<'){
            pref[i]=1;
            pref[i]+=pref[i-1];
        }
        else {
            pref[i]=0;
        }
    }
    for (int i=n+1;i>=1;--i){
        if (s[i]=='>'){
            suf[i]=1;
            suf[i]+=suf[i+1];
        }
        else {
            suf[i]=0;
        }
    }
    int ans=0;
    for (int i=1;i<=n+1;++i){
        int c=max(pref[i-1],suf[i]);
        ans+=c;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 8752
#include <stdio.h>
int main()
{
    int H, W, i, j, n;
    while(1){
        scanf("%d %d", &H, &W);
        if(H==0 && W==0){
            break;
        } else {
            for(i=0; i<H; i++){
                for(j=0; j<W; j++){
                    printf("#");
                    }
                printf("\n");
                }
                printf("\n");
            }
    }
    return 0;
}


Measured memory_bytes: 2124
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1

using namespace std;

class Point
{
private:
  int m_x;
  int m_y;
public:
  void setX(int x);
  void setY(int y);
  int getX();
  int getY();

  Point(int x, int y) {
    setX(x);
    setY(y);
  }
};

void Point::setX(int x) {
  m_x = x;
}

void Point::setY(int y) {
  m_y = y;
}

int Point::getX() {
  return m_x;
}

int Point::getY() {
  return m_y;
}

int main() {
  int n, w, h, x, y, s, t, l_s, u_s, count, max;
  while (cin >> n, n) {
    cin >> w >> h;
    vector<Point> persimmon;
    while (n--) {
      cin >> x >> y;
      persimmon.push_back(Point(x, y));
    }
    cin >> s >> t;
    max = 0;
    for (l_s = 1; l_s+s <= w+1; l_s++) {
      for (u_s = 1; u_s+t <= h+1; u_s++) {
        count = 0;
        for (int i = 0; i < persimmon.size(); i++) {
          if (l_s <= persimmon[i].getX() && persimmon[i].getX() < l_s+s && u_s <= persimmon[i].getY() && persimmon[i].getY() < u_s+t)
            count++;
        }
        if (max < count) max = count;
      }
    }
    cout << max << el;
  }
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>
#include <math.h>

#define nl '\n'

using namespace std;

long long a, b, k, t;

int main(){

    cin >> a >> b >> k;

    t = a;

    a = a - min(a, k);
    k = k - min(t, k);

    b = b - min(b, k);

    cout << a << " " << b;
    









}

//g++ -std=c++14 comp.cpp -o b; ./b.exe

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
 
    int main(){
      string S;
      cin >> S;
      bool flag1=false;
      bool flag2=false;
      bool flag3=false;
      if(S[0]=='A'){
        flag1=true;
      }
      int count=0;
      for(int i=2;i<S.size()-1;i++){
        if(S[i]=='C'){
       count++;
        }
      }
      if(count==1){
       flag2=true; 
      }
      int count2=0;
      for(int i=0;i<S.size();i++){
        for(char j='a';j<='z';j++){
       if(S[i]==j) count2++; 
        }
      }
      if(count2==S.size()-2){
       flag3=true;
      }
      if(flag1==true && flag2==true && flag3==true){
       cout << "AC" << endl; 
      }
      else{
       cout << "WA" << endl; 
      }
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    long long n, m;
    while(cin >> n >> m, n){
        vector<long> in(n+1,0),sum;
        for(int i = 0; i < n; i++) cin >> in[i];
        n++;
        for(int i = 0; i < n; i++) for(int j = i; j < n; j++){
            sum.push_back(in[i]+in[j]);
        }
        sort(sum.begin(),sum.end());
        long long ans = 0;
        for(int i = 0; i < sum.size(); i++){
            int t = upper_bound(sum.begin(),sum.end(),m-sum[i])-sum.begin();
            t--;
            long long score = sum[i] + sum[t];
            if(score > m)continue;
            ans = max(ans, score);
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 10728
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
a = []

for i in range(N):
  a.append(1/A[i])

print(1/sum(a))

Measured memory_bytes: 5192
from copy import copy
N = int(input())
P = list(map(float,input().split()))
dp = [0. for i in range(N+1)]
for i in range(N):
    if i == 0:
        dp[0] = 1. - P[i]
        dp[1] = P[i]
    else:
        new_dp = copy(dp)
        for j in range(N+1):
            if j == 0:
                new_dp[j] = dp[j]*(1-P[i])
            else:
                new_dp[j] = dp[j]*(1-P[i]) + dp[j-1]*(P[i])
        dp = copy(new_dp)
print(sum(dp[N//2+1:]))

Measured memory_bytes: 44508
n,a,b = gets.split.map(&:to_i)
s = gets.chomp
n.times do |i|
  if s[i] == "a" && a+b > 0
    puts "Yes"
    a -= 1
  elsif s[i] == "b" && b > 0 && a+b > 0
    puts "Yes"
    b -= 1
  else
    puts "No"
  end
end

Measured memory_bytes: 2300
#include<stdio.h>
		int w,h,dx[]={0,0,1,-1},dy[]={1,-1,0,0},k;
		char s[100][100];
	void func(int y,int x){
		int i;
		s[y][x]='#';
		k++;
		for(i=0;i<4;i++)
			if(dy[i]+y>=0&&dy[i]+y<h&&dx[i]+x>=0&&dx[i]+x<w&&s[y+dy[i]][x+dx[i]]=='.')
				func(y+dy[i],x+dx[i]);
}
	int main(){
		int i,j,x,y;
		while(scanf("%d %d",&w,&h),w||h){
			k=0;
			for(i=0;i<h;i++)
				scanf("%s",s[i]);
			for(i=0;i<h;i++)
				for(j=0;j<w;j++)
					if(s[i][j]=='@'){
						x=j;
						y=i;
			}
			func(y,x);
			printf("%d\n",k);
		}
		return 0;
}

Measured memory_bytes: 0
// Problem : A - Plural Form
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀🌙｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、 
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 🚶ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/

// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	string str;
	cin>>str;
	cout<<str;
	if(str.back()=='s')
		cout<<"es";
	else
		cout<<'s';
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3668