akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
#define f first
#define s second

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

main(){
  int w,h;
  while(cin>>w>>h,w|h){
    int xs,ys,xg,yg,n;
    cin>>xs>>ys>>xg>>yg>>n;
    --xs,--ys,--xg,--yg;
    int maze[w][h];
    memset(maze,0,sizeof(maze));
    rep(i,n){
      int c,d,x,y;
      cin>>c>>d>>x>>y;
      --x,--y;
      rep(i,4-d*2)rep(j,2+d*2)maze[x+i][y+j]=c;
    }
    queue<PI> Q;
    if(maze[xs][ys]== 0 || maze[xs][ys]!=maze[xg][yg] || maze[xg][yg]==0){
      puts("NG");
      continue;
    }
    bool goal=false;
    Q.push(mp(xs,ys));
    int dp[w][h];
    memset(dp,0,sizeof(dp));
    dp[xs][ys]=1;
    while(!Q.empty()){
      int cx=Q.front().f,cy=Q.front().s;Q.pop();
      if(cx==xg && cy==yg){
        goal=true;
        break;
      }
      rep(i,4){
        int nx=cx+dx[i],ny=cy+dy[i];
        if(nx<0 || nx>=w || ny<0 || ny>=h || dp[nx][ny])continue;
        if(maze[nx][ny]!=maze[xs][ys])continue;
        dp[nx][ny]=1;
        Q.push(mp(nx,ny));
      }
    }
    cout<<(goal?"OK":"NG")<<endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stack>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <assert.h>
#include <unordered_map>

using namespace std;

const int maxN = 2e5 + 10;

#define FORU(i, l, r) for (int i = l; i <= r; ++i)
#define FORD(i, r, l) for (int i = r; i >= l; --i)
#define REPU(i, r) for (int i = 0; i < r; ++i)
#define F first
#define S second
#define PB push_back
#define LL long long
#define BIT(x, i) ((x >> i) & 1)
#define PINT pair < int, int >
#define MP make_pair

int n, a[maxN], cnt[21];
LL res;

int main() {
    cin >> n;
    FORU(i, 1, n) cin >> a[i];
    int j = 1;
    int num = 0;
    FORU(i, 1, n) {
        REPU(t, 20) cnt[t] += BIT(a[i], t), num += (BIT(a[i], t) && cnt[t] == 2);
        while (num) {
            REPU(t, 20) cnt[t] -= BIT(a[j], t), num -= (BIT(a[j], t) && cnt[t] == 1);
            ++j;
        }
        res += (i - j + 1);
    }
    cout << res;
}


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

using namespace std;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int x,y,z,K;
    cin >> x;
  	cin >> y;
  	cin >> z;
  	cin >> K;
  	K = min(K, x*y*z);
  	vector<long> A(x), B(y), C(z);
  	vector<long> O;
  	int index =0;
  	while(cin >> A[index])
    {
      index++;
      if(index == x) break;
    }
  	index = 0;
  	while(cin >> B[index])
    {
      index++;
      if(index == y) break;
    }
  	index = 0;
  	while(cin >> C[index])
    {
      index++;
      if(index == z) break;
    }
  
  	sort(A.begin(), A.end(), std::greater<long>() );
  	sort(B.begin(), B.end(), std::greater<long>() );
  	sort(C.begin(), C.end(), std::greater<long>() );
  	for (int i = 0; i < x; i++) {
		for (int j = 0; j < y; j++) {
			for (int k = 0; k < z; k++) {
				if ((i + 1) * (j + 1) * (k + 1) <= K) O.push_back(A[i] + B[j] + C[k]);
				else break;
			}
		}
	}
	sort(O.begin(), O.end(), greater<long>());
	for (int i = 0; i < K; i++) cout << O[i] << endl;
  	return 0;
}

Measured memory_bytes: 1404
a=int(input())

if a >= 400 and a < 600:
    print("8")
elif a >= 600 and a < 800:
    print("7")
elif a >= 800 and a < 1000:
    print("6")
elif a >= 1000 and a < 1200:
    print("5")
elif a >= 1200 and a < 1400:
    print("4")
elif a >= 1400 and a < 1600:
    print("3")
elif a >= 1600 and a < 1800:
    print("2")
elif a >= 1800 and a < 2000:
    print("1")

Measured memory_bytes: 9196
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
ll evaluate(VV& S, ll d, V& prev, V& C, ll j) {
    ll temp = 0;
    temp += S[d][j];
    rep(k, 26) {
        if (j == k) {
            continue;
        }
        temp -= C[k] * (d - prev[k]);
    }
    return temp;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll d;
    cin >> d;
    V C(26);
    rep(i, 26) cin >> C[i];
    VV S(d, V(26));
    rep(i, d) { rep(j, 26) cin >> S[i][j]; }
    ll width = 500;
    vector<tuple<ll, V, V>> vec;
    V temp;
    rep(i, 26) temp.push_back(-1);
    V temp2;
    vec.push_back({0, temp, temp2});
    rep3(i, 0, d) {
        priority_queue<tuple<ll, V, V>> q;
        for (auto j : vec) {
            ll score = get<0>(j);
            V prev = get<1>(j);
            V history = get<2>(j);
            rep(k, 26) {
              bool f=false;
                for(int g=history.size()-1,h=0;h<10&&g>=0;h++,g--){
                    if(!history.empty()&&history[g]==k){
                      f=true;
                      break;
                    }
                }
                if(f)continue;
                ll value = evaluate(S, i, prev, C, k);
                ll prev2 = prev[k];
                
                prev[k] = i;
                history.push_back(k);
                q.push({score + value, prev, history});
                history.pop_back();
                prev[k] = prev2;
            }
        }
        vec = {};
        for (ll j = 0; j < width && !q.empty(); j++) {
            vec.push_back(q.top());
            q.pop();
        }
    }
    for (auto i : get<2>(vec[0])) {
        cout << i + 1 << endl;
    }
}


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

#define fi first
#define se second
#define pb push_back
#define MP std::make_pair
#define PII std::pair<int, int>
#define all(x) (x).begin(), (x).end()
#define CL(a, b) memset(a, b, sizeof a)
#define rep(i, l, r) for (int i = (l); i <= (r); ++ i)
#define per(i, r, l) for (int i = (r); i >= (l); -- i)
#define PE(x, a) for (int x = head[a]; x;x = edge[x].next)

typedef long long ll;

const int MAXN = 2e5 + 7;

int t[MAXN], a[MAXN], n;

inline int lb(int x) {
	return x & (-x);
}

void add(int x) {
	for (int i = x; i <= 2 * n; i += lb(i)) t[i]++;
}

int query(int x) {
	int r = 0;
	for (int i = x; i; i -= lb(i)) r += t[i];
	return r;
}

bool check(int mid) {
	CL(t, 0);
	int sum = 0;
	ll cnt = 0;
	add(n);
	rep(i, 1, n) sum += (a[i] >= mid ? 1 : -1), cnt += query(sum + n), add(sum + n);
	return cnt >= 1ll * n * (n + 1ll) / 4ll;
}

int main() {
	scanf("%d", &n);
	int l = INT_MAX, r = INT_MIN, mid;
	rep(i, 1, n) scanf("%d", a + i), l = std::min(l, a[i]), r = std::max(r, a[i]);
	while (l < r) {
		mid = (l + r + 1) / 2;
		if (check(mid)) l = mid;
		else r = mid - 1;
	}
	printf("%d\n", l);
	return 0;
}

Measured memory_bytes: 1408
import heapq
n = int(input())
slist = [int(input())*(-1) for i in range(n)]
sslist = slist[::]
heapq.heapify(slist)
for i in range(n):
  a = heapq.heappop(slist)
  if a == sslist[i]:
    b = heapq.heappop(slist)
    print((-1)*b)
    heapq.heappush(slist,b)
  else:print(-a)
  heapq.heappush(slist,a)


Measured memory_bytes: 89944
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

vector<ll> cum_value[5];
ll weights[5];
ll n, w;

int dfs(int index, ll weight, ll value)
{
    if (weight > w) return 0;
    if (index > 4 or cum_value[index].size() == 0)
        return value;
    int ans = 0;
    rep(i, 0, cum_value[index].size())
    {
        ans = max(ans, dfs(index + 1, weight + weights[index] * i, value + cum_value[index][i]));
        // cout << cum_value[index][i]<<' '<<weight << endl;
    }
    return ans;
}

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

    map<int, vector<ll>> w_vec;
    rep(i, 0, n)
    {
        int w, v;
        cin >> w >> v;
        w_vec[w].push_back(v);
    }

    int index = 0;
    for (auto w_v :w_vec)
    {
        weights[index] = w_v.first;
        vector<ll> values = w_v.second;
        sort(values.rbegin(), values.rend());

        cum_value[index].push_back(0);
        for (auto v: values)
        {
            ll prev = cum_value[index].back();
            cum_value[index].push_back(prev + v);
        }
        ++index;
    }

    cout << dfs(0, 0, 0) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<climits>
#include<queue>
#include<algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define LL long long 
#define MAXN 2200000
int n,m;
int read()
{
	int f=1,x=0;
	char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9') {x=x*10+c-'0';c=getchar();}
	return f*x;
}
struct edge//G
{
	int v,w;
	edge(){}
	edge(int V,int W){v=V,w=W;}
};
vector<edge> G[MAXN+5];
struct nodezx
{
	int v,c;
	nodezx(){}
	nodezx(int V,int C){v=V,c=C;}
	friend bool operator < (nodezx x,nodezx y){return x.v==y.v ? x.c<y.c : x.v<y.v;}
};
vector<nodezx> zx;
struct nodexx
{
	int u,v,w;
	nodexx(){}
	nodexx(int U,int V,int W){u=U,v=V,w=W;}
};
queue<int> Q;
vector<nodexx> xx;
int vis[MAXN+5],dis[MAXN+5];
int SPFA(int s,int t)
{
	memset(vis,0,sizeof(vis));
	memset(dis,0x3f,sizeof(dis));
	dis[s]=0;
	vis[s]=1;
	Q.push(s);
	while(!Q.empty())
	{
		//printf("1\n");
		int u=Q.front();
		//printf("%d:",u);
		//printf("%d\n",G[u].size());
		Q.pop();
		vis[u]=0;
		for(int i=0;i<G[u].size();i++)
		{
			int v=G[u][i].v;
			if(dis[v]>dis[u]+G[u][i].w&&dis[u]<(INF))
			{
				dis[v]=dis[u]+G[u][i].w;
				if(!vis[v])
				{
					vis[v]=1;
					Q.push(v);
				}
			}
		 } 
	} 
	return dis[t]==INF ? -1 : dis[t]/2;
}
int main()
{
	n=read(); 
	m=read();
	int p,q,c;
	for(int i=1;i<=m;i++)
	{
		p=read()-1;
		q=read()-1;
		c=read()-1;
		//printf("%d %d %d\n",p,q,c);
		zx.push_back(nodezx(p,c));
		zx.push_back(nodezx(q,c));
		xx.push_back(nodexx(p,q,c));
		xx.push_back(nodexx(q,p,c));
	}
	sort(zx.begin(),zx.end());
	for(int i=0;i<zx.size();i++)
	{
		int v=zx[i].v;
		G[v].push_back(edge(n+i,1));
		G[n+i].push_back(edge(v,1));
	}
	for(int i=0;i<xx.size();i++)
	{
		int l1=lower_bound(zx.begin(),zx.end(),nodezx(xx[i].u,xx[i].w))-zx.begin();
		int l2=lower_bound(zx.begin(),zx.end(),nodezx(xx[i].v,xx[i].w))-zx.begin(); 
		G[l1+n].push_back(edge(l2+n,0));
		
		//G[l2+n].push_back(edge(l1+n,0));
	}
	printf("%d",SPFA(0,n-1));
 } 

Measured memory_bytes: 102268
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i=0;i<N;i++) cin >> d.at(i);
  sort(d.begin(),d.end());
  int ans=0;
  for(int i=d.at(N/2-1);i<d.at(N/2);i++) ++ans;

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


Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AtCoder solver = new AtCoder();
        solver.solve(1, in, out);
        out.close();
    }

    static class AtCoder {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int x = in.nextInt(), y = in.nextInt(), z = in.nextInt();
            out.println((int) Math.floor((x - z) / (y + z)));
        }
    }
}


