akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> w(n);
  int sum = 0;
  for(int i = 0;i < n;i++){
    cin >> w[i];
    sum += w[i];
  }

  int ans = 1e9;
  int sub_sum = 0;
  for(int i = 0;i < n;i++){
    sub_sum += w[i];
    int sub_sum_right = sum - sub_sum;
    ans = min(ans,abs(sub_sum_right - sub_sum));
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
const int N = 300030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  ll n;
  cin>>n;
  ll x=0;
  rep(i,0,n)
  {
  	ll y;
  	cin>>y;
  	x=x^y;
  }
  if(x==0)
  {cout<<"Yes\n";
  }
  else
  cout<<"No";


}






Measured memory_bytes: 256
x,y = map(int,input().split())
ans = 0
if abs(y) > abs(x):
  if x < 0:ans += 1
  if y < 0:ans += 1
  ans += (abs(y)-abs(x))
else:
  if x > 0:ans += 1
  if y > 0:ans += 1
  ans += (abs(x)-abs(y))
print(ans)


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

ll n,k;
ll mod=1000000007;
ll arr[101];
ll dp[100005];
ll pre[100005];
void add(ll x,ll a){
	pre[x]+=a;
	if(pre[x]>=mod)pre[x]-=mod;
	
}

void sub(ll x,ll a){
	pre[x]-=a;
	if(pre[x]<0)pre[x]+=mod;
}

int main(){
	cin>>n>>k;
	
	for(ll i=0;i<n;i++){
		cin>>arr[i];
	}
	dp[0]=1;
	for(ll i=0;i<n;i++){
		memset(pre,0,sizeof(pre));
		for(ll j=k;j>=0;j--){
			
			ll r=j+min(arr[i],k-j);
			if(j+1<=r){
			add(j+1,dp[j]);
			if(r+1<=k){
			sub(r+1,dp[j]);}}
			
		}
		for(ll z=0;z<=k;z++){
			//	if(z>=j){
			if(z>=1)
			add(z,pre[z-1]);
					dp[z]=(dp[z]+pre[z])%mod;
			//	}
			}
	}
	
	cout<<dp[k]<<'\n';
	
}

Measured memory_bytes: 1792
import std.functional,
       std.algorithm,
       std.container,
       std.typetuple,
       std.typecons,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

bool chmin(T)(ref T a, T b) {
  if (b < a) {
    a = b;
    return true;
  } else {
    return false;
  }
}

void main() {
  int N = readln.chomp.to!int;
  string S = readln.chomp;
  int[][] dp = new int[][](2, N);

  foreach (i, ch; S) {
    if (ch == 'W') {
      if (i > 0) {
        dp[0][i] = dp[0][i - 1] + 1;
      } else {
        dp[0][i] = 1;
      }
    } else {
      if (i > 0) {
        dp[0][i] = dp[0][i - 1];
      } else {
        dp[0][i] = 0;
      }
    }
  }

  foreach_reverse (i, ch; S) {
    if (ch == 'E') {
      if (i < N - 1) {
        dp[1][i] = dp[1][i + 1] + 1;
      } else {
        dp[1][i] = 1;
      }
    } else {
      if (i < N - 1) {
        dp[1][i] = dp[1][i + 1];
      } else {
        dp[1][i] = 0;
      }
    }
  }

  int[] ans = new int[](N);

  foreach (i; 0..N) {
    ans[i] = dp[0][i] + dp[1][i];
  }

  int min = int.max;

  foreach (a; ans) {
    chmin(min, a);
  }

  writeln(min - 1);
}


Measured memory_bytes: 4308
// Author: πα

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

inline double euclid(pair<int, int> a, pair<int, int> b)
{
    return sqrt(
        (a.first - b.first) * (a.first - b.first) +
        (a.second - b.second) * (a.second - b.second));
}

int fact(int n)
{
    if(n == 1)
        return 1;
    return n * fact(n-1);
}

int main()
{
    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    vector<int> p(n);
    iota(p.begin(), p.end(), 0);
    double ans = 0;
    for(auto& it : v)
        cin >> it.first >> it.second;
    do
    {
        double cur = 0;
        for(int i = 1; i < n; ++i)
            cur += euclid(v[p[i]], v[p[i-1]]);
        ans += cur;
    }
    while(next_permutation(p.begin(), p.end()));
    cout << fixed << setprecision(12) << ans/fact(n);
    return 0;
}


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

