akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

constexpr int INF = 0x3f3f3f3f;

int main() {
  int n;
  cin >> n;
  string s;
  vector<vector<int>> g(n, vector<int>(n, INF));
  rep(i, 0, n) {
    cin >> s;
    rep(j, 0, n) {
      if (s[j] == '1') g[i][j] = 1;
    }
    g[i][i] = 0;
  }

  vector<int> color(n);
  // vをcで塗れるか？
  auto dfs = [&](auto self, int v, int c) {
    color[v] = c;
    rep(nv, 0, n) {
      if (g[v][nv] == 1) {
        if (color[nv] == c) return false;
        if (color[nv] == 0 && !self(self, nv, -c)) return false;
      }
    }
    return true;
  };
  if (!dfs(dfs, 0, 1)) {
    cout << "-1";
    return 0;
  }

  rep(k, 0, n) rep(i, 0, n) rep(j, 0, n) g[i][j] =
    min(g[i][j], g[i][k] + g[k][j]);

  int ans = 0;
  rep(i, 0, n) rep(j, 0, n) ans = max(ans, g[i][j]);
  cout << ans + 1;
  return 0;
}


Measured memory_bytes: 3800
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <iomanip>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
double pi = 3.141592653589793;
ll mod = 1000000007;

int main() {
    int N;
    cin >> N;
    double t[N], v[N];
    for (int i = 0; i < N; i++) {
        cin >> t[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> v[i];
    }
    int slim[N + 1], elim[N + 1];
    slim[0] = 0;
    elim[N] = 0;
    for (int i = 0; i < N; i++) {
        slim[i + 1] = min(slim[i] + t[i], v[i]);
        elim[N - i - 1] = min(elim[N - i] + t[N - 1 - i], v[N - 1 - i]);
    }
    double ans = 0;
    for (int i = 0; i < N; i++) {
        int s = min(slim[i], elim[i]);
        int e = min(slim[i + 1], elim[i + 1]);
        double m = (t[i] - abs(s - e)) * 0.5 + max(s, e);
        if (m <= v[i]) {
            ans += 0.5 * (s + m) * (m - s) + 0.5 * (m + e) * (m - e);
        } else {
            ans += v[i] * t[i] * 1.0 - 0.5 * (v[i] - s) * (v[i] - s) - 0.5 * (v[i] - e) * (v[i] - e);
        }
    }
    cout << fixed;
    cout << setprecision(2) << ans << endl;
}



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

int main() {
  int a, b, c, x, cnt=0;
  cin >> a >> b >> c >> x;

  for (int i=0; i<=a; i++) {
    for (int j=0; j<=b; j++) {
      for (int k=0; k<=c; k++) {
        if (i*500+j*100+k*50==x) cnt++;
      }
    }
  }

  cout << cnt;
}
/*
  A=500, B=100, C=50
*/

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
	int x;
	cin >> x;
	if (x == 1) {
		cout << "0" << endl;
	}
	else if (x == 0) {
		cout << "1" << endl;
	}
}


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

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) 0
#endif
#define endl '\n'
#define pb push_back
#define mod 1000000007
typedef int integer;
#define int long long
using namespace std;

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const integer NN = (int) 5e5 + 2;
int ar[NN];
int b[NN];
int n, m, k, x;
string s;

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

    int x, y;
    cin >> x >> y;
    for (int i = 0; i <= x; i++){
        if (2 * i + 4 * (x-i) == y){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";

}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int x3, y3, x4, y4;
    x3 = y1 -y2 + x2;
    y3 = x2 - x1 + y2;
    x4 = x1 - y2 + y1;
    y4 = y1 + x2 - x1;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    string s;
    cin >> s;
    ll n = s.size();
    vll dist(n);
    REP(i, n){
        if(s[i] == 'L'){
            if(s[i - 1] == 'R') dist[i] = i - 1;
            else dist[i] = dist[i - 1];
        }
    }
    REPR(i, n){
        if(s[i] == 'R'){
            if(s[i + 1] == 'R') dist[i] = dist[i + 1];
            else dist[i] = i + 1;
        }
    }
    vll res(n);
    REP(i, n){
        ll cost = dist[i] - i;
        if(cost > 0){
            if(cost % 2) res[dist[i] - 1]++;
            else res[dist[i]]++;
        }
        else{
            if(cost % 2) res[dist[i] + 1]++;
            else res[dist[i]]++;
        }
    }
    REP(i, n) cout << res[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 2256
#include<stdio.h>
int main (void){
    int i,j,d,n[10],max,full[3];
    for(i=0;i<10;i++){
        scanf("%d",&n[i]);
    }
    for(i=0;i<3;i++){
            max = 0;
            for(j=0;j<10;j++){
        if(max<n[j]){
            max = n[j];
            full[i] = n[j];
            d = j;
        }

            }
            n[d] = 0;
    }
    printf("%d\n%d\n%d\n",full[0],full[1],full[2]);
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    cin>>a>>b;
    if(a==b)
     cout<<"Yes";
    else 
     cout<<"No";
    return 0;
}
     
   




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

#define LL long long
#define COIN const int
#define ite ::iterator
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define LEN(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/

using namespace std;

string s;
deque <char> q;
bool rev;
int a,b,t,i;
char c;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >>s; cin >>t;
	REP(i,s.size()) q.pb(s[i]); 
	REP(i,t)
	{
		cin >>a;
		if (a==1)
			rev^=1;
		else
		{
			cin >>b >>c;
			b--;
			if (b==(int)rev) q.pf(c);
			else q.pb(c);
		}
	}
	s="";
	REP(i,q.size())
		s+=q[i];
	if (rev) reverse(ALL(s));
	cout <<s;
	return 0;
}
/******************************************************************************
******************************************************************************/


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

int main() {
  int n;
  double ans = 0;
  cin >> n;
  for (int i = 0; i < n; ++i ) {
    double x;
    string u;
    cin >> x >> u;
    if (u == "JPY")
      ans += x;
    else
      ans += x * 380000;
  }
  cout << fixed << setprecision(10) << ans << endl;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DBG(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define DBG(...)
#endif

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, n) for (auto i : (n))
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  int N, R;
  cin >> N >> R;

  if (N < 10) R += 100 * (10 - N);
  cout << R << endl;
}


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

int main() {
  int H,W,i,j;  
  cin>>H>>W;
  string input;
  
  for(i=0;i<W+2;i++){
    cout<<"#";
  }
  cout<<endl;
  
    for(j=0;j<H;j++){
      cin>>input;
      cout<<"#"<<input<<"#"<<endl;
    }
   for(i=0;i<W+2;i++){
    cout<<"#";
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    ll a, b, x; cin >> a >> b >> x;
    ll ans = b/x - max((a-1),0ll)/x;
    if(a == 0) ans ++ ;

    cout << ans << endl;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    const int digit = 60;
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<int> binaryA[N];
    REP(i, N)
    {
        cin >> A[i];
        REP(j, digit)
        {
            if (((A[i] >> j) & 1) == 1) binaryA[i].push_back(1);
            else binaryA[i].push_back(0);
        }  
    }

    vector<ll> digitCount[N];
    REP(i, digit)
    {
        digitCount[0].push_back(binaryA[N - 1][i]);
    }
    for (ll i = N - 2; i >= 0; --i)
    {
        digitCount[N - 1 - i] = digitCount[N - 2 - i];
        REP(j, digit)
        {
            if (binaryA[i][j] == 1) digitCount[N - 1 - i][j]++;
        }
    }

    vector<ll> res(digit);
    res[0] = 1;
    for (int i = 1; i < digit; ++i) res[i] = (res[i - 1] * 2) % MOD;

    ll ans = 0;
    REP(i, N - 1)
    {
        REP(j, digit)
        {
            if (binaryA[i][j] == 1) ans += res[j] * (N - 1 - i - digitCount[N - 2 - i][j]);
            else ans += res[j] * digitCount[N - 2 - i][j];
            ans = ans % MOD;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 241664
while True:
    (H, W) = [int(i) for i in input().split()]
    if H == W == 0:
        break

    for a in range(H):
        for b in range(W):
            print('#', end='') if (a + b) % 2 == 0 else print('.', end='')
        print()
    print()

Measured memory_bytes: 6804
#include <stdio.h>
#include <algorithm>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x1f3f3f3f3f3f3f3f;
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)

const int MX = 200005;

int A[MX];

int main()
{
	int N;
	scanf("%d", &N);
	vector<int> L;
	for(int i = 1; i <= N; i++) scanf("%d", A+i), L.push_back(A[i]);
	sort(L.begin(), L.end());
	int med = L[N/2-1], nxt = L[N/2];

	for(int i = 1; i <= N; i++){
		if(med >= A[i]) printf("%d\n", nxt);
		else printf("%d\n", med);
	}
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
//#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};

int mod = 1000000007;
//int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N;
    scanf("%d", &N);

    bool s1, s2;

    char ans[10];
    printf("0\n");
    fflush(stdout);
    scanf("%s", &ans);
    if(ans[0] == 'V') return 0;
    else if(ans[0] == 'M') s1 = true;
    else s1 = false;
    printf("%d\n", N / 2);
    fflush(stdout);
    scanf("%s", &ans);
    if(ans[0] == 'V') return 0;
    else if(ans[0] == 'M') s2 = true;
    else s2 = false;

    int d = N / 2;
    int x1, x2;
    if((s1 == s2) ^ (d % 2 == 0)){
        x1 = 0, x2 = N / 2;
    }else{
        x1 = N / 2, x2 = N;
        swap(s1, s2);
    }

    REP(i, 18){
        int x = (x1 + x2) / 2;
        d = x - x1;
        printf("%d\n", x);
        fflush(stdout);
        scanf("%s", &ans);
        if(ans[0] == 'V') return 0;
        else if(ans[0] == 'M') s2 = true;
        else s2 = false;

        if((s1 == s2) ^ (d % 2 == 0)){
            x2 = x;
        }else{
            x1 = x;
            swap(s1, s2);
        }
    }

    return 0;
}


Measured memory_bytes: 852
x, n = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

ans = 999999
min = 999999
for i in -200..200
    d = (x - i).abs
    if min > d
        ok = true
        for j in 0...n
            ok = false if i == a[j]
        end
        if ok
            min = d
            ans = i
        end
    end
end

puts ans

Measured memory_bytes: 14292
#include<bits/stdc++.h>
using namespace std;
int main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	long m,n;
	cin>>n>>m;
	long ans =(n*(n-1))/2 + (m*(m-1))/2;
	cout<<ans;
	
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
int n, cnt, cnt2;
int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
	int x;
	scanf("%d", &x);
	if((x % 4 == 0)) cnt++;
	else if((x % 2 == 0)) cnt2++;
	else cnt--;
    }
    printf("%s", (cnt >= 0 || (cnt == -1 && cnt2 == 0))?"Yes\n":"No");
}


Measured memory_bytes: 128
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;


public class Main {
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
   long A = sc.nextLong();
   long B = sc.nextLong();
   long C = sc.nextLong();

   long count = 0;
   while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
     long nextA = (B + C) / 2;
     long nextB = (A + C) / 2;
     long nextC = (A + B) / 2;
     
     A = nextA;
     B = nextB;
     C = nextC;
     count ++;
     
     if (count > 10000) {
       count = -1;
       break;
     }
   }
   System.out.println(count);
  }

}


class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else if (buflen == 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int , int> P;
typedef pair<ll, ll> PL;
const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
 
int n,a,b;

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

    cout << min(a,b)  <<' ' <<  max(-(n-a-b),0) << endl;

}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


int main(){
    int R, G, B, N, cnt(0); cin >> R >> G >> B >> N;
    REPS(r, N){
        REPS(g, N){
            int b = (N - r*R - g*G) / B;
            if(b >= 0 && (r*R + g*G + b*B == N))
                ++cnt;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n,k; cin >> n >> k;
  int res=0;
 rep(i,n){
    int temp; cin >> temp;
    if(temp>=k) res++;
  }
 cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
t=int(input())
def gcd(x,y):
  if y==0:
    return x
  else:
    return gcd(y,x%y)
for i in range(t):
  a,b,c,d=map(int,input().split())
  if a<b:
    print("No")
  elif b>d:
    print("No")
  elif c>b:
    print("Yes")
  else:
    if b-gcd(b,d)+a%gcd(b,d)>c:
      print("No")
    else:
      print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long n,m; cin>>n>>m;
    if(n==1&&m==1) {cout<<1<<endl; return 0;}
    else if(n==1) {cout<<m-2<<endl; return 0;}
    else if(m==1) {cout<<n-2<<endl; return 0;}
    else{
        cout<<n*m - (n-1+n-1+m-1+m-1)<<endl;
    }
}


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

int main() {
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    a[i]--;
  }
  
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (i == a[a[i]]) ans++;
  }
  
  // 解答
  cout << ans / 2 << endl;
  
  return 0;
}

Measured memory_bytes: 640
s=input()
k=int(input())
l=len(s)
now=1
seq=[]
re=False
all=False
for i in range(l):
    if s[i%l]==s[(i+1)%l]:
        if i==l-1:
            re=True
            if len(seq)==0:
                all=True
            else:
                first=seq[0]//2
                end=now//2
                seq[0]=(seq[0]+now)
        now+=1
    else:
        seq.append(now)
        now=1
if all:
    ans=len(s)*k//2
else:
    seq=[i//2 for i in seq]
    if re:
        ans=sum(seq)*k-seq[0]+first+end
    else:
        ans=sum(seq)*k

print(ans)


Measured memory_bytes: 3064
def solve():
  import sys
  import math

  sys.setrecursionlimit(10**7)
  readline=sys.stdin.readline

  n = int(input())
  b = list(map(int, input().split()))
  
  a = b[0]
  for i in range(1,n-1):
    a += min(b[i],b[i-1])
  a += b[-1]

  print(a)


if __name__ == '__main__':
  solve()

Measured memory_bytes: 3060
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector< vector<int> >
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

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

    int Q;
    cin >> Q;
    int ans = 0;
    rep(i, Q){
        int t;
        cin >> t;
        S[N] = t;
        int j = 0;
        while(t != S[j]) j++;
        if(j != N) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3088
S = input()
Ls = [1, 10, 9, 12, 3, 4]  # 10^n % 13, n % 6でループ
C = 10 ** 9 + 7

L = len(S) - 1
mem = [[0 for _ in range(13)] for _ in range(len(S))]
if S[L] == '?':
    for m in range(10):
        mem[0][m] = 1
else:
    mem[0][int(S[L])] = 1

for i in range(1, len(S)):
    t = S[L - i]
    for m in range(13):
        if t == '?':
            s = 0
            for j in range(10):
                tm = m - ((Ls[i % 6] * j) % 13)
                if tm < 0:
                    tm += 13
                s += mem[i - 1][tm]
            mem[i][m] = s % C
        else:
            tm = m - ((Ls[i % 6] * int(t)) % 13)
            if tm < 0:
                tm += 13
            mem[i][m] = mem[i - 1][tm] % C
print(mem[len(S) - 1][5])

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    string a, b;
    cin >> a >> b;
    reverse(a.begin(), a.end());
    if(a==b) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

using namespace std;
int main() {
    string s;
    cin >> s;
    int len=0;
    regex re(R"([ACGT]+)");
    sregex_iterator iter(s.cbegin(), s.cend(), re);
    sregex_iterator end;
    for(;iter!=end;++iter) {
        string m = iter->str();
        if (m.length()>len) len = m.length();
    }
    cout << len << endl;
    return 0;
}

Measured memory_bytes: 384
from sys import stdin

N, M = [int(x) for x in stdin.readline().rstrip().split()]
drink = {}
for i in range(0, N):
    a, b = [int(x) for x in stdin.readline().rstrip().split()]
    if not a in drink:
        drink[a] = 0
    drink[a] += b

cost = 0
buy_drinks = 0
for price, num in sorted(drink.items()):
    if buy_drinks + num > M:
        cost += (M-buy_drinks) * price
        buy_drinks = M
        break
    else:
        cost += price * num
        buy_drinks += num

print(cost)

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

int n, k, x, y, mx, d1[4004][4004], d2[4004][4004];
char a[5];
int f2(int p, int q) {
	return d1[p][q];
}

int g2(int p, int q) {
	return d2[p][q];
}
//int f2(int p, int q) {
//	if (p < 0 || q < 0) return 0;
//	return d1[p][q];
//}
//int g2(int p, int q) {
//	if (p < 0 || q < 0) return 0;
//	return d2[p][q];
//}
//
int f(int p1, int q1){
	int p2, q2;
	p2 = p1 + k - 1;
	q2 = q1 + k - 1;
	return f2(p2, q2) -f2(p1 - 1, q2) - f2(p2, q1 - 1) + f2(p1 - 1, q1 - 1);
}

int g(int p1, int q1){
	int p2, q2;
	p2 = p1 + k - 1;
	q2 = q1 + k - 1;
	return g2(p2, q2) -g2(p1 - 1, q2) - g2(p2, q1 - 1) + g2(p1 - 1, q1 - 1);
}
int main()
{
	int i, j, r, c;
	cin >> n >> k;
	for (i = 0; i < n; i++) {
		scanf ("%d %d %s", &x, &y, a);
		r = x % (k * 2) + 1;
		c = y % (k * 2) + 1;
		if (a[0] == 'W') {
			d1[r][c]++;
			d1[r + k * 2][c]++;
			d1[r][c + k * 2]++;
			d1[r + k * 2][c + k * 2]++;
		} else {
			d2[r][c]++;
			d2[r + k * 2][c]++;
			d2[r][c + k * 2]++;
			d2[r + k * 2][c + k * 2]++;
		}
	}
	for (i = 1; i <= k * 4; i++) {
		for (j = 1; j <= k * 4; j++) {
			d1[i][j] += d1[i - 1][j] + d1[i][j - 1] - d1[i - 1][j - 1];
			d2[i][j] += d2[i - 1][j] + d2[i][j - 1] - d2[i - 1][j - 1];
		}
	}
	for (i = 1; i <= k * 2; i++) {
		for (j = 1; j <= k * 2; j++) {
//			mx = max(mx, f(i, j, i + k - 1, j + k - 1) + f(i + k, j + k, i + k * 2 - 1, j + k * 2 - 1) + g(i, j + k, i + k - 1, j + k * 2 - 1) + g(i + k, j, i + k * 2 - 1, j + k - 1));
			mx = max(mx, f(i, j) + f(i + k, j + k) + g(i, j + k) + g(i + k, j));
		}
	}
	cout << mx;
    return 0;
}


Measured memory_bytes: 125440
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def ii(): return int(stdin.readline())
def li(): return map(int, stdin.readline().split())
A, B = tuple(li())
if A >= 13:
    print(B)
elif A >= 6:
    print(B//2)
else:
    print(0)


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#define N 1000005
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int main() {
	int r,g,b;
	cin>>r>>g>>b;
	int res=r*100+10*g+b;
	if (res%4==0) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

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

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

	std::int64_t ans = 0;
	for (int i = 1; i <= n; ++i)
		if (i % 3 != 0 && i % 5 != 0)
			ans += i;

	std::cout << ans << std::endl;
}


Measured memory_bytes: 3160
N,K = list(map(int,input().split()))

V = list(map(int,input().split()))

# 左から試していく

left_dict = {0:0}

for i in range(K,0,-1):
    left_dict[i]=max([sum(sorted(V[:i-j])[j:]) for j in range(i//2+1)])

left_dict



V = list(reversed(V))

V

right_dict = {0:0}
for i in range(K,0,-1):
    right_dict[i]=max([sum(sorted(V[:i-j])[j:]) for j in range(i//2+1)])

right_dict

m = 0
for i in range(K+1):
    for j in range(K-i+1):
        if m < left_dict[i]+right_dict[j]:
            m = left_dict[i]+right_dict[j]

            
print(min(m,sum([v for v in V if v>0 ]) ))

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

struct ed{
    ed(int a, int b) : to(a) , co(b) {}
    int to;
    int co;
};

int main() {

    int N,M,P;
    Scd3(N,M,P);

    int a,b,c;

    vector< vector<ed> > e(N);
    vector< vector<ed> > eb(N);

    Rep(i,M){
        Scd3(a,b,c);
        a--,b--,c-=P;
        e[a].push_back(ed(b,c));
        eb[b].push_back(ed(a,c));
    }

    deque<int> d;
    vector<bool> isThrough(N,false);
    d.push_back(N-1);

    while( !d.empty() ){
        int from = d.front();
        // printf ("%d\n", from );
        d.pop_front();
        isThrough[from] = true;
        for( ed t : eb[from] ){
            int to = t.to;
            if( !isThrough[to] ){
                isThrough[to] = true;
                d.push_back(to);
            }
        }
    }

    vector<int> sc(N,-INF);
    vector<int> ac(N,0);
    sc[0] = 0;

    d.push_back(0);

    while( !d.empty() ){
        int from = d.front();
        d.pop_front();

        for( ed t : e[from] ){
            int to = t.to;
            int co = t.co;
            if( !isThrough[to] ) continue;
            if( sc[to] == -INF ){
                ac[to]++;
                if( ac[to] > 5003 ) {
                    sc[N-1] = INF;
                    break;
                }
                sc[to] = sc[from]+co;
                d.push_back(to);
            }else if( sc[to] < sc[from]+co ){
                ac[to]++;
                // printf ("%d\n", ac[to] );
                if( ac[to] > 5003 ) {
                    sc[N-1] = INF;
                    break;
                }
                sc[to] = sc[from]+co;
                d.push_back(to);
            }
        }
        if( sc[N-1] == INF ) break;
    }

    printf ("%d\n", sc[N-1] < 0 ? 0 : sc[N-1] == INF ? -1 : sc[N-1] );

    return 0;
}



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

using namespace std;
using LL = long long;

constexpr int MAXN = 2e5 + 5;

LL n, k, a[MAXN], grade(1), pre;

int main () {
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> a[i];
    int l = 1, r = k + 1;
    while (r <= n) {
        if (a[l] < a[r]) {
            cout << "Yes" << endl;
        } else cout << "No" << endl;
        l++, r++;
    }
    return 0;
}

Measured memory_bytes: 5212
#include <iostream>
#include <algorithm>
typedef long long ll;

using namespace std;

int main(void){
	ll n; cin >> n;
	ll ans = 0;
	while(1){
		if(n <= 1) break;
		if(n%3 != 0){
			n += (3 - (n%3));
		}
		n /= 3;
		ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3092
import java.util.*;

public class Main {

  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n=sc.nextInt();
	int x=0;
	String str=sc.next();
	Set<Integer>set=new HashSet<>();
	set.add(0);
	for(int i=0;i<n;i++){
		if(str.charAt(i)=='I'){
			x++;
			set.add(x);
		}
		else {
			x--;
			set.add(x);
		}
	}
	System.out.println(Collections.max(set));
	sc.close();
  }
}


Measured memory_bytes: 35788
N= int(input())
H=[int(x) for x in input().split()]
hantei = True
for i in range(2,N):#右から検証していく。
  if H[-i]-1 == H[-i+1]:#１引いて比較
    H[-i] -= 1
  elif H[-i]-1>H[-i+1]:
    hantei = False
print('Yes' if hantei else 'No')

Measured memory_bytes: 14396
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
const int MOD = 1000000009;
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long ans = LLONG_MAX;
  long long l, r;

  cin >> l >> r;

  for(long long i = l;i < r && ans != 0;i++){
    for(long long j = l + 1;j <= r && ans != 0;j++){
      ans = min(ans, (i * j) % 2019);
    }
  }
      
  cout << ans << endl;
  return 0;
}



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


Measured memory_bytes: 256
import math
import sys
import numpy as np
from collections import defaultdict, deque, Counter 
from itertools import accumulate, product, permutations,combinations, combinations_with_replacement
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd

max_value = 1000000000
min_value = -1000000000
sys.setrecursionlimit(max_value)


n = int(input())
a_list = list(map(int,input().split()))


b_list = [1./e for e in a_list]

b = np.sum(b_list)

print(1/b)


Measured memory_bytes: 13300
import java.util.*;

class Main{
  private static long answer = Long.MAX_VALUE;
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int all = sc.nextInt();
    int choice = sc.nextInt();
    List<Integer> minus = new ArrayList<>();
    List<Integer> plus = new ArrayList<>();
    
    for(int i = 0;i<all;i++){
      int x = sc.nextInt();
      if(x < 0){
        minus.add(Integer.valueOf(Math.abs(x)));
      }else{
        plus.add(Integer.valueOf(x));
      }
    }
    Collections.sort(minus);
    
    check(plus,minus,choice);
    check(minus,plus,choice);
               
    System.out.println(answer);
  }
  
  public static void check(List<Integer> a,List<Integer> b,int c){
    for(int i = 0;i<a.size() && i<c;i++){
      if(c - i - 1 > 0){
        if(b.size() > c - i - 2){
          answer = Math.min(answer,2 * a.get(i) + b.get(c - i -2));
        }
      }
      else{
        answer = Math.min(answer,a.get(c - 1));
      }
    }
  }
}

Measured memory_bytes: 60928
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
	static void Main(string[] args)
	{
		string s = Console.ReadLine();
		char[] sp = new char[s.Length];
		for (var i = 0; i < s.Length; i++)
		{
			sp[i] = s[i];
		}
		int l = 0;
		List<char> list = new List<char>();
		List<int> ans = new List<int>();
		list.Add('A');
		list.Add('G');
		list.Add('C');
		list.Add('T');
		for (var i = 0; i < sp.Length; i++)
		{
			if (list.Contains(sp[i]))
			{
				l++;
			}
			else {
				ans.Add(l);
				l = 0; }
			if (i == sp.Length - 1) { ans.Add(l); }
            
		}

		ans.Sort((a, b) => b - a);
		Console.WriteLine(ans[0]);
	}
	
}


Measured memory_bytes: 13280
#include <iostream>

using namespace std;

const int NMAX = 2e5;

int n;
int a[NMAX + 5];
pair<int,int> st[NMAX + 5];
int len;

bool ok(int sz){
	len = 0;
	st[0] = {0,0};
	for(int i = 1;i <= n;i++){
		while(len && st[len].first > a[i]){
			len--;
		}
		if(len && st[len].first == a[i]){
			st[len].second++;
			while(len && st[len].second >= sz){
				st[len].second /= sz;
				st[len].first--;
				if(st[len].first == st[len - 1].first){
					st[len - 1].second += st[len].second;
					len--;
				}
			}
			
			if(len == 0 && st[0].second > 0){
				return false;
			}
		}
		else{
			st[++len] = {a[i],(a[i] <= a[i - 1])};
		}
		
	}
	return true;
}

int main(){
	
	cin >> n;
	
	bool special = true;
	
	for(int i = 1;i <= n;i++){
		cin >> a[i];
		special &= (a[i - 1] < a[i]);
	}
	
	if(special){
		cout << 1;
		return 0;
	}
	
	int st = 1;
	int dr = NMAX + 5;
	
	while(dr - st > 1){
		int mid = (st + dr) / 2;
		
		if(ok(mid)){
			dr = mid;
		}
		else{
			st = mid;
		}
	}
	
	cout << dr;
	
	return 0;
}

Measured memory_bytes: 1536
#include<stdio.h>
int main()
{
    int s,m,h,a;
    scanf("%d %d %d %d",&a);
    s=a%60;
    a=a/60;
    m=a%60;
    h=a/60;
    printf("%d:%d:%d\n",h,m,s );
    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h> //library
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //for-loop (from 0)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++) //for-loop (from 1)
#define all(x) (x).begin(),(x).end() //start-to-end iteration, mainly in upper_bound, lower_bound
#define SZ(x) ((int)(x).size()) //unsigned to signed

using namespace std;
using ll = long long; //long long
ll M = 1000000000 + 7;
const ll INF = 1LL << 60;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } //compare a,b and replace by greater
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } //compare a,b and replace by smaller
ll qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; } //power
ll qp(int a, ll b, ll Mod) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%Mod; a = 1ll * a*a%Mod; } while (b >>= 1); return ans; } //power(mod)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } //gcd
int dx[4] = { 1,0,-1,0 }; //path
int dy[4] = { 0,1,0,-1 }; //path
ll RS(ll N, ll P) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2); return sq*sq; } else { return N*RS(N, P - 1); } } //power(repeat-square,fast)
ll nPr(ll n, ll r) { ll ans = 1; rep(i, r) { ans = ans * (n - i); } return ans; } //permutation
ll nCr(ll n, ll r) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1); bunshi = bunshi * (n - i); } return bunshi / bunbo; } //combination
ll RS(ll N, ll P, ll Mod) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2, Mod); return sq*sq%Mod; } else { return N*RS(N, P - 1, Mod) % Mod; } } //power(mod)(repeat-square,fast)
ll nPr(ll n, ll r, ll Mod) { ll ans = 1; rep(i, r) { ans = ans * (n - i) % Mod; } return ans; } //permutation
ll nCr(ll n, ll r, ll Mod) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1) % Mod; bunshi = bunshi * (n - i) % Mod; } return bunshi * RS(bunbo, Mod - 2, Mod) % Mod; } //combination


