akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

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

int main(void){
  bool ttt[31]={0};
  REP(i,30){
    int tmp;
    cin>>tmp;
    ttt[tmp]=true;
  }
  for(int i=1; i<31; i++){
    if(ttt[i]==false){
      cout<<i<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::cmp::max;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());

    let a = scan.read::<i64>();
    let b = scan.read::<i64>();

    println!("{}", max(a - b * 2, 0));
}

// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 4352
from collections import Counter
n = int(input())
a = sorted(map(int, input().split()))
c = Counter(a)
s = set()
for i in range(n):
    if a[i] in s:
        continue
    elif c[a[i]] >= 2:
        s.add(a[i])
    for j in range(2,10**6//a[i]+1):
        s.add(a[i]*j)
print(sum(not (ai in s) for ai in a))

Measured memory_bytes: 103532
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define int long long

using namespace std;

const int N = 300707;
int a, b, n;
string s;
signed main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("diameter.in", "r", stdin);
    //freopen("diameter.out", "w", stdout);
    cin >> n;
    cin >> s;
    int l = s.size();
    if (l % 2 == 0){
        int t = l / 2;
        for (int i = t; i < s.size(); i++){
            if (s[i] != s[i - t]){
                cout <<"No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
        return 0;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a<=c&&a+b>=c) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <set>
#include <cstdio>
#include <vector>
#include <iostream>
#include <utility>
#include <queue>
#include <map>

#define fir first
#define sec second
#define sz(s) (s).size()
#define pb push_back
#define get(n) scanf("%d",&n);
#define gets(s) string s;cin >> (s);
#define prfi(n) printf("%d", &n);
#define prfd(n) printf("%lf", &n);
#define All(s) (s).begin(), (s).end()
#define rep(i,j) for(int (i)=0;(i)<(j);(i)++)
#define For(i,j,k) for(int (i)=(j);(i)<(k);(i)++)
#define repd(i,j) for(int (i)=(j);(i)>=0;(i)--)
#define Ford(i,j,k) for(int (i)=(j);i>=(k);i--)
#define vfor(c,v) for(auto (c): v)
#define dump(x)  std::cout << #x << " = " << (x) << std::endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using ll = long long;
using pii = std::pair<int,int>;
using vi = std::vector<int> ;
using vvi = std::vector<vi> ;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vd = std::vector<double> ;
using vvd = std::vector<vd> ;
using qi = std::queue<int> ;
using vpii = std::vector<std::pair<int, int> >;
using namespace std;

const int Mod = (1e9) + 7;
const int max_n = 3 * (1e5) + 1;
const int max_m = 83 * (1e5) + 1;
const int INF = 1e9 + 19;
const ll INFL = 1e18 + 19;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
//_____________________________________Templates_________________________________________//

template<class T1, class T2> inline void chmin(T1 &a, T2 b){if(a > b) a = b;}
template<class T1, class T2> inline void chmax(T1 &a, T2 b){if(a < b) a = b;}

//mainly use for dynamic prog
template<class T1, class T2>
void update(T1 &a, T2 b){
  a += b;
  if(a > Mod) a %= Mod;
}

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}
//_____________________　following sorce code_________________________//
int n,k;ll m;
//vvll dp(400, vll(400));
string S;
vll cost(1 << 16);
int a,b,c;
int h,w;
vi v;
vll u;

bool check(int x){
  int idx = 0;
  ll sum = 0;
  ll res = 0;
  rep(i,n){
    while(idx < n && sum < k){
      if(v[idx] <= x)sum++;
      idx++;
    }
    //dump(res);
    if(sum >= k)res += n - idx + 1;
    if(v[i] <= x)sum--;
  }
  //OUT(res);
  return res >= m;
}

int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  IN(n,k,m);
  v = vi(n);
  rep(i,n)IN(v[i]);
  int idx = 0;
  int l = 0, r = n+1;
  while(l+1<r){
    int c = (l+r)/2;
    if(check(c))r = c;
    else l = c;
  }
  //bool ok = check(3);
  //if(ok)OUT(-1);
  cout << r << endl;
  //cout << fixed << setprecision(15) << ans << endl;
  return 0;
}


Measured memory_bytes: 4156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int inf = 1000000000;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(b*d, (max(b*c, (max(a*c,a*d)))));
    

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {
    long long N; 
    long long ans;
    cin >> N;
    if(N==1){
        ans = 0;
    }
    else if(N==2){
        ans = 1;
    }
    else{
        ans = N * (N-1) / 2;
    }
    cout << ans << endl; 
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    long long a,b,x,z,c;
    cin>>a>>b>>x;
    z=b/x;
    if(a==0)
        cout<<z+1;
    else
    {
        c=(a-1)/x;
        cout<<z-c;
    }
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const long long LINF = 1e18 + 3141;

void solve(){
    string s, t;
    cin >> s;
    string cur = "";
    int n = (int)s.size();
    
    for(int i = n - 1; i >= 0; --i) {
        cur = s[i] + cur;
        if(cur.size() == 8) {
            cout << "NO";
            return;
        }else {
            if(cur == "dream"){
                cur = "";
            }else if(cur == "dreamer") {
                cur = "";
            }else if(cur == "erase") {
                cur = "";
            }else if(cur == "eraser") {
                cur = "";
            }
        }
    }
    if(cur != "") {
        cout << "NO";
    }else{
        cout << "YES";
    }
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd_ll(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int abs(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
ll fiv(ll n){
  if(n==0){
    return 1;
  }
  else if(n==1){
    return 1;
  }
  return fiv(n-1)+fiv(n-2);
}
ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

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

}





Measured memory_bytes: 2560
import sys

if __name__ == "__main__":
    N = int(input())
    X = []
    for _ in range(N):
        x, l = [int(x) for x in input().split(" ")]
        X.append((x - l, x + l))

    X.sort(key=lambda x: x[1])

    count = 0
    max_high = -sys.maxsize
    for low, high in X:
        if max_high <= low:

            count += 1
            max_high = high
    print(count)


Measured memory_bytes: 87092
//PseudoName

    #pragma GCC optimize("O3")
    #include <bits/stdc++.h>
/*
	#include <ext/pb_ds/assoc_container.hpp>
	#include <ext/pb_ds/tree_policy.hpp>
	using namespace __gnu_pbds;
	template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/
    #define FOR(i,n) for(i=0;i<n;i++)
    #define FOR1(i,n) for(i=1;i<=n;i++)
    #define FOR2(I, A, B) for (int I = (A); I <= (B); ++I)
    #define pb push_back
    #define unique_sort(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
    #define print(v) for(auto it:v)cout<<it<<" ";cout<<endl
    #define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define endl "\n"
    #define min3(a,b,c) min(a,min(b,c))
    #define forr(n) for(int i=0;i<n;i++)
    #define frr(n) for(int i=1;i<=n;i++)
    #define MAX 200005
    #define inf 200008

    using namespace std;

    typedef long long ll;
    typedef long li;
    typedef vector<int> vi;
    typedef vector<ll> vli;
    typedef vector<vi> vvi;
    typedef vector<vli> vvli;
    typedef pair<int,int> pi;
    typedef pair<ll,ll> pli;
    typedef vector<pi> vpi;
    typedef vector<pli> vpli;



    bool pal(string s)
    {
        string re=s;
        reverse(re.begin(),re.end());
        return re==s;
    }
    int main() {
        fast();
        string s;
        cin>>s;
        int n=s.length();
        int fr=(n-1)/2,sc=(n+3)/2;
      //  cout<<pal(s.substr(0,fr))<<endl;
        //cout<<s.substr(sc-1,n-sc+1)<<endl;
        //cout<<pal(s)<<endl;


        if(pal(s) && pal(s.substr(0,fr)) && pal(s.substr(sc-1,n-sc+1)))cout<<"Yes\n";
        else
            cout<<"No\n";


    }


Measured memory_bytes: 256
str = gets.chomp
be_str = []
af_str = []
count = gets.to_i
queries = []
is_reverse = false
count.times do
  substr = gets
  if substr.include?(" ")
    t,f,c = substr.chomp.split(" ")
    # f = 1のとき、strの先頭にcを追加する
    # f = 2のとき、strの末尾にcを追加する
    if (f.to_s == "1" && !is_reverse) ||(f.to_s == "2" && is_reverse)
      be_str.unshift(c)
    else
      af_str.push(c)
    end
  else
    # t = 1のとき strの前後を反転する
    is_reverse = !is_reverse
  end
end
str = be_str.join + str + af_str.join
# 最後に反転する
if is_reverse
  str = str.reverse
end
print str


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

#define ll 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'

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() {
    //COMint();
    ll N=in();
    for(ll i=1;i<=3500;i++){
        for(ll j=1;j<=3500;j++){
        //debug(i);debug(j);debug((N*i*j));debug(4*i*j-N*j-N*i);
            if((4*i*j-N*j-N*i)!=0){
                if((N*i*j)%(4*i*j-N*j-N*i)==0&&(4*i*j-N*j-N*i)>0){
                    cout<<i<<" "<<j<<" "<<N*i*j/(4*i*j-N*j-N*i)<<endl;
                    return 0;
                }
            }
        }
    }
}

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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }


long long usu[1000006];
char s[100003];
long long n,sol,act;

int main()
{

    //ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        cin>>(s+1);
        
        // cout << s << "\n";
        //  FOR(l, 10)
        //  	cout << s[l] << ' ';

        sort(s+1,s+10+1);
		        
        for(int j=1;j<=10;++j) usu[i]=usu[i]*26+(s[j]-'a');
    }

    sort(usu+1,usu+n+1);
    act=1;
    for(int i=2;i<=n;++i)
    {
        if(usu[i]==usu[i-1])
        {
            ++act;
            continue;
        }
        else
        {
            sol+=(act-1)*act/2;
            act=1;
            continue;
        }
    }
    sol+=(act-1)*act/2;
    cout<<sol;
    return 0;
}


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

#define int long long int
#define ff first
#define ss second
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int cmod = 998244353;
const int N = 1e7 + 5;
const int inf = 1e16 + 2;


void solve(int Case) {
    int n , m , k;
    cin >> n >> m >> k;
    int arr[n] , brr[m];
    for(int i = 0 ; i < n ; i ++) cin >> arr[i];
    for(int i = 0 ; i < m ; i ++) cin >> brr[i];
    int l = 0 , r = 0 , cnt = 0 , ans = 0;
    while(cnt < k) {
        if(l < n and cnt + arr[l] <= k) cnt += arr[l] , l ++;
        else if(r < m and cnt + brr[r] <= k) cnt += brr[r] , r ++;
        else break;
    }
    if(l + r == n + m) {
        cout << n + m << '\n';
        return;
    }
    
    ans = l + r;
    l --;
    while(l >= 0) {
        cnt -= arr[l];
        l --;
        while(r < m and (cnt + brr[r]) <= k) cnt += brr[r] , r ++;
        ans = max(ans , l + 1 + r);
        if(r >= m) break;
    }
    
    cout << ans << '\n';
}
/*
 */

int32_t main()
{
    fastio
    int testcase = 1;
    //cin >> testcase;
    int Case = 1;
    while(testcase --) {
        solve(Case ++);
    }
    return 0;
}
 



Measured memory_bytes: 6716
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<fstream>
#include<algorithm>
using namespace std;
using ll = long long;

int main(){
    int a,b;
    cin >> a >> b;
    if(a<=9&&b<=9)  cout << a*b;
    else    cout << -1;
}

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

using namespace std;

int N,M,K,L,R,H,W;
//long long int N,M,K,L,R,H,W;

//constexpr long long int MOD=1000000007;
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
//constexpr long long int MOD=998244353;

constexpr long double  EPS=1e-8;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>N>>K;
	vector<int>v(N);
	for(auto &i:v)cin>>i;
	sort(v.begin(),v.end());
	long long int ans=1;
	queue<int>Q;
	for(int i=0;i<N;i++){
		while(!Q.empty()&&Q.front()<v[i]-K)Q.pop();
		//cout<<Q.front()<<endl;
		ans*=(1+Q.size());
		ans%=MOD;
		Q.push(v[i]);
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3736
#include <iostream>

using namespace std;

int main(void) {
    int N, K;
    cin >> N >> K;

    int ans = 1;
    while(N--) {
        if(ans > K) {
            ans += K;
        } else {
            ans *= 2;
        }
    }

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


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

int main() {
  int s,k;
  cin>>k>>s;
  int x,y,z,cnt=0;

    for(x=0;x<=k;x++)
      for(y=0;y<=k;y++)
          if(s-x-y<=k && s-x-y>=0)
            cnt++;
  cout<<cnt;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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() {
    int a, b, q;
    cin >> a >> b >> q;
    V<ll> s(a), t(b);
    rep(i,a) cin >> s[i];
    rep(i,b) cin >> t[i];

    rep(i,q) {
        ll x;
        cin >> x;

        auto add = [&](V<ll> &c, V<ll> &C) {
            auto it = lower_bound(all(c),x);
            if(it != c.end()) C.push_back(*it);
            if(it != c.begin()) C.push_back(*(it-1));
        };

        V<ll> S(0), T(0);
        add(s,S);
        add(t,T);

        ll ans = infll;
        for(ll y:S)for(ll z:T) {
            ll d = max({x,y,z}) - min({x,y,z});
            if((y >= x) != (z >= x)) {
                d += min(abs(y-x), abs(z-x));
            }
            chmin(ans, d);
        }
        cout << ans << endl;
    } 
}

Measured memory_bytes: 4840
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.StringTokenizer;
 
public class Main {
	
	public static final long MOD = 1000000007;
	
	public static long mod_inv(long a, long m){
		return (a == 1 ? 1 : (1 - m*mod_inv(m%a, a)) / a + m);
	}
	
	public static long comb(int n, int k, long[] fact){
		if(n == 0){ return 1; }
		if(k == 0){ return 1; }
		
		return (((fact[n] * mod_inv(fact[k], MOD)) % MOD) * mod_inv(fact[n - k], MOD)) % MOD;
	}
	
	public static void main(String[] args) throws IOException {
		final Scanner sc = new Scanner(System.in);
		
		final int H = sc.nextInt();
		final int W = sc.nextInt();
		final int A = sc.nextInt();
		final int B = sc.nextInt();
		
		final long[] fact = new long[H + W + 1];
		fact[0] = 1;
		for(int i = 1; i < fact.length; i++){
			fact[i] = i * fact[i - 1];
			fact[i] %= MOD;
		}
		//System.out.println(Arrays.toString(fact));
		
		long answer = 0;
		for(int i = B; i < W; i++){
			//System.out.println(comb(H - A + i - 1, i, fact));
			//System.out.println(A + " " + (W - i - 1) + " " + comb(A + (W - i - 1), A - 1, fact));
			answer += (comb((H - A) + i - 1, i, fact) * comb((A - 1) + (W - i - 1), A - 1, fact)) % MOD;
			//System.out.println(i + " " + answer);
			answer %= MOD;
		}
		
		
		System.out.println(answer);
	}
 
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 10412
N, M = map(int, input().split())
X = list(map(int, input().split()))

if N >= M:
    print(0)
else:
    X.sort()
    spot = [0]*M
    diff = [[0, 0]]*(M-1)
    for i in range(M-1):
        diff[i] = [X[i+1]-X[i], i]
    diff.sort(key=lambda x: x[0])
    if N == 1:
        print(X[-1]-X[0])

    else:
        ans = X[-1] - X[0]
        for i in range(N-1):
            tmp = diff.pop()
            ans -= tmp[0]
        print(ans)



Measured memory_bytes: 22308
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int a[11],b[11],flag;
void dfs(int step){
	if(flag){
		return ;
	}
	if(step==10){
		int s1=0,s2=0,inf=0;
		for(int i=0;i<10;i++){
			if(b[i]==1){
				if(a[i]>s1){
					s1=a[i];
				}
				else{
					inf=1;break;
				}
			}
			else{
				if(a[i]>s2){
					s2=a[i];
				}
				else{
					inf=1;break;
				}
			}
		}
		if(!inf){
			flag=1;
		}
		return ;
	}
	b[step]=0;
	dfs(step+1);
	b[step]=1;
	dfs(step+1);
	return ;
}
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		flag=0;
		for(int i=0;i<10;i++){
			scanf("%d",&a[i]);
		}
		dfs(0);
		if(flag){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	return 0;
}



Measured memory_bytes: 3100
unittest
{
	assert( [ "1", "24 30" ].parse.expand.solve == 7 );
	assert( [ "2", "6 8", "3 3" ].parse.expand.solve == 4 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	auto lrs = new long[ 2 ][ n ];
	foreach( ref lr; lrs )
	{
		input.popFront;
		lr = input.front.split.to!( long[] );
	}
	return tuple( lrs );
}

auto solve( long[ 2 ][] lrs )
{
	return lrs.map!( ( a ) => 1 + a[ 1 ] - a[ 0 ] ).reduce!( ( a, b ) => a + b );
}


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll a[n+1];
    for(ll i=1;i<=n;i++)
        cin>>a[i];
    ll dp[n+1];
    dp[0]=0;
    for(ll i=1;i<=n;i++)
    {
        dp[i]=dp[i-1]+a[i];
    }
    for(ll i=1;i<=n;i++)
    {
        dp[i]=((dp[i]-i)%k+k)%k;
        //cout<<dp[i]<<" ";
    }
    //cout<<endl;
    map<ll,ll>m;
    ll mini=min(k,n);
    if(mini==n)
    {
        ll as=0;
        for(ll i=0;i<=n;i++)
        {
            m[dp[i]]+=1;
        }
        for(auto i=m.begin();i!=m.end();i++)
        {
            as+=(i->second)*(i->second-1)/2;
        }
        cout<<as;
        return 0;
    }
    for(ll i=0;i<mini;i++)
    {
        m[dp[i]]+=1;
    }
    ll ans=0;
    for(auto i=m.begin();i!=m.end();i++)
    {
        ans=ans+(i->second)*(i->second-1)/2;
    }
    //cout<<ans<<endl;
    for(ll i=mini;i<=n;i++)
    {
        m[dp[i-mini]]-=1;
        ans+=m[dp[i]];
        m[dp[i]]+=1;
    }
    cout<<ans;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int a,b,c;
    while(cin>>a>>b>>c){
        if((b+c)>=a)cout<<(b+c)-a<<endl;
        else cout<<"0"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<ll> a(n+2);

    a[0] = 0;
    a[n+1] = 0;
    REP(i, 1, n+1) cin >> a[i];

    ll sum = 0;
    REP(i, 1, n+2) {
        sum += abs(a[i] - a[i-1]);
    }

    REP(i, 1, n+1) {
        cout << sum + abs(a[i+1] - a[i-1]) - abs(a[i] - a[i-1]) - abs(a[i+1] - a[i]) << endl;
    
    }

    return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
//#define INF 1e9
using namespace std;
long long int arr[200001];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
 
	int n;
	cin >> n;
	long long int total = 0;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		total += arr[i] % 1000000007;
		total %=1000000007;
	}
	long long int sum = 0;
	long long int m_sum = 0;
	for (int i = 0; i < n; i++) {
		m_sum += arr[i];
		m_sum = m_sum  % 1000000007;
		sum = sum + arr[i] * (total - m_sum)%1000000007;
      	if(sum<0)sum+=1000000007;
		sum = sum % 1000000007;
 
	}
	cout << sum % 1000000007;
	return 0;
}

Measured memory_bytes: 5188
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define int int64_t
#define pcnt __builtin_popcount
#define pb push_back
#define ALL(x) (x).begin(),(x).end()
#define vec vector<int>
#define mat vector<vector<int>> //mat データ名(縦,vec(横));
int INF = 1000000000000000001; //10^18+1
int MOD = 1000000007; //10^9+7
//cout << fixed << setprecision(15); (小数点以下表示)

signed main () {
  int H,N,ma=0,ans=INF;
  cin >> H >> N;
  vec A(N),B(N);
  for(int i=0;i<N;i++)cin >> A.at(i) >> B.at(i),ma=max(ma,A.at(i));
  vec dp(H+ma,INF);
  dp.at(0)=0;
  for(int i=0;i<H+ma;i++){
    for(int j=0;j<N;j++){
      if(i-A.at(j)>=0){
        if(dp.at(i-A.at(j))!=INF){
          dp.at(i)=min(dp.at(i),dp.at(i-A.at(j))+B.at(j));
        }
      }
    }
    if(i>=H)ans=min(ans,dp.at(i));
  }
  cout << ans << endl;
}

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

int main() {
    int n, m;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s.at(i);
    }
    cin >> m;
    vector<string> t(m);
    for (int i = 0; i < m; i++) {
        cin >> t.at(i);
    }
    int answer = 0;
    for (int i = 0; i < n; i++) {
        int score = 0;
        for (int j = 0; j < n; j++) {
            if (s.at(j) == s.at(i)) {
                score++;
            }
        }
        for (int j = 0; j < m; j++) {
            if (t.at(j) == s.at(i)) {
                score--;
            }
        }
        answer = max(answer, score);
    }
    cout << answer << endl;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#define maxn 500009
using namespace std;
int n;
int b[maxn];
int a[maxn];
int main(){
	cin >> n;
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
	}
	int p = 1, q = n;
	int sg = 1;
	for(int i  = n; i >= 1; i--){
		if(sg == 1){
			b[p++] = a[i];
		}
		else{
			b[q--] =a[i];
		}
		sg *= -1;
	}
	for(int i = 1; i <= n; i++){
		printf("%d", b[i]);
		if(i == n)
			puts("");
		else
			printf(" ");
	}
	return 0;
}

Measured memory_bytes: 3712
#include<string>
#include<iostream>
#include<cctype>
using namespace std;
int b[26];
int main(){
    string a;
    char c[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    while(getline(cin,a)){
    for(int i=0;i<a.size();i++){
        for(int j=0;j<26;j++){
            if(a[i]==c[j] || a[i]==toupper(c[j])){
                b[j] += 1;
            }
        }
    }
    }
    for(int i=0;i<26;i++){
        cout<<c[i]<<" : "<<b[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1180
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
   int n; cin>>n;
   int b=0;
   if(n==1) cout<<"Yes"<<endl;
   else{
   for(int i=9;i>1;i--){
      if(n%i==0){
         b=n/i;
         break;
      }
   }
   if(b>0&&b<10) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   }
   return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int M = int.Parse(str[1]);
		var uf = new UnionFind(N+1);
		int[,]A = new int[M,3];
		int[]ct = new int[N];
		for(var i=0;i<N;i++){
			ct[i] = 1;
		}
		for(var i=0;i<M;i++){
			string[] str2 = Console.ReadLine().Split();
			A[i,0] = int.Parse(str2[0]);
			A[i,1] = int.Parse(str2[1]);
			A[i,2] = int.Parse(str2[2]);
			int ct1 = ct[uf.Root(A[i,0])-1];
			int ct2 = ct[uf.Root(A[i,1])-1];
			uf.Unite(A[i,0],A[i,1]);
			ct[uf.Root(A[i,0])-1] = ct1+ct2+1;
		}
		int[] c = new int[N];
		for(var i=0;i<N;i++){
			c[uf.Root(i+1)-1] = 1;
		}
		long ans = 0;
		for(var i=0;i<N;i++){
			if(c[i] == 1){
				//Console.WriteLine(i+" "+ct[i]);
				ans += 1;
			}
		}
		Console.WriteLine(ans);
	}
}

public class UnionFind
{
    private int[] data;
	public UnionFind(int size){
        data = new int[size];
        for (int i = 0; i < size; i++) data[i] = -1;
    }
    public bool Unite(int x, int y){
        x = Root(x);
        y = Root(y);
        if (x != y){
            if (data[y] < data[x]){
                var tmp = y;
                y = x;
                x = tmp;
            }
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
	public bool IsSameGroup(int x, int y){
        return Root(x) == Root(y);
    }
    public int Root(int x){
        return data[x] < 0 ? x : data[x] = Root(data[x]);
    }
}


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

int main()
{
  string s;
  int i, c, score[2];
  while (cin>>s, s!="0") {
    score[0] = 0;
    score[1] = 0;
    c = s[0]-'A';
    for (i = 1; i < s.size(); i++) {
      if (c != s[i]-'A') c ^= 1;
      score[c]++;
    }
    if (score[0]<10) score[1]++;
    else if (score[1]<10) score[0]++;
    else if (score[0]<score[1]) score[1]++;
    else if (score[0]<score[1]) score[1]++;
    else score[0]++;
    cout<<score[0]<<" "<<score[1]<<endl;
  }
}

Measured memory_bytes: 0
import java.util.*;

public class Main{

    void solve(){
	Scanner sc = new Scanner(System.in);

	while(true){
	    int n = sc.nextInt();
	    int m = sc.nextInt();
	    if(n==0 && m==0) break;
	    int[] c = new int[m];
	    int[] x = new int[n];
	    for(int i=0; i<m; i++) c[i] = sc.nextInt();
	    for(int i=0; i<n; i++) x[i] = sc.nextInt();
	    
	    int INF = 100000000;
	    int[][] dp = new int[256][n+1];
	    for(int i=0; i<256; i++) Arrays.fill(dp[i], INF);
	    dp[128][0] = 0;
	    
	    for(int i=1; i<=n; i++){
		for(int j=0; j<256; j++){
		    if(dp[j][i-1]==INF) continue;
		    for(int k=0; k<m; k++){
			int newY = j+c[k];
			if(newY<0) newY = 0;
			else if(newY>255) newY = 255;
			dp[newY][i] = Math.min(dp[newY][i], dp[j][i-1]+(newY-x[i-1])*(newY-x[i-1]));
		    }
		}
	    }
	    
	    int min = INF;
	    for(int i=0; i<256; i++) min = Math.min(min, dp[i][n]);
	    
	    System.out.println(min);
	}
    }

    public static void main(String[] args){
	new Main().solve();
    }
}

Measured memory_bytes: 37000
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
                
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pretime float(clock()-clk)/CLOCKS_PER_SEC
#define max2(a,b) ((a)>(b) ? (a) : (b))   
#define min2(a,b) ((a)<(b) ? (a) : (b)) 
#define rep(i,a,b) for(i=a;i<=b;++i)
#define rev(i,a,b) for(i=a;i>=b;--i) 
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define lli long long int 
#define ins insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
#define inf 1000000000000000

using namespace std;
typedef vector<lli>   vll;
typedef vector<int>   vi;
typedef set<lli>      sll;
typedef set<int>      si;
typedef pair<lli,lli> pll;
typedef pair<int,int> pii;
clock_t clk=clock();       

int i,j;
void solve(void);

int main()
{
  speedio;
   int t=1;  
  // cin>>t;
   while(t--)
     solve();

  return 0;
}
//
void solve()
{
	lli n,k; cin>>n>>k;
	 cout<<n-k+1<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
////////////////////////////////////////////////////////////
#define all(x) (x).begin(), (x).end() 
const int inf = 1e9;
const long long INF=1e15;
#define endl '\n'
#define rep(i, n) for(int i=0;i<(n);++i)
#define repp(i, a, b) for(int i=(a);i<=(b);++i)
#define pb push_back
#define eb emplace_back
#define fastio ios::sync_with_stdio(false);cin.tie(0); //cout.tie(0);

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

int solve() {
	ll n , a , b;
	cin >> n>>a>>b;
	// a < b is guaranteed.
	if(b-a+1&1) {
		cout << (b-a)/2;
	} else {
		cout << min(a+(b-a)/2, n+1-b+(b-a)/2);
	}
}

int main() {
	fastio;
	solve();
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  string s,t;
  cin >> s;
  cin >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t)cout << "Yes" << endl;
  else cout << "No" << endl;
return 0;}

Measured memory_bytes: 256
import sys

class Card:
	def __init__(self, card):
		self.card = card
		self.symbol = card[0]
		self.value = int(card[1])

def print_cards(arr_print, arr_compare):
	n = len(arr_print)
	same = True
	for i in range(n):
		if arr_compare != None and arr_print[i].card != arr_compare[i].card: same = False
		sys.stdout.write(arr_print[i].card)
		if i != n - 1:
			sys.stdout.write(' ')
	print()
	return same

def swap(arr, i, j):
	temp = arr[i]
	arr[i] = arr[j]
	arr[j] = temp

def bubble_sort(arr):
	n = len(arr)
	for i in range(0, n):
		for j in range(n - 1, i, -1):
			if arr[j].value < arr[j - 1].value:
				swap(arr, j, j - 1)

def selection_sort(arr):
	n = len(arr)
	for i in range(n):
		minj = i
		for j in range(i, n):
			if arr[j].value < arr[minj].value:
				minj = j
		if minj != i:
			swap(arr, i, minj)

n = int(input())
arr = list(map(str, input().split()))
cards1 = [None] * n
cards2 = [None] * n
for i in range(n):
	cards1[i] = Card(arr[i])
	cards2[i] = Card(arr[i])

bubble_sort(cards1)
selection_sort(cards2)

print_cards(cards1, None)
print('Stable')

stable = print_cards(cards2, cards1)
if stable == True:
	print('Stable')
else:
	print('Not stable')



Measured memory_bytes: 5616
#include <stdio.h>

#define N 8
#define UFOKERU -5
#define NOT_UFOKERU 5
#define true 1
#define false 0

int row[N], col[N], dpos[2 * N - 1], dneg[2 * N - 1];

int X[N][N];

void init()
{
    int i;

    for (i = 0; i < N; i++)
    {
        row[i] = UFOKERU, col[i] = UFOKERU;
    }
    for (i = 0; i < 2 * N - 1; i++)
    {
        dpos[i] = UFOKERU;
        dneg[i] = UFOKERU;
    }
}

void printBoard()
{
    int i, j;

    for (i = 0; i < N; i++)
    {
        for (j = 0; j < N; j++)
        {
            if (X[i][j])
            {
                if (row[i] != j)
                    return;
            }
        }
    }
    for (i = 0; i < N; i++)
    {
        for (j = 0; j < N; j++)
        {
            if (row[i] == j)
                printf("Q");
            else
                printf(".");
        }
        printf("\n");
    }
}

void recursive(int i)
{
    int j;

    if (i == N)
    {
        printBoard();
        return;
    }

    for (j = 0; j < N; j++)
    {
        if (NOT_UFOKERU == col[j] ||
            NOT_UFOKERU == dpos[i + j] ||
            NOT_UFOKERU == dneg[i - j + N - 1])
            continue;

        row[i] = j;
        col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_UFOKERU;

        recursive(i + 1);
        row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = UFOKERU;
    }
}

int main()
{
    int i, j;
    init();

    for (i = 0; i < N; i++)
        for (j = 0; j < N; j++)
            X[i][j] = false;

    int k;
    scanf("%d", &k);
    for (i = 0; i < k; i++)
    {
        int r, c;
        scanf("%d%d", &r, &c);
        X[r][c] = true;
    }

    recursive(0);

    return 0;
}


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

int main() {
  int n; cin >> n;
  vector<int> v(1000000);
  rep(i,n){
    cin >> v[i];
  }

  int min = 10000000;
  int ans = 0;
  rep(i,n){
    if(min > v[i]){
      min = v[i];
      ans++;
    }
  }

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


Measured memory_bytes: 7216
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double lb;

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


int main() {
    ll A,B,C,K;
    cin >> A >> B >> C >> K;

    ll ans = A-B;
    if(abs(ans) > (ll)1e18){
        cout << "Unfair" << endl;
        return 0;
    }

    if(K%2 == 0){
        cout << ans << endl;
    }else{
        cout << ans*-1 << endl;
    }
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define int long long
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)


int32_t main()
{
	fastio;
	string s;
	cin >> s;
	int l = 0, r = (int)s.size()-1;
	int cnt = 0;
	while(l<r){
		if(s[l]!=s[r])
			cnt++;
		l++, r--;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
typedef long long ll;
string s;
int d;

ll dp[100008][2][128];

ll dfs(int pos, int less, int sum) {
    if (pos == s.size()) {
        if (sum % d == 0) {
            return 1;
        } else {
            return 0;
        }
    }
    if (dp[pos][less][sum] != -1) {
        return dp[pos][less][sum];
    }
    char upper = less ? '9' : s[pos];
    ll total = 0;
    for (char i = '0'; i <= upper; i++) {
        ll num = sum + i - '0';
        num %= d;
        total += dfs(pos + 1, less || i < upper, num) % M; 
        total %= M;
    }
    total %= M;
    return dp[pos][less][sum] = total;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> s;
    cin >> d;
    memset(dp, -1, sizeof(dp));
    cout << max((dfs(0, 0, 0) - 1LL + M) % M, 0LL);
    return 0;
}


Measured memory_bytes: 201216
#include<iostream>
using namespace std;
int main()
{
	int i,l,r;
	cin>>r>>l;
	if(l>r)
	{
		i=r;
		r=l;
		l=i;
	}
	if(l<=0&&r>=0)
	{
		cout<<"Zero\n";
	}
	else
	{
		if(l>0)
			cout<<"Positive\n";
		else
		{
			i=r-l;
			if(i%2==0)
				cout<<"Negative\n";
			else
				cout<<"Positive\n";
		}
	}
	return 0;
}

Measured memory_bytes: 256
// Problem : A - BBQ Easy
// Contest : AtCoder - AtCoder Grand Contest 001
// URL : https://atcoder.jp/contests/agc001/tasks/agc001_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
    return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
    mem(isprime,true);
    for(ll p=2;p*p<=n;p++)
    {
        if(isprime[p]==true)
        {
            for(ll i=p*p;i<=n;i+=p)
                isprime[i]=false;
        }
    }
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
void solve()
{
 	ll n;
 	cin>>n;
 	vector<ll> a;
 	for(ll i=0;i<2*n;i++)
 	{
 		ll p;
 		cin>>p;
 		a.pb(p);
 	}
 	sort(all(a));
 	ll sum=0;
 	for(ll i=0;i<2*n;i=i+2)
 	{
 		sum=sum+a[i];
 	}   
 	cout<<sum;
}
int main()
{
    ll inpoup = 0;
    if(inpoup==1)
    {
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
    }
    IOS
    ll t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
     
    string str;
    int sum;
     
    while(cin >> str && str!="0"){
        sum=0;
        for(int i=0,l=str.size();i<l;i++)sum += str[i] - '0';
        cout << sum <<endl;
    }
     
    return 0;
     
}


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

int n;
int a[100005];

int main(void)
{
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	
	for(int i = 0; i < n; i++){
		if(a[i]%2){
			cout << "first" << endl;
			return 0;
		}
	}
	cout << "second" << endl;
	return 0;
}

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

int main()
{
    int n, y, m, d;
    int mil = 200 * 333 + 195 * 666 + 1;
    
    cin >> n;
    
    for( int i = 0; i < n; i++ )
    {
        cin >> y >> m >> d;

        int sum = d;
        sum += ( y - 1 ) / 3 * 200 + ( y - 1 - ( y - 1 ) / 3 ) * 195;

        if( y % 3 == 0 )
            sum += ( m - 1 ) * 20;
        else
        {
            if( m % 2 == 0 )
                sum += ( m - 1 ) / 2 * 39 + 20;
            else
                sum += m / 2 * 39;
        }
        cout << mil - sum << endl;
    }

    return 0;
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
long long n, k;

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

    n %= k;

    printf("%lld\n", min(n, abs(n - k)));
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 256
s=int(input())
l=[]
l.append(s)
i=0
buf=s
while True:
    if buf%2==0:
       l.append(int(buf/2))
       buf=int(buf/2)
    else:
        l.append(3*buf+1)
        buf=3*buf+1
    if not(len(set(l))==len(l)):
        break
    else:
        i=i+1
print(i+2)

Measured memory_bytes: 38256
#include <iostream>
#include <cstdio>
using namespace std;
long long n, x, s, a[55], d[55][55][2505]={1};
int main() {
	int i, j, k;
	cin>>n>>x;
	for(i=1; i<=n; i++) cin>>a[i];
	for(i=1; i<=n; i++) for(j=0; j<=i; j++) {
		for(k=0; k<=i*50; k++) {
			d[i][j][k] = d[i-1][j][k];
			if(j>=1 && k>=a[i]) d[i][j][k] += d[i-1][j-1][k-a[i]];
		}
	}
	for(j=1; j<=n; j++) s += d[n][j][j*x];
	cout<<s;
	return 0;
}

Measured memory_bytes: 21760