int main(){
    int N,max_height,count;
    cin >> N;
    max_height = 0;
    count = 0;
    vector<int> H(N);

    for (int i = 0; i < N; i++){
        cin >> H.at(i);
        if (H.at(i) >= max_height){
            count++;
            max_height = H.at(i);
        }
    }
    cout << count << endl;
    
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	h, _ := strconv.Atoi(Scanner())
	w, _ := strconv.Atoi(Scanner())
	a := make([]string, h)
	n := make([][]int, h)
	d := 1000000007
	for i := 0; i < h; i++ {
		a[i] = Scanner()
		n[i] = make([]int, w)
	}
	n[0][0] = 1
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if j < w-1 {
				if string(a[i][j+1]) == "." {
					n[i][j+1] += n[i][j]
					n[i][j+1] %= d
				}
			}
			if i < h-1 {
				if string(a[i+1][j]) == "." {
					n[i+1][j] += n[i][j]
					n[i+1][j] %= d
				}
			}
		}
	}
	fmt.Println(n[h-1][w-1])
}


Measured memory_bytes: 10112
#include<string>
#include<algorithm>
#include<iostream>

using namespace std;

int main() {
  string target;
  int commnad_num;

  cin >> target;
  cin >> commnad_num;

  for(int i = 0; i < commnad_num; i++) {
    string command;
    int top_index, tail_index;
    cin >> command >> top_index >> tail_index;

    if(command == "print") {
      string sub_str = target.substr(top_index, tail_index - top_index + 1);
      cout << sub_str << endl;
    } else if(command == "reverse") {
      string sub_str = target.substr(top_index, tail_index - top_index + 1);
      reverse(sub_str.begin(), sub_str.end());
      target.replace(top_index, sub_str.size(), sub_str);
    } else if(command == "replace") {
      string sub_str;
      cin >> sub_str;

      target.replace(top_index, sub_str.size(), sub_str);
    }
  }
}



Measured memory_bytes: 3216
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int n;
            int[] p;
            n = Integer.parseInt(sc.next());
            p = new int[n];
            for (int i = 0; i < n; i++) {
                p[i] = Integer.parseInt(sc.next());
            }
            Arrays.sort(p);
            int pp = 0;
            for (int i = n; i > 0; i--) {
                pp += p[n - i] * i;
            }
            System.out.println(pp);
        }
    }
}



Measured memory_bytes: 36920
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	string S; cin >> S;
	if(S[0] == 'A'){
		S[0] = 'a';
		for(int i = 2; i < S.size()-1; ++i){
			if(S[i] == 'C'){
				S[i] = 'c';
				for(int j = 0; j < S.size(); ++j){
					if(isupper(S[j])){
						cout << "WA" << endl;
						return 0;
					}
					if(j+1 == S.size()){
						cout << "AC" << endl;
						return 0;
					}
				}
			}
		}
	}
	cout << "WA" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int k = scanner.nextInt();

        int counter = 0;
        for (int i = 0; i < n; i++) {
            if (scanner.nextInt() >= k) {
                counter++;
            }
        }

        System.out.println(counter);
    }
}


Measured memory_bytes: 47912
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 998244353;
const int IMAX = 100000;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}

ll dp[3001][3001];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N, S;
	cin >> N >> S;

	int A[3000];
	rep(i, N) {
		cin >> A[i];

	}

	ll k1 = modpow(2, N);
	ll k2 = modpow(2, mod - 2);
	dp[0][0] = k1;

	ll kotae = 0;
	rep(i, N) {
		rep(j, S) {
			if (j + A[i] <= S) {
				dp[i + 1][j + A[i]] += dp[i][j] * k2 % mod;
				dp[i + 1][j + A[i]] %= mod;
			}
			dp[i + 1][j] += dp[i][j];
			dp[i + 1][j] %= mod;
		}
		kotae += dp[i + 1][S];
	}

	co(kotae% mod);


	Would you please return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    long syak = 100000;
    for(int i=0;i<n;i++){
        syak = syak * 1.05;
        int s = syak % 1000;
        if(s != 0){
            syak = syak -s + 1000;
        }
    }
    cout << syak << endl;
    return 0;
}

Measured memory_bytes: 0
#include <cassert>
#include <vector>

template <class T = long long>
class cht_monotone
{
    struct line
    {
        T a, b;
        T eval(const T x) const { return a * x + b; }
    };

    std::vector<line> lines;
    typename std::vector<line>::iterator lp, rp;

    void realloc()
    {
        std::vector<line> cpy((rp - lp) * 2);
        cpy.swap(lines);
        rp = copy(lp, rp, lines.begin());
        lp = lines.begin();
    }

public:
    cht_monotone() : lines(1), lp(lines.begin()), rp(lp) {}

    bool empty() const { return lp == rp; }