int main(void) {
  ll N,W; cin >> N >> W;
  ll items[110][2], dp[110][101000]={0};
  rep(i,N) cin >> items[i][0] >> items[i][1];

  rep(i,N){
    rep(w,W+1){
      if (w-items[i][0] >= 0) chmax(dp[i+1][w],dp[i][w-items[i][0]]+items[i][1]);
      chmax(dp[i+1][w],dp[i][w]);
    }
  }
  
  cout << dp[N][W] << endl;
  return 0;
}


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

#define INF 1E18



int main(){
    ll n;
    cin >> n;
    
    ll ans = INF;
    rep(i,n){
        ll temp;
        ll ans_temp = 0;
        cin >> temp;
        while(temp % 2 == 0){
            ans_temp++;
            temp /= 2;
        }
        ans = min(ans, ans_temp);
    }

    cout << ans << endl;

    return 0;
}


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

#define ll long long

using namespace std;


int main(){
    ll N;
    ll mn = 1000000;
    ll count = 0;
    cin >> N;
    vector<ll> P(N);
    for(ll i = 0;i < N; i++){
        cin >> P.at(i);
        if(P.at(i) < mn) mn = P.at(i);
        else{
            count++;
        }
    }


    cout << N - count << endl;

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define A a
#define B b
#define C c
#define D d
#define N n
#define M m
#define H h
#define W w
#define S s
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
int main(){
	int n;cin>>N;
	int d[N];
	rep(i,0,n) cin>>d[i];
	sort(d,d+n);
	cout<<d[n/2]-d[n/2-1]<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

struct mint {
    ll x;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {if ((x+=a.x)>=MOD) x-=MOD; return *this;}
    mint& operator-=(const mint a) {if ((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
    mint& operator*=(const mint a) {(x*=a.x)%=MOD; return *this;}
    mint operator+(const mint a) const {mint res(*this); return res+=a;}
    mint operator-(const mint a) const {mint res(*this); return res-=a;}
    mint operator*(const mint a) const {mint res(*this); return res*=a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(MOD-2);}
    mint& operator/=(const mint a) { return (*this) *= a.inv();}
    mint operator/(const mint a) const {mint res(*this); return res/=a;}
};

void solve() {
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    vector<mint> sa(n + 1);
    rep(i, n) sa[i + 1] = sa[i] + a[i];
    mint ans = 0;
    rep(i, n) ans += (sa[n] - sa[i+1]) * a[i];
    cout << ans.x << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 6332