Measured memory_bytes: 23124
#include <stdio.h>
#include <stdlib.h>

int main(void){
  int c[3][3];
  int i, j;

  int min[3];

  for(i=0; i<3; i++){
    for(j=0; j<3; j++){
      scanf("%d", &c[i][j]);
    }
    if(c[i][0]>c[i][1]){
      if(c[i][1]>c[i][2]) min[i] = c[i][2];
      else min[i] = c[i][1];
    } else {
      if(c[i][0]>c[i][2]) min[i] = c[i][2];
      else min[i] = c[i][0];
    }
  }



  for(i=0; i<3; i++){
    for(j=0; j<3; j++){
      c[i][j] -= min[i];
    }
  }

  for(j=0; j<3; j++){
    if(c[0][j]!=c[1][j] || c[0][j]!=c[2][j]){
      printf("No\n");
      exit(0);
    }
  }

  printf("Yes\n");

  return (0);
}


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long

using namespace std;

typedef pair<int, int> P;

int main(){
	char b;
	cin >> b;
	if (b=='A') {cout << 'T' << endl;}
	else if (b=='T') {cout << 'A'<< endl;}
	else if (b=='G') {cout <<  'C'<< endl;}
	else if (b=='C') {cout << 'G' << endl;}

}


Measured memory_bytes: 256
import sys
counter=0
A=[]
for e in sys.stdin:
    str=e.replace("\n", "")
    A.append(0)
    A.append(0)
    for i in range(len(str)-2):
        if str[i:i+3]=="JOI":
            A[counter]+=1
        elif str[i:i+3]=="IOI":
            A[counter+1]+=1
    counter+=2