    void add(const T a, const T b)
    {
        while(rp - lp > 1)
        {
            auto [a1,b1] = *(rp - 1);
            auto [a2,b2] = *(rp - 2);
            if((b - b1) * (a2 - a) > (b - b2) * (a1 - a)) break;
            --rp;
        }
        if(rp == lines.end()) realloc();
        *rp++ = {a, b};
    }

    T get(const T x)
    {
        assert(!empty());
        while(rp - lp > 1 && lp->eval(x) > (lp + 1)->eval(x)) ++lp;
        return lp->eval(x);
    }
};

#include <cassert>
#include <cstdio>

main()
{
    int n; long long c;
    scanf("%d%lld",&n,&c);

    cht_monotone cht;

    for(int i=1; i<n; i++)
    {
        long long h;
        scanf("%lld",&h);
        if(i==1)
        {
            cht.add(-2*h,h*h+c);
        }
        else
        {
            cht.add(-2*h,cht.get(h)+h*h*2+c);
        }
    }
    long long hlst;
    scanf("%lld",&hlst);
    printf("%lld\n",cht.get(hlst)+hlst*hlst);
}

Measured memory_bytes: 8968
#include <bits/stdc++.h>
#define int long long
#define endl "\n"
using namespace std;

int32_t main(){
	string s;
	cin >> s;
	if(s.size() < 26){
		set<char> pool;
		for(char c : s) pool.insert(c);
		for(int i=0; i<26; i++){
			if(pool.count(char('a'+i))) continue;
			s += char('a'+i);
			cout << s << endl;
			return 0;
		}
	}
	else {
		set<char> pool;
		for(char c : s) pool.insert(c);
		while(s.size() > 0){
			char curr = s.back();
			curr++;
			while(curr <= 'z'){
				if(pool.count(curr)) curr++;
				else{
					s.back() = curr;
					cout << s << endl;
					return 0;
				}
			}
			pool.erase(s.back());
			s.pop_back();
		}
		cout << -1 << endl;
	}
}
		

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;
int main(void){
    int n, m, c=0, d=0;
    P p[100000];
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a, b;
        cin>>a>>b;
        p[i]=P(b, a);
    }
    sort(p, p+m);
    for(int i=0;i<m;i++){
        //cout<<p[i].second<<" "<<p[i].first<<endl;
        if(p[i].second>=d){
            d=p[i].first;
            c++;
        }
    }
    cout<<c<<endl;
}


Measured memory_bytes: 1024
#include"bits/stdc++.h"
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.141592653589793238

int main() {
	int N;
	cin >> N;
	double sum = 0;
	rep(i, N) {
		double A;
		cin >> A;
		sum += 1 / A;
	}
	printf("%.8lf\n", 1 / sum);
	return 0;
}

Measured memory_bytes: 256
def partition(p, r):
    x = A[r]
    i = p - 1  # <xの右端
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A_tmp = A[i]
            A[i] = A[j]
            A[j] = A_tmp
    t = A[i+1]
    A[i+1] = A[r]
    A[r] = t
    return i+1


n = int(input())
A = [int(_) for _ in input().split()]
q = partition(0, n-1)
for i in range(n):
    if i:
        print(" ", end="")
    if i == q:
        print("[", end="")
    print(A[i], end="")
    if i == q:
        print("]", end="")
print("")



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

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

#define endl '\n'
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define int long long
#define pb push_back
#define f(i,l,r) for(ll i=l;i<=r;i++)
#define rf(i,r,l) for(ll i=r;i>=l;i--)
#define Max 5000001
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define d0(a) cout<<a<<' ';
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<' '<<b<<endl;
#define d3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define d4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
#define d5(a,b,c,d,e) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl;
#define d6(a,b,c,d,e,f) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<' '<<f<<endl;

const ll N=1e5+5,mod=1e9+7,bit=61;



signed main()
{
    fast;

    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n,k;
        cin>>k>>n;
        ll a[n];
        f(i,0,n-1)
        {
            cin>>a[i];
        }
        ll mx=a[0]+k-a[n-1];
        f(i,1,n-1)
        {
            mx=max(mx,a[i]-a[i-1]);
        }
        cout<<k-mx<<endl;
    }
    return 0;
}


















Measured memory_bytes: 1792
#include <stdio.h>

int main(void) {
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}else if(a>b){
		printf("a > b\n");
	}else {
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 1816
use std::io::{self, BufRead};

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let line = lines.next().unwrap().unwrap();
  let n: usize = line.parse().unwrap();
  let line = lines.next().unwrap().unwrap();
  let ps: Vec<i32> = line.split(' ').map(|x| x.parse().unwrap()).collect();
  let mut min = ps[0];
  let mut count = 1;
  for i in 1..n {
    if ps[i] <= min {
      min = ps[i];
      count += 1;
    }
  }
  println!("{}", count);
}

