akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int long long

void solve() {
	int n, m, v, p; cin >> n >> m >> v >> p;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    sort(all(a));
    reverse(all(a));
    int ok = p, ng = n + 1;
    while(ng - ok > 1) {
        int q = (ng + ok) / 2;
        bool check = true;
        if(a[p - 1] > a[q - 1] + m) { 
            check = false;
        } else {
            int k = (v - 1) - (p - 1) - (n - q);
            if(k <= 0) check = true;
            else {
                int sum = 0;
                for(int i = p; i <= q - 1; ++i) {
                    sum += (a[q - 1] + m) - a[i - 1];
                }
                //cout << q << " " << sum << " " << k << endl;
                if(sum < m * k) {
                    check = false;
                } else {
                    check = true;
                }
            }
        }
        if(check) {
            ok = q;
        } else {
            ng = q;
        }
    }
    cout << ok << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

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

using namespace std;

long long inf=1000000007;

long long modpow(long long n,long long p,long long mod);

int main(){
	long long n,m;
	cin>>n>>m;
	vector<long long> val(m);
	for(long long i=0;i<m;i++) cin>>val.at(i);

	vector<long long> dp(n+1,inf*100);
	dp.at(0)=0;

	for(long long i=0;i<n;i++){
		for(auto a:val){
			if(i+a<=n){
				dp.at(i+a)=min(dp.at(i+a),dp.at(i)+1);
			}
		}
	}

	cout<<dp.at(n)<<endl;

	return 0;
}

long long modpow(long long n,long long p,long long mod){
	if(p==0) return 1;
	if(p%2==0) return (modpow(n,p/2,mod)*modpow(n,p/2,mod))%mod;
	if(p%2==1) return (modpow(n,p-1,mod)*n)%mod;
	cerr<<"ERROR"<<endl;
	return 1;
}



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

static const int MAX = 10000;

int main(){
    int n, m, a;
    int asum = 0;
    cin >> n >> m;
    for(int i=0; i<m; i++){
        cin >> a;
        asum += a;
    }
    if(asum > n) cout << -1 << endl;
    else cout << n - asum << endl;
}

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

int main()
{
  int an, bn, a[5000], b[5000], ans = 0;
  cin >> an >> bn;
  for(int i = 0; i < an; i++)
    cin >> a[i];
  for(int i = 0; i < bn; i++)
    cin >> b[i];

  for(int st = 0; st < bn; st++)
  {
    int ai = 0, bi = st;
    for(; bi < bn; bi++, ai++)
    {
      while(a[ai] != b[bi])
      {
        if(!(ai < an))
          goto countend;
        ai++;
      }
    }
countend:
    ans = max(ans, bi - st);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1200
//18
#include<iostream>
#include<utility>
#include<algorithm>

using namespace std;

typedef pair<int,int> pii;

bool cmp(pii a,pii b){
  return  a.first>b.first || (a.first==b.first && a.second<b.second);
}

int main(){
  for(int n,m;cin>>n>>m,n|m;){
    int v[101]={};
    for(int i=0;i<n;i++){
      for(int j=1;j<=m;j++){
	int k;
	cin>>k;
	v[j]+=k;
      }
    }
    pii res[101];
    for(int i=1;i<=m;i++){
      res[i]=make_pair(v[i],i);
    }
    sort(res+1,res+1+m,cmp);
    for(int i=1;i<=m;i++){
      cout<<res[i].second<<((i==m)?'\n':' ');
    }
  }
  return 0;
}

Measured memory_bytes: 864
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>

#define INF 100000001

using namespace std;

int DP[101][101];
int *p;

int rec(int r, int c){
  int Min = INF;
  int num = c-r;

  for (int i = 0; i < num; i++){
    Min = min(Min, DP[r][r+i] + DP[r+i+1][c] + p[r-1]*p[r+i]*p[c]);
  }
  return Min;
}
  int main(){
    int N;
    cin >> N;
    for(int i = 1; i <= N; i++) DP[i][i] = 0;

    p = (int *)malloc(sizeof(int)*(N+1));

    cin >> p[0];
    cin >> p[1];
      int bb;
    for(int i = 2; i <= N; i++){
      cin >> bb;
      cin >> p[i];
    }

    for(int i = 1; i < N; i++) DP[i][i+1] = p[i-1]*p[i]*p[i+1];

    for(int j = 0; j <= N-3; j++){
      for(int i = 3+j; i <= N; i++){
	DP[i-2-j][i] = rec(i-2-j,i);
      }
    }

    cout << DP[1][N] << endl;

    return 0;
  }



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

using namespace std;

string s,t, subst ;
int DP[3009][3009];

int LCS(int i,int j){
	if(i==s.size() || j==t.size()){
		return 0;
	}

	if(DP[i][j] >= 0) return DP[i][j];

	int valor = 0;

	if(s[i]==t[j]){
		valor += LCS(i+1,j+1) + 1;
	}else{
		valor += max(LCS(i+1,j),LCS(i,j+1));
	}
	return DP[i][j] = valor;
}

void Recover(int i,int j){
	if(i==s.size() || j==t.size()){
		return;
	}
	if(s[i]==t[j]){
		subst += s[i];
		Recover(i+1,j+1);
	}else{
		if(DP[i][j]==DP[i+1][j]){
			Recover(i+1,j);
		}else{
			Recover(i,j+1);
		}
	}
}

int main(){

	getline(cin,s);
	getline(cin,t);

	int x;

	memset(DP,-1,sizeof(DP));

	x = LCS(0,0);
	Recover(0,0);

	cout << subst << endl;

	return 0;
}

Measured memory_bytes: 35968
#include <stdio.h>
int main(void)
{
    int h,n,i,sum = 0;
    scanf("%d%d",&h,&n);
    int a[100000];
    for(i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
        sum += a[i];
    }
    if(h <= sum)
        printf("Yes");
    else
        printf("No");
 
 
    return 0;
}

Measured memory_bytes: 512
//Night's template
//orzakyrt
#include <bits/stdc++.h>
#define R register
#define LL long long
#ifdef __DEBUG__
	#define Debug (fprintf(stderr,"orzyrt\n"),fflush(stderr))
	#define debug(__a...) (fprintf(stderr,__a),fflush(stderr))
#else
	#define Debug ('orzyrt')
	#define debug(__a...) ('orzyrt')
#endif
inline void Compile(R char *s){
	char com[111];
	sprintf(com,"g++ %s.cpp -lm -o %s",s,s);
	system(com);
}
inline void setfile(R char *s){
	char inname[111],outname[111];
	sprintf(inname,"%s.in",s);
	sprintf(outname,"%s.out",s);
	freopen(inname,"r",stdin);
	freopen(outname,"w",stdout);
}
#ifdef __DEBUG__
	#define setfile(__a) (1)
#endif
template<class TT>inline TT Max(R TT a,R TT b){return a<b?b:a;}
template<class TT>inline TT Min(R TT a,R TT b){return a<b?a:b;}
template<class TT>inline TT Abs(R TT a){return a<0?-a:a;}
template<class TT>inline TT cmin(R TT &a,R TT b){(b<a)&&(a=b);}
template<class TT>inline TT cmax(R TT &a,R TT b){(a<b)&&(a=b);}
using namespace std;
template<class TT>inline void read(R TT &x){
	x=0;R bool f=false;R char c=getchar();
	for(;c<48||c>57;c=getchar())f|=(c=='-');
	for(;c>47&&c<58;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	(f)&&(x=-x);
}
//end template

namespace Night{
	int n;
	struct node{
		int x,y,h;
	}a[111];
	inline int check(R int x,R int y){
		R int ret=-1;
		R int i;
		for(i=1;i<=n;++i){
			if(a[i].h){
				R int t=Abs(x-a[i].x)+Abs(y-a[i].y);
				ret=a[i].h+t;
				break;
			}
		}
		if(ret==-1){
			R int tmp=1e9+7;
			for(R int i=1;i<=n;++i){
				R int t=Abs(x-a[i].x)+Abs(y-a[i].y);
				cmin(tmp,t);
			}
			ret=tmp;
		}
		for(R int i=1;i<=n;++i){
			R int t=Abs(x-a[i].x)+Abs(y-a[i].y);
			if(Max(ret-t,0)!=a[i].h)return -1;
		}
		return ret;
	}
	int main(){
		read(n);
		for(R int i=1;i<=n;++i){
			read(a[i].x);read(a[i].y);read(a[i].h);
		}
		for(R int x=0;x<=100;++x){
			for(R int y=0,h;y<=100;++y){
				if((h=check(x,y))!=-1){
					printf("%d %d %d\n",x,y,h);
					return 0;
				}
			}
		}
		return 0;
	}
}
int main(){
	return Night::main();
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(void) {
	string s;
	cin >> s;
	bool b[26];
	for (int i(0); i < 26; i++) {
		b[i] = true;
	}
	for (int i(0); i < s.size(); i++) {
		b[(int)s[i] - 97] = false;
	}
	for (int i(0); i < 26; i++) {
		if (b[i] == true) {
			cout << (char)(i + 97) << endl;
			break;
		}
		if (i == 25)cout << "None" << endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;
int main(){
	int i,n,k;
	cin >> n >> k;
	if(n==1){
		if(k==0){
			cout << 0 << " " << 0 << " " << 1 << " " << 1 << endl;
		}else{
			cout << -1 << endl;
		}
	}else{
		if(k==0){
			for(i=0;i<(1<<n);i++){
				cout << i << " " << i << " " ;
			}
			return 0;
		}
		if((1<<n)<=k){
			cout << -1 << endl;
		}else{
			cout << 0 << " " << k << " " << 0 << " ";
			for(i=(1<<n) - 1;i>=1;i--){
				if(i==k) continue;
				cout << i << " ";
			}
			cout << k << " ";
			for(i=1;i<=(1<<n) - 1;i++){
				if(i==k) continue;
				cout << i << " ";
			}
			cout << endl;
		}
	}
}
		

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()
 
#define REP(i,s,e)	for(int i=(s); i<(e); i++)
#define rep(i,n)	REP(i,0,n)
#define REPE(i,s,e)	for(int i=s; i>e; i--)
#define repe(i,n)	REPE(i,n,-1)


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<vi> vii;
 
const int IMAX=((1<<30)-1)*2+1;
const int INF=100000000;
const double EPS=1e-10;
//int mod=1000000007
 

//??????????±???????

// ??????????????????????¶????????????????
double add(double a,double b){
	if(abs(a + b) < EPS * (abs(a) + abs(b))) return 0;
	return a + b;
}

// ????¬?????????????????§???????
struct P {
	double x,y;
	P(){}
	P(double x,double y) : x(x), y(y){
	}
	P operator + (P p){
		return P(add(x, p.x), add(y, p.y));
	}
	P operator - (P p){
		return P(add(x, -p.x), add(y, -p.y));
	}
	P operator * (double d){
		return P(x * d, y * d);
	}
	double dot(P p){	// ??????
		return add(x * p.x, y * p.y);
	}
	double det(P p){	// ??????
		return add(x * p.y, -y * p.x);
	}
};

// ???????????§??????
bool cmp_x(const P& p, const P& q){
	if(p.x != q.x) return p.x <q.x;
	return p.y<q.y;
}

// ??????????±???????	
vector<P> convex_hull(P* ps, int n){
	sort(ps, ps + n, cmp_x);
	int k = 0;				//?????????????????°
	vector<P> qs(n * 2);	//?§????????????????
	// ?????´???????????????
	for(int i = 0; i < n; i++){
		while(k > 1 && (qs[k - 1] - qs[ k - 2]).det(ps[i] - qs[k - 1]) <= 0) k--;
		qs[k++] = ps[i];
	}
	// ?????´???????????????
	for(int i = n - 2, t = k; i >= 0; i--){
		while(k > t && (qs[k - 1] - qs[k - 2]).det(ps[i] - qs[k - 1]) <=0 ) k--;
		qs[k++] = ps[i];
	}
	qs.resize(k - 1);
	return qs;
}

const int MAX_N =100;
P ps[MAX_N];
//vector<P> ps(MAX_N);

int main(){
	int n;
	char c;

	while(cin>>n && n>0){
		rep(i,n) cin>>ps[i].x>>c>>ps[i].y;
		cout<<n-convex_hull(ps, n).size()<<endl;
	}
	
}

Measured memory_bytes: 1236
require 'prime'

#約数一覧
def divisors(n)
  n.prime_division.inject([1]) do |ary, (p, e)|
    (0..e).map{ |e1| p ** e1 }.product(ary).map{ |a, b| a * b }
  end.sort
end

A, B = gets.chomp.split(" ").map(&:to_i)

puts divisors(A.gcd(B)).count{|pr| pr.prime?} + 1


Measured memory_bytes: 2556
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<cassert>
#include<sstream>
#include<numeric>
#include<iostream>
#include<algorithm>
#include<functional>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> Vi;
typedef pair<int,int> pii;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=1e5+19;

int A[3][N];
int n,rev[2];
Vi V[2];

int C[N];
void Add(int x){
	for (;x<N;x+=x&-x) C[x]++;
}
int Qry(int x){
	int res=0;
	for (;x;x-=x&-x) res+=C[x];
	return res;
}
ll calc(int t){
	ll res=0;
	memset(C,0,sizeof(C));
	for (int i=V[t].size()-1;~i;i--){
		res+=Qry(V[t][i]+1);
		Add(V[t][i]+1);
	}
	return res;
}

int main(){
	n=IN();
	For(i,0,3) For(j,0,n) A[i][j]=IN()-1;
	For(i,0,3) For(j,0,n){
		if (A[i][j]/3!=A[0][j]/3) return puts("No"),0;
		if ((A[i][j]/3)%2!=j%2) return puts("No"),0;
	}
	For(i,0,n){
		if (A[1][i]%3!=1) return puts("No"),0;
		if (A[0][i]%3!=0) rev[i&1]++;
		V[i&1].pb(A[0][i]/3);
	}
	if (calc(0)%2!=rev[1]%2) return puts("No"),0;
	if (calc(1)%2!=rev[0]%2) return puts("No"),0;
	puts("Yes");
}

Measured memory_bytes: 2428
#include <iostream>
using namespace std;
  
int main()
{
    int sum, a, b, i,t;
      
    while(cin >> a >> b)
   {
  
      sum = a + b;
      i = 1;
      while(1)
      {
          sum = sum / 10;
  
          if(sum == 0)
             break;
  
          i++;
      }
  
      cout << i << endl;
   }
  
   return 0;
}

Measured memory_bytes: 1160
#include <atcoder/dsu>
#include <cstdio>

using namespace std;
using namespace atcoder;

int main() {
    int n, q;
    scanf("%d %d", &n, &q);
    dsu d(n);
    for (int i = 0; i < q; i++) {
        int t, u, v;
        scanf("%d %d %d", &t, &u, &v);
        if (t == 0) {
            d.merge(u, v);
        } else {
            if (d.same(u, v)) {
                printf("1\n");
            } else {
                printf("0\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3472
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

  string s;
  cin >> s;
  if(s == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }
}


Measured memory_bytes: 3648
#include<iostream>

using namespace std;
int S[100000];
int T[100000];

bool serch(int n,int* T,int size){
	for(int i=0;i<size;i++){
		if(T[i]==n)return true;
	}
	return false;
}


int main(){
	int n,q;
	cin>>n;
	for(int i=0;i<n;i++)cin>>S[i];
	cin>>q;
	for(int i=0;i<q;i++)cin>>T[i];
	
	int cnt=0;
	for(int i=0;i<q;i++){
		
		if(serch(T[i],S,n))cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3100
#include <stdio.h>

int main()
{
	int n;
	int buf[10];
	int idx = 0;

	while (scanf("%d", &n) != EOF) {
		if (n == 0) {
			printf("%d\n", buf[--idx]);
		} else {
			buf[idx++] = n;
		}
	}
	return 0;
}

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

#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) {return b < a ? a = b, 1 : 0;}
template<typename T> inline bool chkmax(T &a, T b) {return b > a ? a = b, 1 : 0;}

namespace pb_ds
{   
    namespace io
    {
        const int MaxBuff = 1 << 23;
        const int Output = 1 << 25;
        char B[MaxBuff], *S = B, *T = B;
        #define getc() ((S == T) && (T = (S = B) + fread(B, 1, MaxBuff, stdin), S == T) ? 0 : *S++)
        char Out[Output], *iter = Out;
        inline void flush()
        {
            fwrite(Out, 1, iter - Out, stdout);
            iter = Out;
        }
    }

    template<class Type> inline Type read()
    {
        using namespace io;
        register char ch; register Type ans = 0; register bool neg = 0;
        while(ch = getc(), (ch < '0' || ch > '9') && ch != '-')     ;
        ch == '-' ? neg = 1 : ans = ch - '0';
        while(ch = getc(), '0' <= ch && ch <= '9') ans = ans * 10 + ch - '0';
        return neg ? -ans : ans;
    }

}

using namespace pb_ds;

void File() {
#ifdef zjp_shadow
	freopen ("D.in", "r", stdin);
	freopen ("D.out", "w", stdout);
#endif
}

int main() {

	File();

	int n = read<int>(); read<int>();

	int ans = 0, tot = 0, minv = INT_MAX;

	For (i, 1, n) {
		int val = read<int>();
		chkmin(minv, val);
		if (chkmax(ans, val - minv)) tot = 1;
		else if (ans == val - minv) ++ tot;
	}
	printf ("%d\n", tot);

    return 0;

}


Measured memory_bytes: 2304
n_entradas = int(input())
contador = 0
vetor=[]
while (contador<n_entradas):
    situacao = str(input())
    vetor.append(situacao)
    contador=contador+1    
print('AC x',vetor.count('AC'))
print('WA x',vetor.count('WA'))
print('TLE x',vetor.count('TLE'))
print('RE x',vetor.count('RE'))

Measured memory_bytes: 16280
N,x,y=$<.read.split.map(&:to_i)

ret = [0] * (N+1) # Array.new(N,0)

i = 1
while i <= N
  j = i+1
  while j <= N
    t = [j-i, 1+(j-y).abs+(x-i).abs].min
    ret[t] += 1
    j += 1
  end
  i += 1
end

puts ret[1..-2].map(&:to_s).join("\n")

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

int main() {
    int r, d, x;
    int c;
    
    cin >> r >> d >> x;
    c = x;
    
    for (int i = 1; i <= 10; i++) {
        c = r * c - d;
        cout << c << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<int> T;
vector<double> V;
void input(){
    fast_io();
    cin >> N;
    T = fetch_vec<int>(N);
    V = fetch_vec<double>(N);
}

int solve(){
    for(auto &t:T) t*=2;
    int MaxTime = accumulate(T.begin(),T.end(),0)+2;
    vector<double> left_vec(MaxTime,0);
    vector<double> right_vec(MaxTime,0);
    vector<double> max_vec(MaxTime,0);
    int time = 0;
    for (int i = 0; i < N; i++)
    {
        for (int t = time; t < time+T[i]; t++)
        {
            left_vec[t+1] = min(left_vec[t]+0.5,V[i]);
        }
        time += T[i];
    }

    for (int i = N-1; i >= 0; i--)
    {
        for (int t = time; t > time-T[i]; t--)
        {
            right_vec[t-1] = min(right_vec[t]+0.5,V[i]);
        }
        time -= T[i];
    }
    for (int t = 0; t < MaxTime; t++)
    {
        max_vec[t] = min(left_vec[t],right_vec[t]);
    }
    double ans = 0;
    for (int t = 0; t < MaxTime; t++)
    {
        if(max_vec[t]==max_vec[t+1]) ans += max_vec[t]/2;
        else if(max_vec[t]<max_vec[t+1]) ans += max_vec[t]/2+0.25;
        else if(max_vec[t]>max_vec[t+1]) ans += max_vec[t]/2-0.25;
    }
    DBG(max_vec)
    cout << fixed << setprecision(12) << ans << endl;
    
    



    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 4244
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>

#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<29)
#define LLINF (1LL<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
typedef pair<int, int> P;

ll ans = 0;

void dfs(int n, ll x) {
    if (x == 0)ans+=0;
    else if (n == 0) {
        //cout << n << ' ' << x << ' ';
        //cout << "AAA" << endl;
        ans+=1;
    }
    else if (n == 1) {
        if (x == 1) {
            //cout << n << ' ' << x << ' ';
            //cout << "BBB" << endl;
            ans+=0;
        }
        else if (x == 5) {
            //cout << n << ' ' << x << ' ';
            //cout << "CCC" << endl;
            ans+=3;
        }
        else {
            //cout << n << ' ' << x << ' ';
            //cout << "DDD" << endl;
            ans+=(x-1);
        }
    }
    else if (x == (pow(2, n + 2) - 3)) {
        ans += pow(2, n + 1) - 1;
    }
    else if (x == pow(2, n + 1) - 3 + 2) {
        //cout << n << ' ' << x << ' ';
        //cout << "EEE" << endl;
        ans+=pow(2, n) - 1 + 1;
    }
    else if (x >= pow(2, n + 1) - 3 + 3) {
        //cout << n << ' ' << x << ' ';
        //cout << "FFF ";
        ans += pow(2, n) - 1 + 1;
        //cout << ans << endl;
        dfs(n - 1, x - (pow(2, n + 1) - 3 + 2));
    }
    else {
        //cout << n << ' ' << x << ' ';
        //cout << "GGG" << endl;
        dfs(n - 1, x - 1);
    }
}

int main() {
    int n;
    ll x;
    cin >> n >> x;
    dfs(n,x);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N, W = map(int, input().split())
dp = [0] * (W+1)

for _ in range(N):
    w, v = map(int, input().split())
    for dp_w in reversed(range(W+1)):
        dp_v = dp[dp_w]
        if (dp_w == 0 or dp_v > 0) and dp_w + w <= W:
            dp[dp_w + w] = max(dp[dp_w + w], dp[dp_w] + v)

print(max(dp))

Measured memory_bytes: 41580
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <iomanip>
//#pragma GCC optimize("Ofast")  //デバッグ時にoptimized-outされて邪魔だった
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  invar(int, N);
  invar(string, S);
  
  rep(i, S.size()) {
    S[i] = ((S[i] - 'A') + N) % 26 + 'A';
  }
  
  fin(S);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define here cout<<"here\n"
#define pb push_back
#define mp make_pair
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define pf printf
#define pfi(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
using namespace std;

const ll mod = 1e9+7;

const int MAX = 100005;

ll modexp(ll x, ll n)
{
    if(n==0)
        return 1LL;
    if(n%2==0)
    {
        ll y = modexp(x,n/2)%mod;
        return (y*y)%mod;
    }
    return (x*modexp(x,n-1)%mod)%mod;
}

ll powr(ll x, ll n)
{
    ll ans = 1;
    for(int i=1;i<=n;i++)
        ans=ans*x;
    return ans;
}

int main()
{
    string s;
    cin>>s;
    int n = s.size();
    for(int i=0;i<n;i++)
    {
        int idx = i+1;
        if(idx%2==0)
        {
            if(s[i]=='L'||s[i]=='U'||s[i]=='D')
                continue;
        }
        if(idx%2==1)
        {
            if(s[i]=='R'||s[i]=='U'||s[i]=='D')
                continue;
        }
        return 0*pf("No\n");
    }
    pf("Yes\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  bool flag = true;
  for(int i=0; i<3; i++){
    if(s[i] == s[i+1]){
      flag = false;
      break;
    }
  }
  if(flag){
    cout << "Good" << endl;
  }else{
    cout << "Bad" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main(){
    string s;
    cin >> s;
    if(s.at(0) == s.at(1) && s.at(2) == s.at(3) && s.at(1) != s.at(2) ||
        s.at(0) == s.at(3) && s.at(1) == s.at(2) && s.at(1) != s.at(3) ||
        s.at(0) == s.at(2) && s.at(1) == s.at(3) && s.at(1) != s.at(2)
        ){
        cout << "Yes" << endl; 
    }else{
        cout << "No" << endl;
    }
}

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

int main(){
    int H, W; cin >> H >> W;
    vector<vector<int> > A(H+1, vector<int>(W+1));
    rep(i , 1, H+1) rep(j, 1, W+1) cin >> A[i][j];
    rep(i , 1, H+1) rep(j, 1, W+1) {int t;cin >> t; A[i][j] = abs(A[i][j] - t);}

    bitset<12801> dp[81] = {};
    dp[0][6400] = 1;
    rep(i, 1, H+1){
        rep(j,1,W+1){
            int a = A[i][j];
            dp[j] = ((dp[j-1] | dp[j]) << a) | ((dp[j-1] | dp[j]) >> a);
        }
        dp[0][6400]=0;
    }

    rep(j , 0, 160){
        //cerr << dp[W][6400 + j] << endl;
        if(dp[W][6400 + j]){cout << j << endl; return 0;}
    }
}

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

int main(){
	int n;
	cin >> n;
	for(int i(1);i<=50000;++i){
		double x = i * 1.08;
		if(floor(x) == n){
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 256
a,b = map(int,input().split())
cnt = 0
import math

for i in range(a,b+1):
    if i%10 == math.floor(i/10000)%10 and math.floor(i/10)%10 == math.floor(i/1000)%10:
        cnt = cnt + 1
        
print(cnt)

Measured memory_bytes: 9108
#

import sys
from bisect import bisect
input=sys.stdin.readline

def main():
    N,M,K=map(int,input().split())
    A=list(map(int,input().split()))
    B=list(map(int,input().split()))
    Ar=[0]*(N+1)
    Br=[0]*(M+1)
    for i in range(N):
        Ar[i+1]=Ar[i]+A[i]
    for i in range(M):
        Br[i+1]=Br[i]+B[i]
        
    maxb=0
    for i in range(N+1):
        if maxb<i+bisect(Br,K-Ar[i])-1 and K>=Ar[i]:
            maxb=i+bisect(Br,K-Ar[i])-1
    print(maxb)
        
            
    
    
if __name__=="__main__":
    main()


Measured memory_bytes: 108916
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define int long long
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];

    int nowm = 1000;
    P now = P(0, 1000);
    rep(i, n) {
        int money = now.first*a[i] + now.second;
        chmax(nowm, money);
        P h = P(nowm/a[i], nowm%a[i]);
        chmax(now, h);
    }
    cout << nowm << endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define fr(i,n) for(int i = 0;i<n;++i)
#define fri(i,a,b) for(int i= a;i<=b;++i)
#define fro(i,a,b) for(int i= a;i>=b;--i)
#define debug(P) cout<<#P<<" = "<<P<<endl;
#define fi first
#define se second
#define pb(x) push_back(x)
#define  mp(x,y) make_pair(x,y)
#define endl  "\n"
#define  ii  pair<int,int>
#define  LL  long long
#define  maxm(a,b,c)  max(a,max(b,c))
int q1,q2,q3,a[100010][4],dp[100010][4];

int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n+1;++i)
		for(int j=0;j<4;++j)
		{
			if(i==0 || j==0)
			a[i][j]=0;
			else
			cin>>a[i][j];
		}
dp[1][1]=a[1][1];
dp[1][2]=a[1][2];
dp[1][3]=a[1][3];

for(int i=2;i<=n;i++)
{
	dp[i][1]=max(dp[i-1][2],dp[i-1][3])+a[i][1];
	dp[i][2]=max(dp[i-1][1],dp[i-1][3])+a[i][2];
	dp[i][3]=max(dp[i-1][2],dp[i-1][1])+a[i][3];
}
cout<<max(dp[n][1],max(dp[n][2],dp[n][3]));
}

Measured memory_bytes: 3328
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

#=-------------------------------------  
n = int( input() )

dict = {}
for i in range( n ):
	sorted_input = "".join( sorted( list( input() ) ) )
	if dict.get( sorted_input ) == None:
		dict[ sorted_input ] = 1
	else :
		dict[ sorted_input ] += 1

count = 0
for eachValue in dict.values():
	if eachValue == 1 : continue
	count += cmb( eachValue, 2 )
print( count )


Measured memory_bytes: 18432
#include <iostream>
#include <vector>
using namespace std;
int main(){
  string s;cin>>s;
  vector<char> box;
  for(int i = 0; s.size() > i; i++){
    if(s[i] == 'S')box.push_back(s[i]);
    else{
      if(box.empty() || box.back() == 'T')box.push_back(s[i]);
      else box.pop_back();
    }
  }
  cout << box.size() << endl;
}

Measured memory_bytes: 772
from math import sqrt
q=int(input())
for i in range(q):
  a,b=map(int,input().split())
  c=min(a,b)
  b=max(a,b)
  a=c
  s=int(sqrt(a*b-1))
  if s*s>=a*b:
    s=s-1
  if (s+1)*(s+1)<a*b:
    s=s+1
  if a==b:
    print(2*(a-1))
  elif s*(s+1)<a*b:
    print(a-1+s+(s-a))
  else:
    print(a-1+s+(s-a-1))

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

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

	    String a= gs();
	    String b= gs();

        //System.out.print(N*800-a*200);
        if ((a.equals("H") && b.equals("H")) || (a.equals("D") && b.equals("D"))) {
        	System.out.print("H");
        }else{
        	System.out.print("D");
        }

	   
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
}

Measured memory_bytes: 35468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n,k; cin>>n>>k;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    rep(i,n) a[i]%=k;
    vector<ll> b(n+1,0);
    rep(i,n) b[i+1]=(a[i]+b[i])%k;
    rep(i,n+1){
        b[i]-=i;
        b[i]%=k;
        if(b[i]<0) b[i]+=k;
    }
    //rep(i,9) cout<<b[i]<<' ';
    map<ll,ll> m;
    ll res=0;
    for(ll i=n; i>=0; i--){
        if(i<=n-k) m[b[i+k]]--;
        res+=m[b[i]];
        m[b[i]]++;

    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 15872
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


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

    ll a,b;
    cin >> a >> b;
    if(a> 12) cout << b<<endl;
    else if (a> 5) cout << b/2 << endl;
    else cout << 0 << endl;


    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


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

#define MAX 1000000

int main(){
	int i,j,k,n;
	bool arr[MAX];
		i=MAX; while(i--) arr[i]=true;

	while(scanf("%d", &n)!=EOF){

	for(j=2; j<=n; j++){
		if(arr[j]==true){
		for(k=2; j*k<=n; k++){
			arr[j*k]=false;
		}
		}
	}

	for(j=2, k=0; j<=n; j++) if(arr[j]==true) k++;

	printf("%d\n", k);
	}
 return 0;
}

Measured memory_bytes: 2000
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=20010;
int a[N],b[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) a[i]=i*n,b[i]=(n-i+1)*n;
    for(int i=0;i<n;i++) a[gi()]+=i;
    for(int i=1;i<=n;i++) printf("%d ",a[i]);
    puts("");
    for(int i=1;i<=n;i++) printf("%d ",b[i]);
    return 0;
}

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

map<long long, long long> prime_list(long long n){
  map<long long, long long> ans;
  for(long long i=2;i*i<=n;++i){
    while(n%i==0){
      ++ans[i];
      n=n/i;
    }
  }
  if(n!=1){
    ++ans[n];
  }
  return ans;
}

int main(){
	long long N;
	cin >> N;
	map<long long, long long> memo = prime_list(N);


	long long ans = 0;

	for(auto item: memo) {
		long long num = 0;
		long long idx = 1;
		while(num + idx <= item.second) {
			num += idx;
			idx++;
		}
		ans += idx - 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3600
function main(arg) {
    let n = Number(arg.split("\n")[0])
    let l = arg.split("\n")[1].split(" ").map(x=>Number(x))

    l = l.sort((a,b)=>a-b)
    
    if(n<=2) {
        console.log(0)
    } else {
        let ans=0
        for(let i=0; i<n; i++) {
            for(let j=i+1; j<n; j++) {
                for(let k=j+1; k<n; k++) {
                    if(l[i]!=l[j] && l[j]!=l[k] && l[i]!=l[k] && 
                      l[k] < l[i]+l[j]) {
                        ans++
                    }
                }
            }
        }
        console.log(ans)
    }    
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 32488
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
	int n, m, l;
	int rectangles = 0, lozenges = 0;
	while (scanf("%d,%d,%d", &n, &m, &l) != EOF) {
		if (n * n + m * m == l * l)
			rectangles++;
		else if (n == m)
			lozenges++;
	}
	printf("%d\n%d\n", rectangles, lozenges);
	return 0;
}

Measured memory_bytes: 1188
import numpy as np
import math
import itertools

L, R = (int(i) for i in input().split()) 
if R - L >= 2019: 
  print(0)
else:
  ans = R * (R - 1)
  for x, y in itertools.combinations(range(L, R + 1), 2):
      mod = ((x % 2019) * (y % 2019)) % 2019
      ans = min(mod, ans)
  
  print(ans)

  
    
 
    

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

public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int N = fs.nextInt();
        int min = N + 1, ans = 0;
        for (int i = 0; i < N; i++) {
          int P = fs.nextInt();
          if (P < min) {
            ans++;
            min = P;
          }
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            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;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        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() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 22692
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
	int N, K; string S; cin >> N >> K >> S;
	
	int blockCount = 0;
	char last = 0;
	int ans = 0;
	
	F0R(i, N) {
		if (S[i] != last) {
			last = S[i];
			blockCount++;
		}
		if (S[i] == 'L' && i > 0 && S[i-1] == 'L') ans++;
		if (S[i] == 'R' && i < N-1 && S[i+1] == 'R') ans++;
	}
	
	int half = (blockCount-1)/2;
	
	if (K > half) {
		ans = N-1;
	} else {
		ans += 2*K;
	}
	
	cout << ans << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343


Measured memory_bytes: 512
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n";
#define int long long
#define mod 1000000007

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// int Solution::solve(vector<int> &arr) {

// 	const long long mod = (long long) 1e9 + 7;
// 	long long n = (long long) arr.size();


// }

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, ele;
	cin >> n;
	vector<int> ans(n, 0);
	for (int i = 0; i < n - 1; i++) {
		cin >> ele;
		ans[ele - 1]++;
	}
	for (auto x : ans)
		cout << x << "\n";
	return 0;
}


Measured memory_bytes: 4792
#include <bits/stdc++.h>
using namespace std;
int main(){
    
    int n;
    while(cin>>n,n){
    
        vector <double> a(n);
        double ave=0;
        
        for(int i=0;i<n;i++) cin>>a[i],ave+=a[i];
        
        ave/=n;
        
        double sum=0;
        for(int i=0;i<n;i++) sum+=pow(a[i]-ave,2);
        
        cout<<fixed<<sqrt(sum/n)<<endl;
        
        
    }
    
    return 0;
    
}


Measured memory_bytes: 3264
n,q=map(int,input().split())
s=input()
c=[0 for _ in range(n)]
p=''
d=0
for i in range(n):
  x=s[i]
  if p=='A' and x=='C':
    d+=1
  p=x
  c[i]=d
for i in range(q):
  ans=0
  l,r=map(int,input().split())
  ans=c[r-1]-c[l-1]

  print(ans)


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

int main() {
    int a,b;
    cin>>a>>b;
    int count=0;
    int c =b;
    while(c>0){
        count++;
        c/=10;
    }
    int d =a*pow(10,count)+b;
    for(int i=4;i<=sqrt(d);i++){
        if(i*i==d){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
} 


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

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

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

    vector<ll> v(n);
    rep(i,n) cin >> v[i];

    sort(v.begin(), v.end(),greater<ll>());

    ll ans = 1, cnt = 0;
    while(v.size() >= 4) {
        rep(i,4) {
            if(v[i] - cnt > 0) {
                ans += v[i] - cnt;
            }
        }

        rep(i,4) {
            v.erase(v.begin());
        }

        cnt++;
    }

    rep(i,v.size()) {
        if(v[i] - cnt > 0) {
            ans += v[i] - cnt;
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1228
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let (a, op, b) = read!(i64, String, i64);
    if op == "+" {
        println!("{}", a + b);
    } else {
        println!("{}", a - b);
    }
}


Measured memory_bytes: 4352