for k in range(len(A)):
    print(A[k])



Measured memory_bytes: 5580
#include <bits/stdc++.h>
#include <math.h>
#include <iostream>
#include <stdlib.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
 
int main(void){
    long int N;
    cin >> N;
    cout << N*(N-1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<50
#define fst first
#define snd second
#define pb push_back
#define int long long
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(int itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(int itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define debug(x)  cout << #x << " = " << (x) << endl;
typedef long long ll;
typedef pair<ll,ll> P;

ll C[51][51];
void comb_table(int N){ 
	for(int i=0;i<=N;++i){
		for(int j=0;j<=i;++j){
			if(j==0 or j==i){
				C[i][j]=1LL;
			}else{
				C[i][j]=(C[i-1][j-1]+C[i-1][j]);
			}
		}
	}
}

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

  int n,p;
  cin >> n >> p;
  
  int odd = 0,even = 0;
  REP(_,n){
    int a;
    cin >> a;
    if(a%2==1) odd++;
    else       even++;
  }
  
  comb_table(n);
  
  ll cnt = 0;
  REP(i,n){
    if(2*i+p > odd) break;
    cnt += C[odd][2*i+p];
  }
  
  cout << cnt*(1LL<<even) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	long long ans=0,l,r;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>l>>r;
		ans+=r-l+1;
	}
	cout<<ans<<endl;
}


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

int main() {
  int N;
  cin >> N;
  long long ma = -1, res = 0;
  for (int i = 0; i < N; ++i) {
    long long h; 
    cin >> h;
    if (h >= ma) ++res;
    ma = max(ma, h);
  }
  cout << res << endl;
}

Measured memory_bytes: 3620
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = list(input())
l = [[] for i in range(k)]
for i in range(n):
    l[i%k].append(t[i])
ans = 0
for i in range(k):
    a = l[i]
    count = 0
    mae = "a"
    for j in a:
        if mae == j:
            count += 1
        else:
            if count == 0:
                count += 1
            elif count == 1:
                if mae == "r":
                    ans += p
                elif mae == "s":
                    ans += r
                else:
                    ans += s
            else:
                if count % 2 == 0:
                    b = count//2
                else:
                    b = count//2 + 1
                if mae == "r":
                    ans += p*b
                elif mae == "s":
                    ans += r*b
                else:
                    ans += s*b
            mae = j
            count = 1
    if count == 0:
        count += 1
    elif count == 1:
        if mae == "r":
            ans += p
        elif mae == "s":
            ans += r
        else:
            ans += s
    else:
        if count % 2 == 0:
            b = count//2
        else:
            b = count//2 + 1
        if mae == "r":
            ans += p*b
        elif mae == "s":
            ans += r*b
        else:
            ans += s*b
print(ans)

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    double a, b, h, m;
    cin >> a >> b >> h >> m;

    double pi = acos(-1);

    double thetaa, thetab;
    thetaa = 2*pi*(h/12.0+30.0/360.0*m/60.0);
    thetab = 2*pi*m/60.0;

    double ax, ay, bx, by;
    ax = a*sin(thetaa);
    ay = a*cos(thetaa);
    bx = b*sin(thetab);
    by = b*cos(thetab);

    double ans;
    ans = sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by));

    cout << setprecision(11) << ans << endl;

    return 0;
}