Measured memory_bytes: 8444
#include <stdio.h>

int main(void)
{
    double a, b, c, d, e, f;
    double A, B, C, D;
    double x, y;
    while(scanf("%lf%lf%lf%lf%lf%lf", &a, &b, &c, &d, &e, &f)!=EOF) {
        A=c*e-b*f; B=a*e-b*d;
        C=c*d-a*f; D=b*d-a*e;
        x=A/B; y=C/D;
        if(x==-0) x=0;
        if(y==-0) y=0;
        printf("%.3f %.3f\n", x, y);
    }
    return 0;
}


Measured memory_bytes: 2140
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

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

int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  rep(i, n) cin >> A[i];
  if (n == 2) {
    cout << max(A[0], A[1]) << endl;
    return 0;
  }
  vector<int> B(n);
  vector<int> C(n);
  B[0] = A[0];
  C[n-1] = A[n-1];
  rep(i, n-1) {
    B[i+1] = gcd(A[i+1], B[i]);
    C[n-2-i] = gcd(A[n-2-i], C[n-1-i]);
  }
  int ans = C[1];
  rep(i, n-2) {
    ans = max(ans, gcd(B[i], C[i+2]));
  }
  ans = max(ans, B[n-2]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4544
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
//i64 mod = 998244353;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;


template<typename IntType>
struct mat2d_t {
    mat2d_t(size_t h, size_t w) : h(h), w(w) {
        mat = std::vector<std::vector<IntType>>(h, std::vector<IntType>(w, 0));
    }
    mat2d_t(size_t h, size_t w, IntType init) : h(h), w(w){
        mat = std::vector<std::vector<IntType>>(h, std::vector<IntType>(w, init));
    }

    std::vector<IntType>& operator[](size_t p) {
        return mat[p];
    }

    const std::vector<IntType>& operator[](size_t p) const {
        return mat[p];
    }
    size_t height() const {
        return h;
    }
    size_t width() const {
        return w;
    }

private:
    std::vector<std::vector<IntType>> mat;
    size_t h;
    size_t w;
};


int main(int argc, char **argv) {
    i64 h, w, tg;
    cin >> h >> w >> tg;

    i64 hp_max = 1 << h;
    i64 wp_max = 1 << w;

    mat2d_t<i64> mt(h, w, 0);
    for (size_t i=0; i<h; ++i) {
        for (size_t j=0; j<w; ++j) {
            char c;
            cin >> c;
            mt[i][j] = c == '.' ? 0:1;
        }
    }
    i64 ans{0};
    for (i64 i=0; i<hp_max; ++i) {
        for (i64 j=0; j<wp_max; ++j) {
            i64 sum{0};
            i64 k=i, l;
            for (i64 m=0; m<h; ++m) {
                l=j;
                for (i64 n=0; n<w; ++n) {
                    if (l&1 && k&1) {
                        sum += mt[m][n];
                    }
                    l >>= 1;
                }
                k >>= 1;
            }
            if (sum == tg) ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <cmath>
#define MAX (int)1e4
#define M (int)1e2

using namespace std;

int num[MAX+1] = {};

int main(void){
  int N;
  cin >> N;
  if(N <= 5){
    for(int i=1;i<=N;i++){
      cout << 0 << endl;
    }
    return 0;
  }
  
  for(int x=1;x<=M;x++){
    for(int y=1;y<=M;y++){
      for(int z=1;z<=M;z++){
        int tmp = x*x + y*y + z*z + x*y + y*z + z*x;
        if(tmp <= MAX){
        	num[tmp] += 1;
        }
        //cout << tmp << endl;
      }
    }
  }
  //cout << "ok" << endl;
  for(int n=1;n<=N;n++){
    cout << num[n] << endl;
  }
  return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int prime(int i);

int main(void){
  int N,i,k,a[60];
  char str[100];
  
  fgets(str,sizeof(str),stdin);
  N=atoi(str);
  
  i=2,k=0;
  while(k<N){
   if(prime(i)==0 && i%5==1){
     a[k]=i;
     if(k==N-1){
      printf("%d\n",a[k]); 
     }else{
       printf("%d ",a[k]);
     }
     k++;
     
   }
    
   i++;
  }
  
  return 0;
}

int prime(int i){
  int j;
  
  if(i==2){
    return 0;
  }
  for(j=2;j<=(i/2)+1;j++){
    if(i%j==0){
      return 1;
    }
  }
  
   if(j>(i/2)+1){
     return 0;
   }
  return 0;
}

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 

	int n;
	cin >> n;
	vi v(n);
	rep(i , n){
		cin >> v[i];
	}
	SORT(v);
	cout << v[n - 1] - v[0];

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int lmin=0,rmax=n;
	for (int x=0;x<m;x++){
		int a,b;
		cin>>a>>b;
		if (a>lmin){
			lmin=a;
		}
		if (b<rmax){
			rmax=b;
		}
	}
	int ans=0;
	for (int x=lmin;x<=rmax;x++){
		ans++;
	}
	cout<<ans<<endl;
}

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

void Solve(){
	int n, m;
	cin>>n>>m;
	vector<int> g[n + 1];
	while(m--){
		int u, v;
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	vector<bool> vst(n + 1);
	queue<int> q;
	vector<int> res(n + 1);
	q.push(1);
	vst[1] = true;
	while(!q.empty()){
		int current = q.front();
		q.pop();
		for(auto x: g[current]){
			if(!vst[x]){
				vst[x] = true;
				q.push(x);
				res[x] = current;
			}
		}
	}
	cout<<"Yes\n";
	for(int i = 2; i <= n; i++) cout<<res[i]<<'\n';
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int T = 1;
	//cin>>T;
	while(T--){
		Solve();
	}
}

Measured memory_bytes: 10284
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        long[] ABCD=cin.ArrayLong(4,0);
        long A=ABCD[0];
        long B=ABCD[1];
        long C=ABCD[2];
        long D=ABCD[3];
        long ans=0;
        long X=0;
        long count=0;
        long LCM=C*D/cin2.GCDLong(C,D);
        if(C!=D)ans=(B-A+1)-(B/C-A/C+B/D-A/D-(B/LCM-A/LCM));
        else if(C==D)ans=(B-A+1)-(B/C-A/C);
        if(A%C==0||A%D==0)ans--;
      Console.WriteLine("{0}",ans);
        
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public static void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }//Answer.IntArrayAns(x);
    public static void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}



Measured memory_bytes: 13268
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double r= sc.nextDouble();
        double pi = Math.PI;
        double area = r*r*pi;
        double length = r*2*pi;
        System.out.printf("%f %f",area,length);
        sc.close();
    }
}


Measured memory_bytes: 28260
#include <iostream>
using namespace std;
#include <set>
#include <algorithm>
typedef long long ll;
const int N = 1e5+10;
int a[N];
int main()
{
	int n;
	cin >> n;
	
	for(int i = 1;i<=n;i++)
	{
		cin >> a[i];
	}
	ll sum = abs(a[1]-0);
	
	for(int i = 2;i<=n;i++)
	{
		sum +=abs(a[i]-a[i-1]);
	}
	
	sum+=abs(a[n]-0);
	
//	cout << sum << endl;
	for(int i = 1; i < n;i++)
	{
		ll res = sum - abs(a[i]-a[i-1])- abs(a[i+1]-a[i]) + abs(a[i+1]-a[i-1]);
		cout << res << endl;
	}
	
	cout << sum - abs(a[n]-a[n-1]) - abs(a[n]) + abs(a[n-1]);
	
	return 0;
}

Measured memory_bytes: 1792
N, M = map(int, input().split())

sss = []
for _ in range(M):
    k, *ss = map(lambda x: int(x) - 1, input().split())
    sss.append(ss)
ps = list(map(lambda x: x == '0', input().split()))

# 全てのスイッチのパターンをチェック
cnt = 0
for i in range(2 ** N):
    lights = ps[:]
    for j, ss in enumerate(sss):
        for s in ss:
            if i >> s & 1:
                lights[j] = not lights[j]
    if all(lights):
        cnt += 1

print(cnt)

Measured memory_bytes: 42732
n=int(input())
a=[int(x) for x in input().rstrip().split()]
cnt=[0 for i in range(n)]
for i in a:
  cnt[i-1]+=1

nc2=[]
for i in cnt:
  nc2.append(((i)*(i-1))//2)

All=sum(nc2)
for i in range(n):
  now=cnt[a[i]-1]-1
  print(All-nc2[a[i]-1]+((now)*(now-1))//2)


Measured memory_bytes: 26140
import math
a, b, h, m = map(int, input().split())
l_rad = m / 60 * 360
s_rad = h * 30 + m / 60 * 30
c_rad = abs(l_rad - s_rad) if abs(l_rad - s_rad) <= 180 else 360 - abs(l_rad - s_rad)
cos_c = math.cos(math.radians(c_rad))
if cos_c == 1:
    print(abs(a - b))
elif cos_c == -1:
    print(a + b)
else:
    print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * cos_c))

Measured memory_bytes: 9516
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk make_pair
#define pb push_back
#define eb emplace_back
#define ins insert
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=1e5+5;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int n,k,ans,id[MAXN],d[MAXN],a[MAXN],vis[MAXN];vector<int>G[MAXN];
void dfs(int x){d[x]=d[a[x]]+1;for(auto y:G[x])dfs(y);}
void bfs(int x){
	++ans;queue<int>q;q.push(x);
	for(;!q.empty();){
		int u=q.front();q.pop();if(!d[u])continue;d[u]=0;
		for(auto v:G[u])q.push(v);
	}
}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),k=read();
	Rep(i,1,n)a[i]=read();ans+=a[1]!=1,a[1]=1;
	Rep(i,2,n)G[a[i]].pb(i);dfs(1);
	Rep(i,1,n)id[i]=i;sort(id+1,id+n+1,[](int x,int y){return d[x]>d[y];});
	Rep(i,1,n)if(d[id[i]]>k+1){int x=id[i];Rep(i,1,k-1)x=a[x];bfs(x);}
	cout<<ans<<'\n';
	return 0;
}




