akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  ll x = in();
  string str = in<string>();
  int k = 0;
  foreach(i,str){
    if(i=='.')continue;
    k *= 10;
    k += i-'0';
  }
  cout << x * k / 100 << endl;
  return 0;
}


Measured memory_bytes: 3692
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<utility>
#define INF 0x3f3f3f3f
#define PI acos(-1)
#define ll long long
using namespace std;
int main() {
	//std::ios::sync_with_stdio(false);
	double n;
	scanf("%lf", &n);
	double ans;
	ans = n * n * n / 27.0*1.0;
	printf("%.12lf\n", ans);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int count=0;
		for(int i=0; i<n; i++){
			int p=sc.nextInt();
			if(p!=i+1){
				count++;
				if(count>2){
					System.out.println("NO");
					return;
				}
			}
		}
		System.out.println("YES");
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

const ll mod = 1e9+7;
ll n;

int main() {
    cin >> n;
    map<ll, ll> cntmp;
    for(ll i = 2; i <= n; ++i) {
        ll tar = i;
        ll limit = sqrtl(i)+1;
        for(ll j = 2; j <= limit; ++j) {
            ll cnt = 0;
            while(tar%j == 0) {
                cnt++;
                tar /= j;
            }
            cntmp[j] += cnt;
        }
        if(tar != 1) cntmp[tar]++;
    }

    ll ans = 1;
    for(auto mp : cntmp) {
        ans *= (mp.second+1);
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int is_prime1(int);
int is_prime2(int);

int prime[168];

int main()
{
	int input, input_cnt, prime_cnt, cnt;
	int output[30];
	
	/*Make prime table*/
	prime[0] = 2;
	prime_cnt = 1;
	for(cnt = 3; cnt < 1000; cnt += 2)
		if(is_prime1(cnt))
			prime[prime_cnt++] = cnt;
	
	/*Get, calculate input then save in output[]*/
	input_cnt = 0;
	while(scanf("%d", &input) != EOF){
		prime_cnt = 0;
		if(input >= 2)
			prime_cnt++;
		for(cnt = 3; cnt <= input; cnt += 2)
			if(is_prime2(cnt))
				prime_cnt++;
		output[input_cnt++] = prime_cnt;
	}
	
	/*print output[]*/
	for(cnt = 0; cnt < input_cnt; cnt++)
		printf("%d\n", output[cnt]);
	
    return 0;
}

/*Test prime directly*/
int is_prime1(int prime1_input)
{
	int prime1_cnt;
	
	if(prime1_input == 1){
		return 0;
	}
	else if(prime1_input == 2 || prime1_input == 3 || prime1_input == 5 || prime1_input == 7){
		return 1;
	}
	else if((prime1_input % 2) == 0){
		return 0;
	}
	
	for(prime1_cnt = 3 ; prime1_cnt <= (sqrt(prime1_input)); prime1_cnt += 2)
		if(prime1_input % prime1_cnt == 0)
			return 0;
	
	return 1;
}

/*Test prime with prime table*/
int is_prime2(int prime2_input)
{
	int prime2_cnt = 0;
	for( ;prime2_cnt <168; prime2_cnt++){
		if(prime[prime2_cnt] > sqrt(prime2_input))
			break;
		if(prime2_input % prime[prime2_cnt] == 0)
			return 0;
	}
	return 1;
}

Measured memory_bytes: 596
#include <iostream>

using namespace std;

int main() {
	long long int n, k;
	cin >> n >> k;

	long long int ans = 0;

	for (long long int i = 1; i <= n; i++) {
		long long int a = n / i;
		long long int b = i - k;
		if (b > 0) {
			ans += a*b;
		}
		long long int c = n%i;
		if (k == 0) {
			ans += c - k;
		} else if (c - k >= 0) {
			ans += c - k + 1;
		}
		//cout << a*b << ' ' << c - k + 1 << endl;
		//cout << ans << endl;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double C = sc.nextDouble();
		System.out.println(a*(b*Math.sin(C*Math.PI/180.0))/2);
		System.out.println(a+b+Math.sqrt(a*a+b*b-2*a*b*Math.cos(C*Math.PI/180.0)));
		System.out.println(b*Math.sin(C*Math.PI/180.0));
	}
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s=in<string>();
    string t=in<string>();
    vector<char> s_char;
    vector<char> t_char;
    REP(i,SZ(s)){
        s_char.push_back(s[i]);
    }
    
    REP(i,SZ(t)){
        t_char.push_back(t[i]);
    }

    sort(all(t_char),greater<char>());
    sort(all(s_char));
    REP(i,SZ(s)){
        s[i]=s_char[i];
    }
    
    REP(i,SZ(t)){
        t[i]=t_char[i];
    }
    if(s<t){
        cout<<"Yes"<<endl;
        return 0;
    }else{
        cout<<"No"<<endl;
        return 0;
    }

}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	int n,l,ans=0,i,min=100;
	scanf("%d %d", &n,&l);

	for (int i = 0; i < n; i++) {
		ans += (l + i);
		if (abs(l + i) < abs(min))
			min = (l + i);
	}

	
	printf("%d", ans -min);
	//system("pause");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const int MX = 300005;
int n, s[MX], m = 1, a[MX], c = -1, t, b[20];

int main(){
	scanf("%d", &n); b[n]++;
	rep(i,n) m *= 2;
	rep(i,m) scanf("%d", s+i);
	sort(s,s+m, greater<int>());
	rep(i,m) if(s[i] != s[i+1]){
		a[t++] = i-c;
		c = i;
	}
	rep(i,t){
		int ac = 0, u = 0;
		for(int j = n; j >= 0; j--){
			u = ac;
			ac = min(u + b[j], a[i]);
			b[j] = u*2 + b[j] - ac;
		}
		if(ac < a[i]) return 0*puts("No");
	}
	puts("Yes");
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for(int i = 1, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

using namespace std;

vector<vector<ll>> comb(int n, int r) {
  std::vector<vector<long long>> v(n + 1, vector<long long>(n + 1, 0));
  for(int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for(int j = 1; j < v.size(); j++) {
    for(int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  ll v[N];
  REP(i, N) cin >> v[i];

  sort(v, v + N);

  vector<vector<ll>> combs = comb(50, 50);

  ll max = v[N - 1];
  int max_cnt = count(v, v + N, max);
  if(max_cnt == N) {
    ll p = 0;
    for(int i = A; i <= B; i++) {
      p += combs[N][i];
    }
    cout << max << endl;
    cout << p << endl;
    return 0;
  }

  if(B <= max_cnt) {
    ll p = 0;
    for(int i = A; i <= B; i++) {
      p += combs[max_cnt][i];
    }
    cout << max << endl;
    cout << p << endl;
  } else if(A <= max_cnt) {
    ll p = 0;
    for(int i = A; i <= max_cnt; i++) {
      p += combs[max_cnt][i];
    }
    cout << max << endl;
    cout << p << endl;
  } else {
    ll min_value = v[N - A];
    int min_value_cnt = count(v, v + N, min_value);
    int start = N - (upper_bound(v, v + N, min_value - 1) - v);
    ll p = combs[min_value_cnt][start - A];
    reverse(v, v + N);
    double avg = 0.0;
    REP(i, A) { avg += v[i]; }
    avg /= A;
    cout << fixed << setprecision(20) << avg << endl;
    cout << p << endl;
  }
}


Measured memory_bytes: 256
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = ((int)(n) - 1); i >= 0; i--)
#define repn(i, n) for(int i = 1; i <= (int)(n); i++)
#define reprn(i, n) for(int i = ((int)(n)); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define LARGE_PRIME_NUM 1000000007
typedef long long ll;

#include <iostream>
#include <array>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <numeric>
#include <cmath>

using namespace std;

bool compare(pair<pair<string, int>, int> a, pair<pair<string, int>, int> b) {
	if (a.first.first != b.first.first) {
		return a.first.first < b.first.first;
	} else {
		return a.first.second > b.first.second;
	}
}

int main() {
	int n;
	cin >> n;
	vector<pair<pair<string, int>, int>> sp;
	rep(i, n) {
		string s;
		int p;
		cin >> s >> p;
		sp.push_back(make_pair(make_pair(s, p), i + 1));
	}
	sort(all(sp), compare);
	rep(i, n) {
		cout << sp[i].second << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
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);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int h[] = new int[n];
            for (int i = 0; i < n; i++) {
                h[i] = Integer.parseInt(in.next());
            }
            int ans = 0;

            while (true) {
                if (arrmax(h) == 0) break;
                int i = 0;
                while (i < n) {
                    if (h[i] == 0) {
                        ++i;
                    } else {
                        ++ans;
                        while (i < n && h[i] > 0) {
                            --h[i];
                            ++i;
                        }
                    }
                }
            }

            // 出力
            out.println(ans);

        }

        public static int arrmax(int[] arr) {
            int max = -1;
            int res[] = new int[arr.length];
            for (int i = 0; i < arr.length; i++) {   //(6)
                res[i] = arr[i];
            }
            Arrays.sort(res);
            return res[res.length - 1];
//        for (int i = 1; i < arr.length; i++) {
//            int v = arr[i];
//            if (v > max) {
//                max = v;
//            }
//        }
//        return max;
        }

    }
}



Measured memory_bytes: 24404
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;
const ll x18=1e18;
int main(){
  int n; cin >>n; ll m=1;
  vector<ll>v(n);
  for(int i=0; i<n; i++){
    cin >>v[i];
    if(!v[i]){cout <<0; return 0;}
  }
  for(int i=0; i<n; i++){
    if(v[i]<=x18/m) m*=v[i];
    else{cout <<-1; return 0;}
  }
  cout <<m;
return 0;}

Measured memory_bytes: 4024
#include<iostream>
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>

using namespace std;

long long ans = 0;
vector<int> x;
vector<vector<long long>> dp;//[i][j]i種類でj枚つかって0になる個数
int n, a;

int main() {
	cin >> n >> a;
	x.resize(n);
	dp.resize(n + 1);
	int Max = 0;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		x[i] -= a;
		if (Max < x[i])
			Max = x[i];
	}
	dp[0].resize(2 * n*Max + 1);
	dp[0][n*Max] = 1;
	for (int i = 1; i <= n; i++) {
		dp[i].resize(2*n*Max + 1);
		for (int j = 0; j <= 2*n*Max; j++) {
			if (i == 0 && j != n*Max)
				dp[i][j] = 0;
			else if(i > 0){
				if (j - x[i - 1] < 0 || j - x[i - 1] > 2 * n*Max)
					dp[i][j] = dp[i - 1][j];
				else
					dp[i][j] = dp[i - 1][j] + dp[i - 1][j - x[i - 1]];
			}
		}
	}
	cout << dp[n][n*Max] - 1 << endl;
//	cin >> n;
	return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>

int main(){

  int H, W, i=0,k=0;

  while(1){
    scanf("%d%d",&H,&W);
    if(H+W==0) break;

    for(i=0;i<H;++i){
      if(i==0 || i==H-1){
	for(k=0;k<W;++k){
	  printf("#");
	}
      printf("\n");
      }
      else {
 	for(k=0;k<W;++k){
	  if(k==0 || k==W-1){
	    printf("#");
	  }
	  else {
	    printf(".");
	  }
	}
      printf("\n");
      }
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2688
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll N , M;
  cin >> N >> M;
  if(N > M)
    swap(N,M);
  if(N == 1){
    if(M == 1)
      cout << 1 << endl;
    else
      cout << N*M - 2 << endl;
  }else{
    cout << (N-2)*(M-2) << endl;
  }
    
  
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char str[] = sc.next().toCharArray();
    int count = 0;
    if (str[0] != 'A' || Character.isUpperCase(str[1]) || Character.isUpperCase(str[str.length-1])){
        System.out.println("WA");
        return;
    }
    for (int i=2 ; i < str.length-1; i++){
        if(Character.isUpperCase(str[i]) && str[i] =='C'){
            count++;
        }
    }
    System.out.println(count==1?"AC":"WA");
  }
}

Measured memory_bytes: 25044
# C
import math
#A:短針,B:長針,H:短針の位置,M:長針の位置
A,B,H,M = map(int,input().split(' '))
rad = abs((H*30+M/2)-M*6)
rad = math.radians(min(rad,360-rad))
print('{:.20f}'.format((A**2 + B**2 - 2*A*B*math.cos(rad))**0.5))

Measured memory_bytes: 9572
N = 1000000
arr = [1] * N
arr[0] = 0
arr[1] = 0

2.upto(N / 2){|i|
	if arr[i] == 1
		(i**2).step(N, i){|j|
			arr[j] = 0
		}
	end
}

2.upto(N){|i|
	arr[i] += arr[i-1]
}

while n = gets
	puts arr[n.to_i]
end

Measured memory_bytes: 10084
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li      int32_t
#define lli     long long
#define ulli unsigned long long

#define pn           printf("\n")
#define nl           cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))

#define pb      push_back
#define pob     pop_back
#define itr     iterator
#define sz()    size()
#define szof    sizeof
#define lb      lower_bound
#define ub      upper_bound
#define mp      make_pair
#define vlli    vector<lli>
#define plli    pair<lli,lli>
#define vplli   vector<plli >
#define F       first
#define S       second
#define Dup     erase(unique(V.begin(),V.end()),V.end())

#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound

#define ALL(V)  V.begin(),V.end()

#define MX1     100000
#define MX2     1000000
#define MX3     10000
#define mod     1000003
#define Inf     1000000000000000
#define MAX 999999999


using namespace std;




int main(){
	int n;
	scanf("%d",&n);
	int num[n],temp,ans = 0;
	
	for(int i=0;i<n;i++){
		scanf("%d",&num[i]);
	}
	
	for(int i=0;i<n-1;i++){
		if(num[i] == i+1){
			temp = num[i];
			num[i] = num[i+1];
			num[i+1] = temp;
			ans++;
		}
	}
	if(num[n-1]==n){
		ans++;
	}
	cout<<ans<<endl; 
}

Measured memory_bytes: 640
#include <stdio.h>

int main(){
	int n, a,b,c,d, cnt;
	while(scanf("%d",&n)>0){
		cnt=0;
		for(a=0;a<=9;a++)
		for(b=0;b<=9;b++)
		for(c=0;c<=9;c++)
		for(d=0;d<=9;d++){
			if(a+b+c+d==n)cnt++;
		}
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<time.h>
#pragma GCC optimize(2)
using namespace std;
long long n;
string s="";
long long r;
int main()
{
	ios::sync_with_stdio(0);
	cin>>n;
	while(n--)
	{
		r=n%26;
		n/=26;
		s+=char('a'+r);
	}
	reverse(s.begin(),s.end());
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3568
#include<iostream>
#include<algorithm>
#include<iomanip>
using lint=int64_t;
using namespace std;

int Cnt(lint *ar,int l,int r,lint val)
{
	int ret=0;
	for(int i=l;i<=r;i++)
		if(ar[i]==val)
			ret++;

	return ret;
}

lint com[55][55];

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


	int N,A,B;
	lint v[55]={};

	cin >> N >> A >> B;
	for(int i=0;i<N;i++)
		cin >> v[i];
	
	sort(v,v+N,greater<lint>());

	double ave=0;
	for(int i=0;i<A;i++)
		ave+=(double)v[i]/A;

	lint ans=0;
	if(v[0]==v[A-1])
	{
		int cnt=Cnt(v,0,N-1,v[0]);
		for(int i=A;i<=min(B,cnt);i++)
			ans+=com[cnt][i];
	}
	else
	{
		int cnt=Cnt(v,0,N-1,v[A-1]);
		int acnt=Cnt(v,0,A-1,v[A-1]);
		ans=com[cnt][acnt];
	}

	cout << fixed << setprecision(10);
	cout << ave << endl;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
P = [int(x) for x in stdin.readline().rstrip().split()]
par = [i for i in range(N+1)]
rank = [0] * (N+1)

def find(x):
    if par[x] == x:
        return par[x]
    else:
        par[x] = find(par[x])
        return par[x]

def union(x,y):
    x = find(x)
    y = find(y)
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[x] = y
        if rank[x] == rank[y]:
            rank[x] += 1

def check_same(x,y):
    return find(x) == find(y)

for _ in range(M):
    x,y = [int(x) for x in stdin.readline().rstrip().split()]
    union(x,y)
ans = 0
for i in range(1,N+1):
    if find(i) == find(P[i-1]):
        ans += 1
print(ans)

Measured memory_bytes: 13812
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<ll> &v) {
    std::for_each(v.begin(), v.end(), [](ll x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    cin >> N;
    vector<int> a(N - 1), b(N - 1);
    vvl edge(N);
    REP(i, N - 1) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        edge[b[i]].push_back(a[i]);
        edge[a[i]].push_back(b[i]);
    }
    vector<pair<int, int>> res;
    REP(i, N) {
        res.push_back(make_pair(-edge[i].size(), i));
    } //サイズが大きいものにじゅんになる番号
    sort(res.begin(), res.end());
    vl c(N);
    REP(i, N) { cin >> c[i]; }
    //一番大きい数字以外いけそう
    sort(c.begin(), c.end());
    ll sum = accumulate(c.begin(), c.end(), 0LL);
    sum -= c[N - 1];
    cout << sum << endl;
    reverse(c.begin(), c.end());
    // cを降順にソートする
    //スターになるべくおおきな数字を割り当てる
    int star = res[0].second;
    queue<int> que;
    que.push(star);
    vector<ll> ans(N, 0);
    ans[star] = c[0];
    int cnt = 0;
    while(!que.empty()) {
        int v = que.front();
        que.pop();
        for(int nv : edge[v]) {
            if(ans[nv] == 0) {

                cnt++;
                ans[nv] = c[cnt];
                que.push(nv);
            }
        }
    }
    print(ans);
    cout << endl;
}

Measured memory_bytes: 1280
def rec(i, g, count, rem):
    global ans
    if i == D:
        # 総得点がGを超えていなければ、remの中の最高配点の問題を解く
        if g < G:
            # 解く問題
            use = max(rem)
            c = min(pc[use-1][0], -(-(G-g) // (use*100)))
            count += c
            g += use*100 * c
            
        if g >= G:
            ans = min(ans, count)
    else:
        # 全部解かない
        rec(i+1, g, count, rem)
        # 全部解く
        rec(i+1, g+(i+1)*100*pc[i][0]+pc[i][1], count+pc[i][0], rem-{i+1})

# 入力
D, G = map(int, input().split())
pc = [[int(i) for i in input().split()] for j in range(D)]
# 解いてない問題リスト
rem = set(range(1, D+1))
ans = float("inf")

rec(0, 0, 0, rem)

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int w[300005],e[300005];
int main(void){
    int n;string s;
    cin>>n>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='W'){
            w[i]+=1;
        }else{
            e[i]+=1;
        }
        if(i!=0)w[i]+=w[i-1];
        if(i!=0)e[i]+=e[i-1];
    }
    //for(int i=0;i<n;i++)cout<<w[i]<<" "<<e[i]<<endl;
    int ans=99999999;
    for(int i=0;i<n;i++){
        int b,c;
        b=w[i];
        c=e[n-1]-e[i];
        if(s[i]=='W')b--;
        ans=min(ans,b+c);
        //if(ans==b+c)check=i;
        //cout<<ans<<" "<<b-c<<endl;
    }
    cout<<ans<<endl;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define cinv(n,vec) V vec(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t make_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a));reverse(all(a))
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (ll)(a.size())
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define cont const auto
#define fi first
#define se second
#define V vector
#define P pair
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
#define PQ priority_queue
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<PL> VP;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

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

  int d,g;
  cin>>d>>g;
  VL p(d),c(d);
  rep(i,d)cin>>p[i]>>c[i];
  
  int ans=(1<<28);
  for(int bit=0;bit<(1<<d);++bit){
    int psum=0,solved=0,msb=0;
    for(int show=0;show<d;++show){
      if((bit>>show)&1){
        psum+=(show+1)*100*p[show]+c[show];
        solved+=p[show];
      }
      else{
        msb=show;
      }
    }
    if(psum<g){
      int dif=g-psum;
      int need=(dif-1)/(100*(msb+1))+1;
      if(need>p[msb])continue;
      psum+=need*(msb+1)*100;
      solved+=need;
    }
    chmin(ans,solved);
  }
  out(ans);

  
  
  
  return 0;
}



Measured memory_bytes: 256
S = input()

n = len(S)
ans = n

for i in range(n-1):
    if S[i] != S[i+1]:
        ans = min(ans, max(n-i-1, i+1))

S = S[::-1]
for i in range(n-1):
    if S[i] != S[i+1]:
        ans = min(ans, max(n-i-1, i+1))

print(ans)

Measured memory_bytes: 9112
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n, k; cin >> n >> k;
    ll ans = 0;
    // bを固定して計算
    for(ll b=k+1; b<=n; b++){
        ll quotient = n/b;
        ll remainder = n%b;
        ans += quotient*max(0LL, b-k) + max(0LL, remainder-k+1);
    }
    if(k == 0) ans = n*n;
    cout << ans << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
ans = []
for m in range(M):
    ans.append(input().split())

ac = [0 for n in range(N)]
wa = [0 for n in range(N)]
w = 0
for a in ans:
    if ac[int(a[0])-1] == 1:
        continue
    else:
        if a[1] == "AC":
            ac[int(a[0])-1] = 1
            w += wa[int(a[0])-1]
        else:
            wa[int(a[0])-1] += 1
        
print(sum(ac), w)

Measured memory_bytes: 33900
#include<iostream>
using namespace std;
int main(){
	long long a,b,x,n,m;
	cin>>a>>b>>x;
	if(a%x==0)
	n=a/x;
	else n=a/x+1;
	m=b/x;
	cout<<m-n+1<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) std::cin >> a[i];
    std::sort(a.rbegin(), a.rend());
    std::cout << a[0] << " ";
    int ma = 0, r = 0;
    for (int i = 1; i < n; i++) {
        int v = std::min(a[i], a[0] - a[i]);
        if (ma < v) {
            r = a[i];
            ma = v;
        }
    }
    std::cout << r << std::endl;
    return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  //vector<vector<P> > vp(N, vector<P>(N));
  llvec x(N), y(N);
  map<P, ll> cnt;
  rep(i, N){
    cin >> x[i] >> y[i];
  }
  rep(i, N){
    rep(j, N){
      if(i==j)continue;
      //vp[i][j].push_back({x[i]-x[j], y[i]-y[j]});
      cnt[{x[i]-x[j], y[i]-y[j]}]++;
    }
  }

  ll cand=0;
  P dist;
  for(auto imp:cnt){
    if(cand<imp.second){
      cand = imp.second;
    }
  }

  cout << N - cand;
  return 0;
}


Measured memory_bytes: 384
import java.util.*;
 
public class  Main {
	
  public static void main (String[]args){
    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    
    int [] a = new int [N];
    
    for (int i =0 ;i<N ;i++){
      	// 入室時の人数を記録したものを配列に格納
    	a[i] = sc.nextInt();	
    }
    
    int[]ans = new int [N];
    
    for (int i = 0 ; i < N ;i++){
        // 記録配列に順次アクセス→記録時人数に当たる配列番号にその時の出席番号（つまりスコープ内のi+1）を入力
    	ans [a[i]-1] = i + 1; 
    }

    for(int i:ans){
        System.out.println(i);
    }
    
    
  }  
}

Measured memory_bytes: 61356
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it!= v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

random_device seed_gen; mt19937_64 mtrand(seed_gen());
#define MOD 1000000007
//////////////////////////////////////////

int main(){
  ini(a,b,c);
  out((a-c)*(c-b)>=0 ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Ti4 tuple<int, int, int, int>
#define Tlll tuple<ll, ll, ll>
#define PI 3.141592653589793

int main() {
    int n;
    while (cin >> n) {
        if (n == 0) return 0;
        
        int ans = 0;
        for (int i = 1; i <= 500; i++) {
            int s = 0, cnt = 0;
            for (int j = i; s < n; j++) {
                s += j;  cnt++;
            }
            if (s == n && cnt > 1) ans++;
        }
        cout << ans << endl;

    }
}



Measured memory_bytes: 3016
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 100011

const int bits = 15;
const int limit = 1 << bits;

int n, i, x, y, z, ans;
vector< pair<int, int> > list[maxN];
int dp[limit];
priority_queue< pair<int, int>, vector< pair<int, int> >, greater< pair<int, int> > > H;
int tp;

void pre() {
    int i, j, to, aux, cnt = 0;

    for (i = 0; i < limit; i++) dp[i] = bits + 1;
    dp[0] = 0;
    H.push(mp(0, 0));

    while (!H.empty()) {
        int conf = H.top().second;
        int cost = H.top().first;
        H.pop();

        if (dp[conf] != cost) continue;
        cnt++;

        for (i = 0; i < bits; i++) {
            for (j = 0; j < bits; j++) {
                if (i == j) continue;
                to = conf ^ (1 << i) ^ (1 << j);

                aux = 1 << (((i + 1) ^ (j + 1)) - 1);
                if (conf & aux) continue;
                to ^= aux;

                if (dp[to] > dp[conf] + 1) {
                    dp[to] = dp[conf] + 1;
                    H.push(mp(dp[to], to));
                }
            }

            to = conf ^ (1 << i);
            if (dp[to] > dp[conf] + 1) {
                dp[to] = dp[conf] + 1;
                H.push(mp(dp[to], to));
            }
        }
    }

    //for (i = 0; i < 256; i++) cerr << dp[i] << ' ';
    //cerr << '\n';

    cerr << limit - cnt << '\n';
}

void dfs(int node, int root, int need) {
    int act = 0;

    for (auto to : list[node])
        if (to.first != root)
            dfs(to.first, node, to.second), act ^= to.second;

    if (node != 1 && act != need)
        tp ^= ((1 << (act ^ need)) >> 1), ans++;
}

int main()
{
  //  freopen("test.in","r",stdin);

    cin >> n;
    pre();
    for (i = 1; i < n; i++) {
        cin >> x >> y >> z;
        x++; y++;
        list[x].pb(mp(y, z));
        list[y].pb(mp(x, z));
    }

    dfs(1, 0, 0);
    ans += dp[tp];

    if (ans % 1) cerr << "Error";
    cout << ans / 2 << '\n';


    return 0;
}


Measured memory_bytes: 13436
import numpy as np
H, W = (int(x) for x in input().split())
C = np.array([[int(x) for x in input().split()] for _ in range(10)])
A = [[int(x) if int(x) >= 0 else 1 for x in input().split()] for _ in range(H)]
from scipy.sparse.csgraph import dijkstra
C = dijkstra(C,directed=True) #有向グラフの経路圧縮（ダイクストラ法）
ans = sum(sum(C[x,1] for x in A))
print(int(ans))

Measured memory_bytes: 38212
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll N;
  std::cin >> N;
  std::vector<ll> A(N);
  range(i, N) std::cin >> A[i];
  sort(A.begin(), A.end());
  range(i, N/2){
    if(A[2*i] + A[2*i+1]<=0) {
      A[2*i] *= -1;
      A[2*i+1] *= -1;
    }
  }
  ll ans = 0;
  range(i, N) ans += A[i];
  std::cout << ans << '\n';
  return 0;
}


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


int main(){


    int n, i, a;

    set<long long> s;
   

    cin >> n;


    for( i = 0 ; i < n ; i = i + 1 ){

         cin >> a;

         if( s.count(a) ) s.erase(a);

         else s.insert(a);

         }


    cout << s.size() << endl;


    return 0;

    }

Measured memory_bytes: 4864
#include <iostream>
#include <vector>

using namespace std;

int main(void) {

	int n;
	//vector<int> p(n);
	int p[200000];
	int min;
	int count = 0;

	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> p[i];
	min = p[0];

	for (int i = 0; i < n; i++) {
		
		if (p[i] <= min) {
			count++;
			min = p[i];
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << 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; }

int main(){
  ll s, w;
  cin >> s >> w;
  if(w>=s){
    print("unsafe");
  }
  else{
    print("safe");
  }
}


Measured memory_bytes: 3624
A,B,K = map(int,input().split())

if B-A > K:
    ax = [i for i in range(A,A+K)]
    bx = [i for i in range(B-K+1,B+1)]
    sum = sorted(list(set(ax + bx))) 
else:
    sum = [i for i in range(A,B+1)]

for i in sum:
    print(i)



Measured memory_bytes: 9004
#include<string>
#include<iomanip>
#include<iostream>
#include<math.h>
using namespace std;

int main() {
	double a, b;
	long double sum = 0;
	int pown;

	cin >> a >> b;

	
	for (int i = 0; i < a; i++)
	{
		pown = ceil(log2(b / (i + 1)));
		if (pown < 0)
			pown = 0;
		sum += (1 / a) * powf(0.5, pown);
	}
	cout << setprecision(12) << sum << endl;

	return 0;
}

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

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


int main()
{
    int N;
    cin >> N;
    vector<vector<int>> A(N, vector<int>(N-1));
    REP(i, N){
        REP(j, N-1){
            cin >> A[i][j];
            --A[i][j];
        }
    }

    int ans = 0;
    vector<int> next_game(N, 0);
    REP(n, N*(N-1)/2){
        vector<bool> in_game(N, false);
        REP(i, N){
            if(next_game[i] == N-1 or in_game[i]) continue;
            int enemy = A[i][next_game[i]];
            if(in_game[enemy]) continue;
            if(A[enemy][next_game[enemy]] == i){
                in_game[i] = in_game[enemy] = true;
                ++next_game[i], ++next_game[enemy];
            }
        }
        ++ans;
        if(ans > 1e+5){
            if(accumulate(next_game.begin(), next_game.end(), 0) > 100*N)
                cout << N*(N-1)/2 << endl;
            else cout << -1 << endl;
            return 0;
        }
        if(accumulate(next_game.begin(), next_game.end(), 0) == N*(N-1)) break;
    }
    bool ok = true;
    REP(i, N){
        if(next_game[i] != N-1){
            ok = false;
            break;
        }
    }
    if(ok) cout << ans << endl;
    else cout << -1 << endl;
    
    return 0;
}

Measured memory_bytes: 6272
/// However long the night,
///     The dawn will break
/// ICPC next year

#include<bits/stdc++.h>
using namespace std ;
const int N = 1e5+5 ;

int n ,k ,q ,x ,cnt[N] ;
int main(){
    cin >> n >> k >> q ;
    fill(cnt,cnt+n,k-q);
    while(q--){
        scanf("%d",&x);
        ++cnt[x-1];
    }
    for(int i=0;i<n;++i) puts(cnt[i]<=0?"No":"Yes");
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define debugArray(x, n)                                      \
  cerr << __LINE__ << ": " << #x << " = {";                   \
  for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];                   \
  cerr << "}" << '\n'
#define debugMatrix(x, h, w)                                         \
  cerr << __LINE__ << ": " << #x << " =\n";                          \
  for (long long hoge = 0; (hoge) < (long long)(h); ++(hoge)) {      \
    cerr << ((hoge ? " {" : "{{"));                                  \
    for (long long fuga = 0; (fuga) < (long long)(w); ++(fuga))      \
      cerr << ((fuga ? ", " : "")) << x[hoge][fuga];                 \
    cerr << "}" << (hoge + 1 == (long long)(h) ? "}" : ",") << '\n'; \
  }
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#define debugMatrix(x, h, w) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int N;
  cin >> N;
  vector<int> tree[N];
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  int root = 0;
  for (int i = 0; i < N; i++)
    if (tree[i].size() > 1) {
      root = i;
      break;
    }
  int par[N];
  int depth[N];
  function<void(int, int, int)> dfs = [&](int v, int p, int d) {
    par[v] = p;
    depth[v] = d;
    for (int u : tree[v])
      if (u != p) dfs(u, v, d + 1);
  };
  dfs(root, -1, 0);
  int idx[N];
  iota(idx, idx + N, 0);
  sort(idx, idx + N, [&](int l, int r) { return depth[l] > depth[r]; });
  int color[N];
  bool takahashi = false;
  for (int v : idx) {
    int sz = tree[v].size();
    if (par[v] != -1) sz--;
    for (int u : tree[v])
      if (u != par[v]) {
        if (color[u] == 1) sz--;
      }
    if (sz > 1) {
      takahashi = true;
      break;
    }
    if (sz == 1) {
      color[v] = 1;
    } else {
      color[v] = -1;
    }
    if (v == root) {
      if (color[v] == -1) {
        takahashi = true;
        break;
      }
    }
  }
  cout << (takahashi ? "First" : "Second") << '\n';
  return 0;
}


Measured memory_bytes: 10676
/**
*
* Author: MARS
* Lang: GNU C++14
*
**/

#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >

typedef unsigned long long ull;
typedef long double ldbl;
typedef long long ll;
typedef double dbl;

const ldbl E = 2.71828182845904523536;
const ldbl pi = acos(-1);
const dbl eps = 1e-9;
const ll mod = 1e9+7;
const ll inf = 1LL<<30;

/** /////////// ** Code ** /////////// **/

const int N=200200;
int a[N];

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

    for(int i=0 ; i<n ; i++){
        if(a[i] > i){
            printf("-1");
            return 0;
        }
    }

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

        if(a[i] == a[i-1]+1) ans++;
        else ans+=a[i];
    }

    printf("%lld",ans);

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
string s;
string p[50005];
int k, cnt;
int main()
{
#ifdef _noname
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin >> s;
	scanf("%d", &k);
	cnt = 0;
	for (int i = 0; i < s.size(); i++)
		for (int j = 1; j <= 5 && i + j <= s.size(); j++)
			p[++cnt] = s.substr(i, j);
	sort(p + 1, p + cnt + 1);
	cnt = unique(p + 1, p + cnt + 1) - p + 1;
	cout << p[k] << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
#define asn ans
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;

int main() {
	int n, d, x; CI n >> d >> x;
	vector<int> a(n); CI a;
	int ans = x+n;

	REP(i, n) {
		int tmp = 1+a[i];
		while (tmp <= d) {
			ans++;
			tmp += a[i];
		}
	}

	CO ans EN;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;

const ll MOD = 998244353;

ll DP[3030][3030];

//A の部分集合 T、Tの部分集合U で数える
int main(){
  int N, S;
  cin >> N >> S;
  vector<ll> A(N);
  REP(i,N) cin >> A[i];

  DP[0][0] = 1;
  REP(i,N) REP(j,S+1) {
    // Ai が T に選ばれない場合
    DP[i+1][j] += DP[i][j];
    // Ai が T には選ばれているけど、Uには選ばれてない場合
    DP[i+1][j] += DP[i][j];
    DP[i+1][j] %= MOD;
    // Ai が選ばれた場合
    if ( A[i] + j <= S )
      DP[i+1][j+A[i]] += DP[i][j];
    DP[i+1][j] %= MOD;
  }
  cout << DP[N][S] << endl;
}

Measured memory_bytes: 74608