Measured memory_bytes: 4108
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

int N, A[200020];
map <int, int> Mx;
int chk;
void update(int x, int L) {
	Mx[x]++; if(x == 0) chk = 1;
	if(Mx[x] == L) { Mx[x] = 0, update(x - 1, L); }
}

int main() {
	scanf("%d", &N);
	for(int i=1;i<=N;i++) scanf("%d", A + i);
	int can1 = 1;
	for(int i=2;i<=N;i++) if(A[i] <= A[i-1]) can1 = 0;
	if(can1) {
		puts("1");
		return 0;
	}
	int low = 2, high = N, res = -1;
	while(low <= high) {
		int mid = (low + high) >> 1;
		Mx.clear(); chk = 0;
		for(int i=2;i<=N;i++) {
			if(A[i] <= A[i-1]) {
				update(A[i], mid);
				while(szz(Mx) && Mx.rbegin()->Fi > A[i]) Mx.erase(--Mx.end());
			}
		}
		if(chk) low = mid + 1;
		else high = mid - 1, res = mid;
	}
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	long long x,y,k,sum;
	while(~scanf("%lld%lld",&x,&y)){
		k = 1;
		while(x <= y){
			x = x * 2;
			if(x <= y)
				k = k + 1;
		}
		printf("%lld\n",k);
	}
	return 0;
}

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

#define ll long long
#define sc(n) int n; scanf("%d",&n);
#define mod 10000007
#define N 100001
#define MX 1000000001
#define log(n) (int)log2(n)
#define log(a)(b) log(b)/log(a)
#define pb(x) push_back(x);
#define T int t, q=0; scanf("%d", &t); while(q++<t)
#define scArr(n) int n; scanf("%d", &n); int a[n]; for(int i=0; i<n; i++) scanf("%d", &a[i]);
#define pi acos(-1)

int main()
{
    string s;
    cin>>s;
    int a=0;
    for(int i=0;i<s.size();i++) if(s[i]=='A') a++;
    if(a==s.size() || a==0) cout<<"No";
    else cout<<"Yes";
}


Measured memory_bytes: 256
H,W = map(int, input().split())
A = [list(map(str, input())) for _ in range(H)]
cnt = 0
for i in range(H):
	for j in range(W):
		if A[i][j] == "#":
			cnt += 1

if cnt == H+W-1:
	print("Possible")
else:
	print("Impossible")

Measured memory_bytes: 3060
#include <iostream>

using namespace std;
int xx[]={-1,0,1,0};
int yy[]={0,-1,0,1},n,m;
int b=0;
    char mat[1000][1000];
void dfs(int y,int x){
    b++;
    if(y<0||y>=n||x<0||x>=m)return;
    mat[y][x]='.';
    int c=0,aux1,aux2,c2=0;
    for(int i=0;i<4;i++){
        if(mat[y+yy[i]][x+xx[i]]=='#'){
            c++;
            if(i<2)c2++;
            aux1=y+yy[i];
            aux2=x+xx[i];
        }
    }
    if(c==1&&c2==1)dfs(aux1,aux2);
    return;
}
int main()
{
    int x=0;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>mat[i][j];
            if(mat[i][j]=='#')x++;
        }
    }
    dfs(n-1,m-1);
    if(b==x)cout<<"Possible";
    else cout<<"Impossible";
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#define inf 3001
#define max(a,b)  (((a) > (b)) ? (a) : (b))
#define min(a,b)  (((a) < (b)) ? (a) : (b))
int main(){
	int a,b,c,d,e,f;
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
	bool swater[31];
	bool sugar[3001];
	double sugwat=0;
	int sug=0,wat=0;
	for(int i=0;i<31;i++) swater[i]=false;
	for(int i=0;i<3001;i++) sugar[i]=false;
	for(int i=0;i<=f/a;i++){
		for(int j=0;j<=f/b;j++){
			if(i*a+j*b>f/100) break;
			swater[i*a+j*b]=true;
			//printf("%d ",i*a+j*b);
		}
	}
	for(int i=0;i<f/c;i++){
		for (int j=0;j<f/d;j++){
			if(i*c+j*d>f) break;
			sugar[i*c+j*d]=true;
		}
	}
	float sw=0;
	for(int i=1;i<=f/100;i++){
		for(int j=i*e;j>=0;j--){
			if(j>(f-i*100)) j=f-i*100;
			//printf("\n%d:%d %d:%d ",i,swater[i],j,sugar[j]);
			if(sugar[j]==0) continue;
			if(swater[i]==0) continue;
			//printf("\n%d %d ",i,j);
			sw=j;
			sw/=(i*100+j);
			if(sw>=sugwat){
				sugwat=sw;
				sug=j;
				wat=i*100+sug;
			}
			break;
		}
	}
	printf("%d %d\n",wat,sug);
	return 0;
}