Measured memory_bytes: 13384
#include <iostream>
using namespace std;
#define LEN 100005

struct Process {
  char name[100];
  int t;
};

Process Q[LEN];
int head,tail,n;

// tailの位置にxを追加する
void enqueue(Process x){
  // tailの位置に追加して，tailを増やす
  Q[tail] = x;
  tail = (tail+1)%LEN;
}

// headの位置の要素を取り出す
Process dequeue(){
  // headが指していた要素を返す
  Process x = Q[head];
  head = (head+1)%LEN;
  return x;
}

int isEmpty(){
  return head == tail;
}

int main(){
  int n;
  int q;
  cin >> n >> q;
  Process p;
  head = 1;
  tail = 1;

  for(int i=1;i<=n;i++){
    cin >> p.name >> p.t;
    enqueue(p);
  }

  int elaps = 0;
  while(!isEmpty()){
    Process p = dequeue();
    int diff = min(q,p.t);
    p.t -= diff;
    elaps += diff;
    if (p.t > 0){
      enqueue(p);
    }
    else{
      cout << p.name << " " << elaps << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 13256
#include<iostream>
#include<vector>
#include<string>

using ll = long long;

int main(){
    std::string S;
    std::cin >> S;
    ll tmp = 0;
    for(ll i = 0; i < S.size(); i++){
        tmp += S[i] - '0';
    }

    if(tmp % 9 == 0){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3752
#include <iostream>
#include <algorithm>

using namespace std;
char field[5][5];

bool isRectAngle(int x1, int y1, int x2, int y2)
{
	for (int i = x1; i <= x2; ++i)
	{
		for (int j = y1; j <= y2; ++j)
		{
			if (field[i][j] == '0')
			{
				return(false);
			}
		}
	}
	return(true);
}

void solve()
{
	int n;
	cin >> n;
	while (n--)
	{
		for (int i = 0; i < 5; ++i)
		{
			for (int j = 0; j < 5; ++j)
			{
				cin >> field[i][j];
			}
		}
		int maxArea = 0;
		for (int x1 = 0; x1 < 5; ++x1)
		{
			for (int y1 = 0; y1 < 5; ++y1)
			{
				for (int x2 = x1; x2 < 5; ++x2)
				{
					for (int y2 = y1; y2 < 5; ++y2)
					{
						if (isRectAngle(x1, y1, x2, y2))
						{
							maxArea = max(maxArea, (x2 - x1 + 1) * (y2 - y1 + 1));
						}
					}
				}
			}
		}
		cout << maxArea << endl;
	}
}

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

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <algorithm>
#include <cassert>
#include <string>

using namespace std;
using ll = long long;

int main()
{
	int n, m;
	cin >> n >> m;
	int food[m] = {0};
	for (int i = 0; i < n; i++){
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int tmp;
			cin >> tmp;
			food[tmp-1]++;
		}
	}

	int res = 0;
	for (int i = 0; i < m; i++) {
		if (food[i] == n)
			res++;
	}

	cout << res << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<string>
#include<iostream>
using namespace std;

int main(){
  long long int x[5];
  long long int n;
    cin >> n;
  for (long long int i = 0; i < 5; i++){
    cin >> x[i];
  }
  long long int min = x[0];
  long long int minindex = 0;
  for (long long int i= 1; i < 5; i++) {
    if(x[i] < min) {min = x[i];
    minindex = i;
    }
  }
  long long int res;
  if(n%min == 0) res = n/min;
  else res = n/min + 1;

  cout << res + 4;

  //long long int state[5] = {n, 0, 0, 0, 0}
  //bool check = false;
  // long long int res = n/x[0]+1+4;
  // while(check){
  //   for (long long int i = 1; i < 5; i++ ){
  //     if(x[i] - x[i-1] < 0){

  //     }

  //   }
  // }


}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
N, M, L = map(int, input().split())
ABC = [list(map(int, input().split())) for _ in range(M)]
Q = int(input())
st = [list(map(int, input().split())) for _ in range(Q)]


def wf(d):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k]+d[k][j])

d = [[float('inf') for _ in range(N)] for _ in range(N)]

for abc in ABC:
    d[abc[0]-1][abc[1]-1] = abc[2]
    d[abc[1]-1][abc[0]-1] = abc[2]
for i in range(N):
    d[i][i] = 0
wf(d)

for i in range(N):
    for j in range(N):
        if d[i][j] <= L:
            d[i][j] = 1
        else:
            d[i][j] = float('inf')

wf(d)

for sti in st:
    res = d[sti[0]-1][sti[1]-1]
    if res == float('inf'):
        print(-1)
    else:
        print(res-1)

Measured memory_bytes: 131804
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<string>
#include<list>
using namespace std;
typedef long long llong;
llong gcd(llong a, llong b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通

int N, A, B;
int main() {
	cin >> N >> A >> B;
	int C = B - A;
	if (C % 2 == 1) cout << "Borys";
	else cout << "Alice";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;
int n;
int a[101];

signed main(){
    cin >> n;
    int mini = 110;
    int maxi = -1;
    rep(i,n){
        int val;
        cin >> val;
        a[val]++;
        mini = min(mini,val);
        maxi = max(maxi,val);
    }

    if(a[mini] == 1){
        if(maxi != mini*2){
            cout << "Impossible" << endl;
            return 0;
        }
        
        for(int i = mini+1;i <= maxi;i++){
            if(a[i] < 2){
                cout << "Impossible" << endl;
                return 0;
            }
        }
        cout << "Possible" << endl;
    }else if(a[mini] == 2){
        if(maxi != mini*2-1){
            cout << "Impossible" << endl;
            return 0;
        }
        for(int i = mini+1;i <= maxi;i++){
            if(a[i] < 2){
                cout << "Impossible" << endl;
                return 0;
            }
        }
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }



    

    return 0; 
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_d
// rm -r -f test;oj dl http://agc005.contest.atcoder.jp/tasks/agc005_c

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++)
        cin >> a[i];

    ll res = 0;
    ll r = 0;
    ll total = 0;
    for (ll l = 0; l < n; l++)
    {
        while (r < n && (total ^ a[r]) == (total + a[r]))
        {
            total += a[r];
            ++r;
        }
        res += (r - l);
        if (l == r)
            ++r;
        else
        {
            total -= a[l];
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 1792
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        double a = sc.nextInt();
        double res = 0;
        if(a % 2 == 0){
            res = 0.5;
        }else{
            res = ((a + 1) / 2) / a;
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 21844
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif
#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;
const int MO=1e9+7; 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
void solve(){
	vector<int> v(3);
	map<int,int> m;
	for(auto& it:v){
		cin>>it;
		m[it]++;
  }
  for(auto it:m)if(it.s==1)cout<<it.f;
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
    IOS;
    solve();
    #ifdef LOCAL_DEFINE
    cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
    #endif
}

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

int main() {
    int a, b;  cin >> a >> b;
    if (a*b % 2 != 0)  cout << "Yes" << endl;
    else  cout << "No" << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N, K;
ll H[200000];
signed main(){
	cin >> N >> K;
	rep(i, N) cin >> H[i];
	sort(H, H+N);
	reverse(H, H+N);
	ll ans = 0;
	rep(i, N){
		if(K > 0){
			K--;
			continue;
		}
		ans += H[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
using System;
class Test
{
    public static void Main()
    {
        while(true)
        {
            string[] str = Console.ReadLine().Split(' ');
            int x = int.Parse(str[0]);
            int y = int.Parse(str[1]);
            if (x == 0 && y == 0) break;
            if(x > y)
            {
                int t = y;
                y = x;
                x = t;
            }
            Console.WriteLine(x + " " + y);
        }
    }
}

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

int main(){
    ll a, b;
    cin >> a >> b;
    ll m = -1;
    if (a * b > 0){
        ll thr = min(b, m);
        if ((abs(a - thr) + 1)%2 == 0) cout << "Positive" << endl;
        else if (a >= 1) cout << "Positive" << endl;
        else cout << "Negative" << endl;
    }
    else cout << "Zero" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define itc ll t;cin>>t;while(t--)
#define otc ll t=1;while(t--)
#define PI 3.141592653589793238
//ang=(PI*ang)/180.0 in radian
#define Max(a,b,c) max(a,max(b,c));
#define all(v) v.begin(),v.end()
#define ll long long int
#define ld long double
#define pb push_back
#define eb emplace_back
#define gcd(a,b) __gcd(a,b)
#define fi first
#define se second
int dx[4] = {0, -1, 0, 1};
int dy[4] = {1, 0, -1, 0};
int main()
{
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
	ll x, y;
	cin >> x >> y;
	if (y >= 2 * x && y <= 4 * x && y % 2 == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define double long double
#define ll long long
#define INF LLONG_MAX/3
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
#define ggr getchar();getchar();return 0
using namespace std;
string s,t,r;
int a[50010],b[50010];
int ans=0;
signed main(){
	cin>>s;
	for(char i:s){
		if(i!='x')t+=i;
	}
	r=t;
	reverse(r.begin(),r.end());
	if(t!=r){
		cout<<-1<<endl;
		return 0;
	}
	int now=0;
	rep(i,(t.size()+1)/2){
		while(s[now]=='x'){
			a[i]++;
			now++;
		}
		now++;
	}
	now=s.size()-1;
	rep(i,(t.size()+1)/2){
		while(s[now]=='x'){
			b[i]++;
			now--;
		}
		now--;
	}
	int ans=0;
	rep(i,(t.size()+1)/2){
		ans+=abs(a[i]-b[i]);
	}
	cout<<ans<<endl;
	ggr;
}

Measured memory_bytes: 1024
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////



int main(){
    itn n;
    cin >> n;
    int a[n];
    inrep(n,a);
    int b[n] = {};
    b[0] = a[0];
    
    rep(i,1,n){
	b[i] = min(b[i-1],a[i]);
    }
    
    itn cnt = 0;
    rep(i,0,n)if(a[i] <= b[i])cnt++;
    P(cnt);
    return  0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
  int a,b,work;
  int digit = 0;

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

    digit = 0;
    work = a + b;
    while (work!=0){
      work /= 10;
      digit++;
    } 

    printf("%d\n",digit);
  }

  return 0;
}

Measured memory_bytes: 596
import numpy as np



N,M =[int(i) for i in input().split()]

a = np.ones(M)
b = np.ones(M)

for i in range(M):
    a[i],b[i] = [int(j) for j in input().split()]
    
ans = np.zeros(N)
    
for i in range(M):
    A = int(a[i]-1)
    B = int(b[i]-1)
    ans[A]+=1
    ans[B]+=1
    
for i in range(N):
    print(int(ans[i]))
    


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

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////



int main() {

	string S;
	cin >>S;

	ll N=S.size();

	for(ll i=N-2; i>0;i-=2){
		ll b=1;
		ll K=i/2;
		rep(j,K){if(S[j]!=S[j+K]){b=0;}}
		if(b==1){cout <<i; break;}
	}
  
	

}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/



////////////////////////////////////////


int main(){
    string s;cin>>s;int len=s.size();
    int pcount=0;for(int i=0;i<=len-1;i++)if(s[i]=='p')pcount++;
    cout<<len/2-pcount<<endl;
    
    return 0;
}

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


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int p = 1, ans = 0;
    for (int i = 0; i < n; i++)
    {
        if(a[i] == p) ++p;
        else ++ans;
    }
    if(ans == n) cout << -1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	static final int MOD = (int) 1e9 + 7;

	int N;
	int[] memo;

	List<Integer> primes;

	public ArrayList<Integer> getPrimes(int n){

		ArrayList<Integer> ret = new ArrayList<Integer>();

		for(int i = 2;i <= n;i++){

			boolean isPrime = true;

			for(int j = 2;j * j <= i;j++){
				if(i%j==0){
					isPrime = false;
					break;
				}
			}

			if(isPrime){
				ret.add(i);
			}
		}

		return ret;
	}

	public void solve() {
		N = nextInt();
		primes = getPrimes(1000);

		memo = new int[1000 + 1];
		for (int i = 2; i <= N; i++) {

			int tmp = i;
			for(int p : primes){
				while(tmp > 0 && tmp % p == 0){
					tmp /= p;
					memo[p]++;
				}
			}
		}

		long[][] dp = new long[1000+2][10000 + 1];
		dp[2][0] = 1;
		for (int i = 2; i <= 1000; i++) {
			for (int j = 0; j <= memo[i]; j++) {
				if (j + 1 <= memo[i]){
					dp[i][j + 1] += dp[i][j];
					dp[i][j + 1] %= MOD;
				}
				dp[i + 1][0] += dp[i][j];
				dp[i + 1][0] %= MOD;
			}
		}

		out.println(dp[1001][0]);
	}

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

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

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

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

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

Measured memory_bytes: 130892