Measured memory_bytes: 256
#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 << "Left" << endl;
  }
  else if (A + B < C + D){
    cout << "Right" << endl;
  }
  else if (A + B == C + D){
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
 int a,b;
  cin >> a >> b;
  if(a==b)
  {
    cout<<a+b<<"\n";return 0;
  }
  int mx  = max(a,b);
  
    cout<<mx+mx-1<<"\n";
  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)


def calc(x):
    if A[x] >= K:
        return True

    dp = [False] * K
    dp[0] = True

    ma = 0
    for i in range(N):
        if i == x:
            continue
        for j in range(ma, -1, -1):
            if j + A[i] >= K:
                continue

            dp[j + A[i]] |= dp[j]

        ma = min(K - 1, ma + A[i])

    return sum(dp[K - A[x]:K])


if not calc(N - 1):
    print(N)
    exit()

if calc(0):
    print(0)
    exit()

l, r = 0, N - 1
while r - l > 1:
    mid = (r + l) // 2
    if calc(mid):
        r = mid
    else:
        l = mid

print(r)


Measured memory_bytes: 42608
S = int(input())
X1 = 0
Y1 = 0
X2 = 10**9
Y2 = 1
X3 = S%(10**9)
Y3 = S//(10**9)
if X3 != 0:
  Y3 += 1
  X3 = X2 - X3
print(X1,Y1,X2,Y2,X3,Y3)

Measured memory_bytes: 3060
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var whxyr = input.split(' ').map(Number);
var w = whxyr[0];
var h = whxyr[1];
var x = whxyr[2];
var y = whxyr[3];
var r = whxyr[4];

var is_circleinrectangle = 0 <= x - r && x + r <= w && 0 <= y - r && y + r <= h;

console.log(is_circleinrectangle ? 'Yes' : 'No');

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define forin(i,array) for(auto& x:array)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mod 1000000007
#define inf 1000000009
#define infll 1e15


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

int maxtime=inf;

int main(){
    int n,t;
    cin>>n>>t;
    rep(i,n){
        int x,y;
        cin>>x>>y;
        if(y<=t)maxtime=min(maxtime,x);
    }
    if(maxtime==inf)cout<<"TLE"<<endl;
    else cout<<maxtime<<endl;
}

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

public class Main {

    FastReader in = new FastReader();
    PrintWriter out = new PrintWriter(System.out);
    int N = (int)1e5+1, mod = (int)1e9+7,n,m; 


    void solve(){
        int n = in.ni() , ans = 0, max = 0;
        for(int i=0;i<n;i++){
            int x = in.ni();
            max = Math.max(max,x);
            if(max==x)ans++;
        }
        out.println(ans);
    }

    void run(){
        solve();
        // out.flush();
        out.close();
    }
    public static void main(String[] args) {
        boolean memory = false;
        Thread t=new Thread(null, null, "T", 1<<28) {
            public void run() {
                new Main().run();
            }
        };
        if(memory) t.start();
        else new Main().run();
    }
    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next(){
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine(){
            String str = "";
            try{   
                str = br.readLine();
            }catch (IOException e){
                e.printStackTrace();
            }  
            return str;
        }
        int ni(){return Integer.parseInt(in.next());}
        long nl(){return Long.parseLong(in.next());}
        double nd(){return Double.parseDouble(in.next());}
    }
    class Edges{
        int u,v,w;
        public Edges(int u,int v,int w){
            this.u = u;
            this.v = v;
            this.w = w;
        }
    }
    void pn(Object o){out.println(o);out.flush();}
    long inv(long a, long b){return 1<a ? b - inv(b%a,a)*b/a : 1;}//a^(-1)%b
    long fe(long a,long b){
        long ans = 1L;
        while(b>0){
            if((b&1)>0)ans=ans*a%mod;
            a = a%mod*a%mod;
            b>>=1;
        }
        // pn("ans = "+ans);
        return ans;
    }
    long gcd(long a,long b){
        if(a==0)return b;
        return gcd(b%a,a);
    }
    class pair{
        int x,y;
        public pair(int f,int s){
            this.x = f;
            this.y = s;
        }
    }
    class triple{
        int i,l,r;
        public triple(int i,int l,int r){
            this.i = i;
            this.l = l;
            this.r = r;
        }
    }
}

Measured memory_bytes: 22740
#include <algorithm>  // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>     // bitset
#include <cctype>     // isupper, islower, isdigit, toupper, tolower
#include <cstdint>    // int64_t, int*_t
#include <cstdio>     // printf
#include <deque>      // deque
#include <iomanip>    // fixed, setprecision
#include <iostream>   // cout, endl, cin
#include <map>        // map
#include <queue>      // queue, priority_queue
#include <set>        // set
#include <stack>      // stack
#include <string>     // string, to_string, stoi
#include <tuple>      // tuple, make_tuple
#include <unordered_map>  // unordered_map
#include <unordered_set>  // unordered_set
#include <utility>        // pair, make_pair
#include <vector>         // vector
using namespace std;

int main() {
  int N, A, B, x, t = 0;
  string s;
  cin >> N >> A >> B;
  for (int i = 1; i <= N; i++) {
    s = to_string(i);
    x = 0;
    for (char c : s) {
      x += (int)(c - '0');
    }
    if (A <= x && x <= B) t += i;
  }
  cout << t << endl;
}


Measured memory_bytes: 3192
from collections import deque
H, W = map(int, input().split())

area = [input() for _ in range(H)]

distance = [ [float('inf') for _ in range(W)] for _ in range(H)]
to_search = deque()

for i in range(H):
    for j in range(W):
        if area[i][j] == "#":
            to_search.appendleft((i, j, 0))
            distance[i][j] = 0

didj = [[1, 0], [0, 1], [-1, 0], [0, -1]]
ans = 0

while len(to_search) > 0:
    nowi, nowj, nowd = to_search.pop()
    for di, dj in didj:
        nexti = nowi + di
        nextj = nowj + dj
        if 0 <= nexti < H and 0 <= nextj < W:
            if distance[nexti][nextj] > nowd + 1:
                to_search.appendleft((nexti, nextj, nowd + 1))
                distance[nexti][nextj] = nowd + 1
                ans = max(ans, nowd + 1)

print(ans)


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

int main(){
  int N,L;
  cin >> N >> L;
  vector<int> v(N);
  int64_t sum=0;
  v.at(0)=L+1-1;
  sum+=v.at(0);
  int mi=v.at(0);
  for(int i=1;i<N;i++){
    v.at(i)=L+(i+1)-1;
    sum+=v.at(i);
    if(abs(mi)>abs(v.at(i))){
      mi=v.at(i);
    }
  }
  cout << sum-mi << endl;
  return 0;
}


Measured memory_bytes: 256
'''
Created on 2020/09/13

@author: okazakieiichiro
'''
d = 10 ** 9 + 7
n = int(input())

ret = None
if n < 2:
    ret = 0
elif n == 2:
    ret = 2
else:
    ret = 10 ** n + 8 ** n - 2 * 9 ** n
ret %= d
print(ret)

Measured memory_bytes: 11024
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join(
            '{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M, K = map(int, input().split())

# 友達関係をUFで用意
uf = UnionFind(N)

# 直接の友達のリスト
friend = [[] for i in range(N)]
# 直接のブロックのリスト
block = [[] for i in range(N)]

for i in range(M):
    A, B = map(int, input().split())
    uf.union(A-1, B-1)
    friend[A-1].append(B-1)
    friend[B-1].append(A-1)

for i in range(K):
    C, D = map(int, input().split())
    block[C-1].append(D-1)
    block[D-1].append(C-1)

ans = [0 for i in range(N)]

# 友達関係のグループの要素数ーグループ内の直接の友達の数ーグループ内の直接のブロックの数ー自分自身
for i in range(N):
    ans[i] += uf.size(i) -1
    for j in friend[i]:
        if uf.same(i,j):
            ans[i] -= 1
    for j in block[i]:
        if uf.same(i,j):
            ans[j] -= 1

print(' '.join(map(str, ans)))


Measured memory_bytes: 130336
import collections
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]


def factorize_all(n):
    factorizations = [None] * (n + 1)
    factorizations[0] = dict()
    factorizations[1] = dict()
    for p in range(2, n + 1):
        if factorizations[p] is None:
            for k in range(1, n // p + 1):
                if factorizations[k] is None:
                    continue
                fs = factorizations[k].copy()
                if p in fs:
                    fs[p] += 1
                else:
                    fs[p] = 1
                factorizations[k * p] = fs
    return factorizations


MOD = 10**9 + 7

n = ri()
ls = ril()
if n == 1:
    print(1)
    exit()

factorizations = factorize_all(max(ls))

lcm = collections.Counter()
for x in ls:
    counter = factorizations[x]
    for p, k in counter.items():
        lcm[p] = max(lcm[p], k)
lcm_val = 1
for p, k in lcm.items():
    lcm_val *= pow(p, k, MOD)
    lcm_val %= MOD

pinvs = {p: pow(p, MOD - 2, MOD) for p in lcm}
res = 0
for x in ls:
    counter = factorizations[x]
    s = 1
    for p, k in counter.items():
        s *= pow(pinvs[p], k, MOD)
    res += lcm_val * s % MOD
    res %= MOD
print(res)

Measured memory_bytes: 306044
#include<iostream>
#include<algorithm>
#include<unordered_map>
using namespace std;
int main()
{
    int n,m,k,ans=0,d,temp;
    //找高展望台，n个展望台，m个道，道j连接着aj和bj
    string s;
    unordered_map<int,int> hash;
    cin>>n>>m;
    ans=n;
    int h[100001];//每一个的高度你都知道咯= =。。。
    //我们根本不需要关心没有路线连接的！！！！所以直接根据路径淘汰就好
    for(int i=1;i<=n;i++)
        cin>>h[i];
    int t1,t2;
    for(int i = 1;i<=m;i++)
    {
        cin>>t1>>t2;
        //if(t1==t2)//不可能有这个= =。。。
        if(h[t1]>h[t2])
        {
            if(hash[t2]==0)
            {
                //cout<<"大于"<<endl;
                ans--;
                hash[t2]++;
            }
        }
        else if(h[t1]<h[t2])//其实就是t1<2
        {
            if(hash[t1]==0)
            {
                //cout<<"小"<<endl;
                ans--;
                hash[t1]++;
            }
        }
        else
        {
             if(hash[t1]==0&&hash[t2]!=0)
            {
                ans--;
                hash[t1]++;
            }
            else if(hash[t1]!=0&&hash[t2]==0)
            {
               // cout<<"-1"<<endl;
                ans--;
                hash[t2]++;
            }
            else if(hash[t1]==0&&hash[t2]==0)
            {
               // cout<<"-2"<<endl;
                ans-=2;
                hash[t1]++;
                hash[t2]++;
            }
            else
                continue;
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 6016
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Long[] a = new Long[N*3];
		
		for(int i = 0; i < N*3 ;i++) {
			a[i] = sc.nextLong();
		}
		
		Arrays.sort(a);
		
		long ans = 0;
		int index = 0;
		
		for(int i = N*3 ; i-2 > index ; i -= 2 ) {
			ans += a[i-2];
			index++;
		}
		System.out.println(ans);
	}
}


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

typedef unsigned long long ull;

int main(){
  ull H,W;
  cin >>H>>W;
  ull ans=0;
  if (H==1 || W==1){
    cout << 1 <<endl;
    return 0;
  }
  if (H%2==0) ans=(H*W/2);
  else ans=(W*H+1)/2;
  cout <<ans<<endl;
}

Measured memory_bytes: 256
const val P = 998244353L

// Find (x, y, r) such that r = gcd(a,b) and ax + by = r.
fun extendedGCD(a: Long, b: Long): Triple<Long, Long, Long> {
  var x0 = 1L
  var y0 = 0L
  var z0 = a
  var x1 = 0L
  var y1 = 1L
  var z1 = b
  while (true) {
    if (z1 == 0L) return Triple(x0, y0, z0)
    val q = z0 / z1
    val x2 = x0 - q * x1
    val y2 = y0 - q * y1
    val z2 = z0 - q * z1
    x0 = x1
    x1 = x2
    y0 = y1
    y1 = y2
    z0 = z1
    z1 = z2
  }
}

fun inverseMod(a: Long, m: Long): Long {
  val (x, y, r) = extendedGCD(a, m)
  if (r != 1L) return 0  // No inverse.

  return (x + m) % m
}

fun timesMod(x: Long, y: Long): Long {
  return x * y % P
}

fun plusMod(x: Long, y: Long): Long {
  return (x + y) % P
}

fun minusMod(x: Long, y: Long): Long {
  return (x - y + P) % P
}

fun divMod(x: Long, y: Long): Long {
  return timesMod(x, inverseMod(y, P))
}

fun main(args: Array<String>) {
  val (n, a, b, k) = readLine()!!.split(" ").map { it.toLong() }
  val nInt = n.toInt()

  val factorialTable = LongArray(nInt + 1)
  factorialTable[0] = 1
  for (i in 1..nInt) {
    factorialTable[i] = timesMod(factorialTable[i - 1], i.toLong())
  }

  var ans = 0L
  for (x in 0..nInt) {
    if (a * x > k) continue
    // k - a * x >= 0.
    if ((k - a * x) % b != 0L) continue
    val yLong = (k - a * x) / b
    if (yLong > n) continue
    val y = yLong.toInt()
    val fx = divMod(divMod(factorialTable[nInt], factorialTable[x]), factorialTable[nInt - x])
    val fy = divMod(divMod(factorialTable[nInt], factorialTable[y]), factorialTable[nInt - y])
//    println("$n $x $y")
//    println("$fx $fy")
    ans = plusMod(ans, timesMod(fx, fy))
  }
  println(ans)
}


Measured memory_bytes: 54660
n=int(input())
a=list(map(int,input().split()))
ans=0
b=[]
for i in range(n):
    b.append(a[i]-(i+1))
b.sort()
t=n//2
f=b[t]
for i in range(n):
    ans+=abs(b[i]-f)
print(ans)

Measured memory_bytes: 26128
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, H1);
    IN(ll, M1);
    IN(ll, H2);
    IN(ll, M2);
    IN(ll, K);
    ll t = (H2 - H1) * 60 + (M2 - M1);
    OUT(t - K);
}

Measured memory_bytes: 3624
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long INF = 1LL << 60;
const int MOD = 1000000007;



template <typename T>
void cout_vector(vector<T> A){
    for (T a : A) cout << a << " ";
    cout << endl;
}

int main(){
    int N;
    cin >> N;
    bool flag = true;
    vector<vector<int>> X(15,vector<int>(15));
    vector<vector<int>> Y(15,vector<int>(15));
    vector<int> A(N);
    rep(i,N){
        cin >> A[i];
        X[i].resize(A[i]);
        Y[i].resize(A[i]);
        rep(j,A[i]){
            int x,y;
            cin >> x >> y;
            X[i][j] = x - 1 ; //0-based indexにする
            Y[i][j] = y ;
        }
    }
    int max_honest = -1;
    for(int bit = 0; bit < (1 << N); bit++){
        flag = true;
        //cout << "search[" << bitset<3> (bit) << "]pettern..." << endl;
        int honest_count = 0;
        for(int i = 0; i < N; i++){
            if (!(flag)) break;
            if (bit & (1 << i)){
                honest_count++;
                for (int j = 0; j < A[i]; j++){
                    int y = Y[i][j];
                    int x = X[i][j];
                    int w = (bit & (1 << x)) != 0;
                    //cout << i << " says " << x << " is " << y << " " << "true:" << w << endl;;
                    if (w != y) {
                        flag = false;
                        honest_count = -1;
                        break;
                    }
                }
            }
        }
        //cout << "honest count:" << honest_count << endl;
        //cout << "=====" << endl;

        if (max_honest < honest_count) max_honest = honest_count;
    }
    cout << max_honest << endl;

}

Measured memory_bytes: 256
n,m=map(int,input().split())
arr=list(map(int,input().split()))
arr=sorted(arr)
q=[list(map(int,input().split())) for _ in range(m)]
q=sorted(q,reverse=True,key=lambda x:x[0])
q=sorted(q,reverse=True,key=lambda x:x[1])
pos=0
for i in range(n):
  if arr[i]<=q[pos][1]:
    arr[i]=q[pos][1]
    q[pos][0]-=1
    if q[pos][0]==0:
      pos+=1
      if pos==m:
        break
print(sum(arr))

Measured memory_bytes: 33732
# @author 

import sys

class ICoins:
    def solve(self):
        n = int(input())
        p = [float(_) for _ in input().split()]
        dp = [[0.0] * (n + 1) for _ in range(n + 1)]
        # dp[i][j] probability of having i heads after j tosses
        dp[0][0] = 1
        for j in range(1, n + 1):
            for i in range(j + 1):
                dp[i][j] = dp[i][j - 1] * (1 - p[j - 1])
                if i > 0:
                    dp[i][j] += dp[i - 1][j - 1] * p[j - 1]

        ans = 0
        for i in range(n + 1):
            if i > n - i:
                ans += dp[i][n]
        print(ans)


solver = ICoins()
input = sys.stdin.readline

solver.solve()


Measured memory_bytes: 111964
#include<iostream>
#include<string>
#include<string.h>
#include<map>
#include<set> 
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue> 
using namespace std;
int main() 
{int n,ans=0;
 cin>>n;
 int a[n];
 for (int i=0;i<n;i++){ 
 cin>>a[i]; 
 while (a[i]%2==0){
 a[i]/=2;
 ans++;}}
 cout<<ans;
 
 system("pause");
 return 0;  
}

Measured memory_bytes: 504
import { readFileSync } from "fs";

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const range = (n: number | bigint) => [...Array(Number(n))].map((_, i) => i);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const tuple = <T extends unknown[]>(...ts: T) => ts;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [cin, nCin, bCin] = (() => {
  const inputs = readFileSync("/dev/stdin", "utf-8").split(/[\n|\s]+/);
  let count = 0;
  const cin = () => inputs[count++];
  return tuple(
    cin,
    () => Number(cin()),
    () => BigInt(cin())
  );
})();
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const isNumber = (x: unknown): x is number => typeof x === "number";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const isBigint = (x: unknown): x is bigint => typeof x === "bigint";
type NumberOrBigintOrElse<T> = number | bigint extends T
  ? undefined
  : T extends number
  ? number
  : T extends bigint
  ? bigint
  : undefined;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const max = <T extends number | bigint>(...ts: T[]) =>
  (ts.length === 0
    ? undefined
    : isNumber(ts[0])
    ? Math.max(...(ts as number[]))
    : (ts as bigint[]).reduce((acc, t) =>
        acc >= t ? acc : t
      )) as NumberOrBigintOrElse<T>;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const min = <T extends number | bigint>(...ts: T[]) =>
  (ts.length === 0
    ? undefined
    : isNumber(ts[0])
    ? Math.min(...(ts as number[]))
    : (ts as bigint[]).reduce((acc, t) =>
        acc <= t ? acc : t
      )) as NumberOrBigintOrElse<T>;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const abs = <T extends number | bigint>(t: T) =>
  (isNumber(t)
    ? Math.abs(t)
    : isBigint(t)
    ? t >= 0n
      ? t
      : -t
    : undefined) as NumberOrBigintOrElse<T>;

/**
 * Program
 */
const getAns = (n: number): number => (n === 0 ? 1 : 0);

{
  const x = nCin();
  const ans = getAns(x);
  console.log(ans);
}


Measured memory_bytes: 29608
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#define ll long long
#define rep(i, a, b) for(int i = a; i <= b; i++)
void read(int &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
void read(ll &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
using namespace std;
const int maxn = 200010;
int n, head, tail, q[maxn];
ll c, a[maxn], dp[maxn];
ll sqr(ll x) { return x * x; }
double slope(int x, int y) {
    return 1.0 * (dp[y] + sqr(a[y]) - dp[x] - sqr(a[x])) / (a[y] - a[x]);
}
int main()
{
    read(n), read(c);
    rep(i, 1, n) read(a[i]);
    dp[1] = 0;
    q[++tail] = 1;
    rep(i, 2, n) {
        while(head < tail && 2 * a[i] >= slope(q[head], q[head + 1])) head++;
        int now = q[head];
        dp[i] = dp[now] + sqr(a[i] - a[now]) + c;
        while(head < tail && slope(q[tail - 1], q[tail]) >= slope(q[tail], i)) tail--;
        q[++tail] = i;
    }
    printf("%lld\n", dp[n]);
    return 0;
}

Measured memory_bytes: 4096