akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(x, y) x = max(x, y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}



int main(){
  int n; cin >> n;
  vector<int> a(n);
  ll sum = 0;
  rep(i, n){
    cin >> a[i];
    sum += a[i];
  }
  vector<mint> sums(n);
  rep(i, n){
    sum -= a[i];
    sums[i] = sum;
  }

  mint ans = 0;
  rep(i, n){
    ans += sums[i] * a[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5580
n = int(input())
h = list(map(int, input().split()))
dp = [float('inf')]*n
dp[0] = 0
for i in range(1, n):
    dp[i] = min(dp[i], dp[i-1] + abs(h[i]-h[i-1]))
    if i > 1:
        dp[i] = min(dp[i], dp[i-2] + abs(h[i]-h[i-2]))
print(dp[n-1])

Measured memory_bytes: 13980
#include<stdio.h>
#define N 500000
#define M 2000000000
void merge(int *,int,int,int);
void mergesort(int *,int,int);
int L[(N/2)+2],R[(N/2)+2];
int cnt;
 
int main(){
  int A[N],n,i;
  cnt=0;
  scanf("%d", &n);
 
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  mergesort(A,0,n);
  for(i=0;i<n-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n%d\n",A[n-1],cnt);
  return 0;
}
 
void merge(int A[],int left,int mid,int right){
int n1,n2,i,j,k;
  n1=mid-left;
  n2=right-mid;
  for(i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
  L[n1]=M;
  R[n2]=M;
  i=0;
  j=0;
  for (k = left;k < right;k++){
    cnt++;
    if(L[i]<=R[j]){
      A[k]=L[i];
      i=i+1;
    }
    else{
      A[k]=R[j];
      j=j+1;
    }
  }
}
 
void mergesort(int A[],int left,int right){
int mid;
if(left+1<right){
  mid=(left+right)/2;
  mergesort(A,left,mid);
  mergesort(A,mid,right);
  merge(A,left,mid,right);
  }
}

Measured memory_bytes: 4500
#include <bits/stdc++.h>
using namespace std;
#define ri rd<int>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; --i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++i)
const int maxN = 3e5 + 7;

template<class T> T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - '0'; return f ? x : -x;
}

int n;
char s[maxN];
int c[maxN][2];

int main() {

	n = ri();
	scanf("%s", s+1);
	rep (i, 1, n) {
		c[i][0] = c[i-1][0];
		c[i][1] = c[i-1][1];
		if (s[i] == 'W') c[i][0]++;
		else c[i][1]++;
	}

	int res = n;
	rep (i, 1, n) {
		res = min(c[i-1][0] + (c[n][1] - c[i][1]), res);
	}
	printf("%d\n", res);
	
	return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define nu 100005
typedef long long int ll;
typedef vector<ll> vi;
vi ad[nu];

ll h[nu];

bool vis[nu];

void dfs(ll u)
{
    vis[u]=1;
    for(ll x : ad[u])
    {
        if(vis[x])            
            continue;
        dfs(x);
    }
    for(ll x :ad[u])
    {
        h[u]=max(h[u],h[x]+1);
    }
}

int main()
{
    ll n,m,x,y,i,j,mx=0;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        ad[x].push_back(y);
    }
    for(i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            dfs(i);
            mx=max(h[i],mx);
        }
    }
    cout<<mx<<"\n";
    return 0;
}

Measured memory_bytes: 8576
n = int(input())
a = sorted(map(int, input().split()))
b = sorted(map(int, input().split()))
c = sorted(map(int, input().split()))
p = 0
ans = 0
f = []
g = [0] * n
for i, x in enumerate(b):
    while p < n and x >= c[p]:
        p += 1
    f.append(n - p)
for i in range(n - 1, -1, -1):
    g[i] = f[i] + (g[i + 1] if i < n - 1 else 0)
p = 0
for i, x in enumerate(a):
    while p < n and x >= b[p]:
        p += 1
    ans += g[p] if p < n else 0
print(ans)


Measured memory_bytes: 24372
import sys 
from collections import Counter
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
l = read().decode().split()
c = Counter(l)
max = c.most_common()[0][1]
ans = [i[0] for i in c.items() if i[1] >= max]
print('\n'.join(sorted(ans)))

Measured memory_bytes: 50168
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=110000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  double r;
  cin >> r;
  cout << fixed << setprecision(10) <<2*pi*r << endl;
  return 0;
}


Measured memory_bytes: 3804
N, M = map(int,input().split())
f = []
for i in range(N):
  f.append(list(map(int,input().split())))
c = 0
for i in range(M):
  b = False
  for j in range(N):
    if not i+1 in f[j][1:]:
      b = True
      break
      
  if not b:
    c+=1
print(c)
    

Measured memory_bytes: 9116
from itertools import permutations

N, M = map(int, input().split())
lines = [[False] * 9 for _ in range(9)]
for _ in range(M):
    a, b = map(int, input().split())
    lines[a][b] = True
    lines[b][a] = True


counter = 0
for perm in permutations(range(2, N+1)):
    if lines[1][perm[0]]:
        if all(lines[perm[i]][perm[i+1]] for i in range(N-2)):
            counter += 1

print(counter)


Measured memory_bytes: 41820
def main():

    a = int(input())
    b = int(input())
    c = int(input())
    x = int(input())
    cnt = 0

    for i in range(a+1):
        for j in range(b+1):
            for k in range(c+1):
                if 500*i+100*j+50*k==x:
                    cnt += 1
    print(cnt)

if __name__ == "__main__":
    main()

Measured memory_bytes: 38896
#include <iostream>
#include <climits>


typedef struct{
	int x;
	int y;
}Point;


bool isEnterInArea(const Point p, const Point c1, const Point c2){


	if(p.x >= c1.x && c2.x >= p.x &&
	   p.y >= c1.y && c2.y >= p.y){

		return true;
	}
	return false;
}


int main(void){

	int n, k;
	std::cin >> n >> k;

	Point* p = new Point[n];
	for(int i = 0; i < n; i++){
		std::cin >> p[i].x >> p[i].y;
	}

	unsigned long long minArea = ULLONG_MAX;
	Point c1, c2;
	for(int x1 = 0; x1 < n; x1++){
		for(int x2 = 0; x2 < n; x2++){

			if(p[x1].x > p[x2].x){ continue;}

			for(int y1 = 0; y1 < n; y1++){
				for(int y2 = 0; y2 < n; y2++){

					if(p[y1].y > p[y2].y){ continue;}

					c1.x = p[x1].x;
					c1.y = p[y1].y;
					c2.x = p[x2].x;
					c2.y = p[y2].y;


					// 入ってる点を探索
					int cnt = 0;
					for(int i = 0; i < n; i++){
						if(isEnterInArea(p[i], c1, c2)){
							cnt++;
						}
					}

					unsigned long long area = (c2.x - c1.x);
					area *= (c2.y - c1.y);
					if(cnt >= k && minArea > area){
						minArea = area;
					}
				}
			}
		}
	}

	std::cout << minArea << std::endl;

	delete[] p;

	return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
d=list(map(int,input().split()))
l=[0,1,2,3,4,5,6,7,8,9]
for i in range(k):
  l.remove(d[i])
L=[]
for j1 in range(len(l)):
  for j2 in range(len(l)):
    for j3 in range(len(l)):
      for j4 in range(len(l)):
        for j5 in range(len(l)):
          L.append(l[j1]*10000+l[j2]*1000+l[j3]*100+l[j4]*10+l[j5])
for j1 in range(len(l)):
  for j2 in range(len(l)):
    for j3 in range(len(l)):
      for j4 in range(len(l)):
        L.append(l[j1]*1000+l[j2]*100+l[j3]*10+l[j4])
for j1 in range(len(l)):
  for j2 in range(len(l)):
    for j3 in range(len(l)):
      L.append(l[j1]*100+l[j2]*10+l[j3])
for j1 in range(len(l)):
  for j2 in range(len(l)):
    L.append(l[j1]*10+l[j2])
for j1 in range(len(l)):
  L.append(l[j1])
L.sort()
for k in range(len(L)):
  if L[k]>=n:
    x=L[k]
    break
print(x)

Measured memory_bytes: 5744
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL<<60;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define rep(i,e) for(int i=0;i<(e);++i)

long long dist[200][200];
int N, M, R, a, b, c, rt;

int main() {
  cin >> N >> M >> R;
  vector<int> r;

  rep(i, 200)rep(j, 200){
    if(i==j) dist[i][j] = 0;
    else dist[i][j] = INF;
  }

  rep(i, R){
    cin >> rt;
    r.push_back(--rt);
  }
  rep(i, M){
    cin >> a >> b >> c;
    a--; b--;
    dist[a][b] = c;
    dist[b][a] = c;
  }

  rep(k, N)rep(i, N)rep(j, N){
    dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
  }

  long long ans = INF;
  sort(r.begin(), r.end());
  do {
    long long cur = 0;
    rep(i, R-1) cur += dist[r[i]][r[i+1]];
    ans = min(ans, cur);
  } while (next_permutation(r.begin(), r.end()));

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

Measured memory_bytes: 512
file = $stdin
lines = file.readlines
file.close

groupedInput = lines.group_by{|i| i % 100}
tmpMax = groupedInput.max_by{|_, val| val.length}
maxNum = groupedInput.select{|key, val| val.length == tmpMax[1].length}.keys

maxNum.each do |i|
	p i.to_i
end 

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

int ary[20];
int main(){
	int N,b=0,c=0;
	cin>>N;
	for(int i=1;i<=N;i++){
		b=c=0;
		for(int j=1;j<=10;j++){
			cin>>ary[j];
		}
		bool fla=true;
		for(int j=1;j<=10;j++){
			if(b<c) swap(b,c);
			if(ary[j]>b) b=ary[j];
			else if(ary[j]>c) c=ary[j];
			else{
				fla=false;
				break;
			}
		}
		if(fla) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}

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

int main( void )
{
        double x1 = 0, y1 = 0, x2 = 0, y2 = 0, x3 = 0, y3 = 0;
        double xp = 0, yp = 0;
        double sum = 0, s = 0, s1 = 0, s2 = 0, s3 = 0;

        while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp) != EOF)
        {
                s = fabs(((x1 * y2) + (x2 * y3) + (x3 * y1) - (y1 * x2) - (y2 * x3) - (y3 * x1)) / 2.0);

                s1 = fabs(((x1 * y2) + (x2 * yp) + (xp * y1) - (y1 * x2) - (y2 * xp) - (yp * x1)) / 2.0);
                s2 = fabs(((xp * y2) + (x2 * y3) + (x3 * yp) - (yp * x2) - (y2 * x3) - (y3 * xp)) / 2.0);
                s3 = fabs(((x1 * yp) + (xp * y3) + (x3 * y1) - (y1 * xp) - (yp * x3) - (y3 * x1)) / 2.0);

                sum = s1 + s2 + s3;

                if((0.0 <= fabs(s - sum) && fabs(s - sum) < 0.001) && ( s1 != 0 && s2 != 0 && s3 != 0))
                {
                        printf("YES\n");
                }
                else
                {
                        printf("NO\n");
                }
        }
        return 0;
}

Measured memory_bytes: 612
n = int(input())
a = []
b = []
for i in range(n):
    c = list(map(int,input().split()))
    a.append(c[0])
    b.append(c[1])
for i in range(n-1):
    d = max(1,-(-a[i]//a[i+1]),-(-b[i]//b[i+1]))
    a[i+1] =a[i+1]*d
    b[i+1] =b[i+1]*d
print(a[-1]+b[-1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define mp make_pair
#define sz(x) (int)((x).size())
#define all(x) (x).begin(),(x).end()
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define eb emplace_back
 
typedef pair< int, int > pii;
typedef pair< long long, long long > pll;
typedef long long ll;
typedef unsigned long long ull;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< ll > vll;
typedef vector< vll > vvll;
typedef vector< pii > vpii;
typedef vector< vpii > vvpii;
typedef vector< pll > vpll;
typedef long double ld;
typedef vector< ld > vld;
typedef unsigned int uint;
 
template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    const bool operator<(const M& o) const {return v < o.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
 
using Mint = ModInt<(int)1e9 + 7>;


int main() { 
    #ifdef BLAT
        freopen("stdin", "r", stdin);
        freopen("stderr", "w", stderr);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    ll a, b, v, w, t;

    cin >> a >> v >> b >> w >> t;

    cout << (abs(a-b) <= (v - w)*t ? "YES" : "NO") << '\n';
    return 0; 
}

Measured memory_bytes: 3652
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

#ifdef LOCAL
#include "../ACL.hpp"
#else
#include <atcoder/all>
#endif

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


template<typename T = long long>
class SegmentTree {
    void update(int k) {
        while (k > 0) {
            k = (k - 1) / 2;
            ary[k] = ope(ary[2 * k + 1], ary[2 * k + 2]);
        }
    }
public:
    std::vector<T> ary;
    int n;
    const T default_value = 0;
    SegmentTree(int n) {
        this->n = 1;
        while (this->n < n) this->n *= 2;
        ary.resize(this->n * 2 - 1, default_value); // sum -> 0, min -> INF, 0?
    }
    T ope(T l, T r) {
        return std::max(l, r);
    }
    void add(int k, T d) {
        k += n - 1;
        ary[k] += d;
        update(k);
    }
    void update(int k, T d) {
        k += n - 1;
        ary[k] = ope(ary[k],d);
        update(k);
    }
    T query(int a, int b) {
        return query(a, b, 0, n, 0);
    }
    T query(int a, int b, int l, int r, int i) {
        if (a <= l && b >= r) return ary[i];
        if (a >= r || b <= l) return 0; // sum
        // if (a >= r || b <= l) return default_value; // min
        int m = (l + r) / 2;
        T vl = query(a, b, l, m, 2 * i + 1);
        T vr = query(a, b, m, r, 2 * i + 2);
        return ope(vl, vr);
    }
};

void solve() {
    LL n,k;
    cin >> n >> k;
    VLL a(n);
    REP(i,0,n) cin >> a[i];
    VI dp(n,1);
    SegmentTree<> seg(300000+1);
    seg.update(a[0],1);
    REP(i,1,n) {
        dp[i] = seg.query(max(0LL,a[i]-k),min(300000LL+1,a[i]+k+1)) + 1;
        seg.update(a[i],dp[i]);
    }
    cout << *max_element(all(dp)) << endl;

    // REP(i,0,n) cerr << i << ", " << dp[i] << endl;
}

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

Measured memory_bytes: 14920
#include<bits/stdc++.h>
using namespace std;
bool col[1000005];
bool row[1000005];
long long mod=1e9+7;
int main(){
	int n,m,a,b;
	long long ans=1;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
	cin>>a;
	if(row[a])
	{
		cout<<0;
		return 0;
	}
	row[a]=1;
	}
	for(int i=1;i<=m;i++)
	{
	cin>>b;	
	if(col[b])
	{
		cout<<0;
		return 0;
	}
	col[b]=1;
	}
	long long c=0,r=0;
	for(int i=n*m;i>0;i--){
        long long tc=c,tr=r;
        if(col[i]) 
		{
		tc=1;
		c++;
		}
        if(row[i]) 
		{
		tr=1;
		r++;
		}
        if(col[i]||row[i]) 
		ans*=(tc*tr)%mod;
        else 
		ans*=(tc*tr-(n*m-i))%mod;
		ans%=mod;
    }
	cout<<ans%mod;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std;

const int Maxn = 100010;
int n;
int a[Maxn];

inline bool comp(const int &x , const int &y) {
	return x > y;
}

int main() {
	
	scanf("%d",&n);
	for(register int i=1; i<=n; i++)
		scanf("%d",&a[i]);
	
	sort(a+1,a+n+1,comp);
	
	register int x = 1;
	for(; x<=n; x++)
		if(a[x] < x)
			break;
	x --;
	
	register int u = a[x] - x;
	register int v = x;
	for(; v<=n; v++)
		if(x > a[v])
			break;
	v -= x + 1;
	
	if(u % 2 == 1 || v % 2 == 1)	puts("First");
	else	puts("Second");
	
	return 0;
	
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
 
 
 
 
 
 
 




 char s[1005][1005];
 int dist[1005][1005];
 int dx[]={1,-1,0,0};
 int dy[]={0,0,-1,1};
int main()
{
    int h,w;
    cin>>h>>w;
   
    for(int i=1;i<=h;i++){
         string t;
         cin>>t;
         for(int j=0;j<t.length();j++){
              s[i][j+1]=t[j];
         }
    }
    memset(dist,-1,sizeof(dist));
    queue<pair<int,int>> q;
    for(int i=1;i<=h;i++){
         for(int j=1;j<=w;j++){
              if(s[i][j]=='#'){
                   q.push({i,j});
                   dist[i][j]=0;
              }
         }
    }
    int ct=0;
    while(!q.empty()){
         int x=q.front().fi,y=q.front().se;
         q.pop();
         for(int i=0;i<4;i++){
              int nx=x+dx[i],ny=y+dy[i];
              if(nx<1||nx>h||ny<1||ny>w||s[nx][ny]=='#')continue;
              if(dist[nx][ny]==-1){
                   dist[nx][ny]=1+dist[x][y];
                   q.push({nx,ny});
              }
         }

    }
    int mx=0;
    for(int i=1;i<=h;i++){
         for(int j=1;j<=w;j++){
              mx=max(mx,dist[i][j]);
         }
    }
    cout<<mx;

}




































Measured memory_bytes: 16040
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define rep(I,N) up(I,0,N-1)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<"\n";}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<"\n";}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<"\n";}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<"\n";}
inline void                                              out(ld p){printf("%.12Lf\n",p);}
template<class T>inline void outml(T p){for_each(all(p),out<decltype(p[0])>);}//ml=multi line
template<class T>inline void outol(T V){auto n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}//ol=one line
vector<bool>used;
ll ans;
void dfs(vector<vector<ll>>&g,ll now){
  bool f=true;
  for(auto result:used){
    if(!result){
      f=false;
      break;
    }
  }
  if(f)ans++;
  for(auto e:g[now]){
    if(!used[e]){
      used[e]=true;
      dfs(g,e);
      used[e]=false;
    }
  }
}
inline void solve(void){
  ll n,m;
  in(n,m);
  used.resize(n);
  vector<vector<ll>>g(n);
  rep(i,m){
    ll a,b;
    in(a,b);
    a--;b--;
    g[a].pb(b);
    g[b].pb(a);
  }
  used[0]=true;
  dfs(g,0);
  out(ans);
}
int main(void){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int i,cnt=0,a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++){
		if(c%i==0){
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <unordered_set>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long

int n;

void process(int indexBg, bool isMaleBg, int indexEd, bool isMaleEd)
{
    int index = (indexBg + indexEd) / 2;

    printf("%d\n", index);
    fflush(stdout);
    string s;

    cin >> s;
    if (s == "Vacant")
    {
        printf("%d\n", index);
        fflush(stdout);
        return;
    }

    bool isMale = (s == "Male");

    bool firstHalf =
        ((index - indexBg) % 2 == 0 && isMaleBg != isMale) ||
        ((index - indexBg) % 2 == 1 && isMaleBg == isMale);

    if (firstHalf)
        process(indexBg, isMaleBg, index, isMale);
    else
        process(index, isMale, indexEd, isMaleEd);
}

int main(void)
{
    scanf("%d", &n);

    printf("%d\n", 0);
    fflush(stdout);

    string s;
    cin >> s;
    if (s == "Vacant")
    {
        printf("%d\n", 0);
        fflush(stdout);
        return 0;
    }

    bool isMale = (s == "Male");
    process(0, isMale, n, isMale);

    return 0;
}


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

using namespace std;

int main() {
    double t1, t2;
    int r1, r2;
    string rank[] = { "AAA", "AA", "A", "B", "C", "D", "E", "NA" };
    while (cin >> t1 >> t2) {
        if (t1 <= 360.0) {
            r1 = 7;
        }
        if (t1 < 70.0) {
            r1 = 6;
        }
        if (t1 < 55.0) {
            r1 = 5;
        }
        if (t1 < 50.0) {
            r1 = 4;
        }
        if (t1 < 43.0) {
            r1 = 3;
        }
        if (t1 < 40.0) {
            r1 = 2;
        }
        if (t1 < 37.50) {
            r1 = 1;
        }
        if (t1 < 35.50) {
            r1 = 0;
        }
        
        if (t2 <= 360.0) {
            r2 = 7;
        }
        if (t2 < 148.0) {
            r2 = 6;
        }
        if (t2 < 116.0) {
            r2 = 5;
        }
        if (t2 < 105.0) {
            r2 = 4;
        }
        if (t2 < 89.0) {
            r2 = 3;
        }
        if (t2 < 83.0) {
            r2 = 2;
        }
        if (t2 < 77.0) {
            r2 = 1;
        }
        if (t2 < 71.0) {
            r2 = 0;
        }
        cout << rank[max(r1, r2)] << endl;
    }

    return 0;
}

Measured memory_bytes: 1228
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A, ll x = 10){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; 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 comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}


ll val, len;
void solve(){
  cin >> val >> len;
  if(val % 2 == 0){
    cout << val/2 << " ";
    rep(i, len-1){
      cout << val << " ";
    }
    cout << endl;
    return;
  }
  vector<ll> ans(len, (val+1)/2);

  ll dec = len / 2;
  rep(_, dec){
    if(ans.back() == 1){
      ll al = ans.size();
      ans.resize(al-1);
    }else{
      ans.back()--;
      while(ans.size() < len){
        ans.pb(val);
      }
    }
  }
  rep(i, ans.size()){
    cout << ans[i] << " ";
  }
  cout << endl;

}

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


Measured memory_bytes: 4608
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    A = LI()
    leftThanMe = [0 for _ in range(N+1)]
    rightThanMe = [0 for _ in range(N+1)]
    for i in range(N-1):
        leftThanMe[i+1] = A[i] + leftThanMe[i]
    for i in range(1, N)[::-1]:
        rightThanMe[i-1] = A[i] + rightThanMe[i]
    ans = inf
    for i in range(N-1):
        val = abs(leftThanMe[i] + A[i] - rightThanMe[i])
        ans = min(ans, val)
    print(ans)
main()



Measured memory_bytes: 31008
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  double N, L;
  cin >> N >> L;
  double sum = N * N / 2 - N / 2 + N * L;
  debug(sum);
  if (L > 0) {
    sum -= L;
  } else if (1 - N > L) {
    sum -= L + N - 1;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}

vector<ll> pw2(51,1);vector<ll> pw10(19,1);
int main(){
    {rep1(i,50) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N,K; cin>>N>>K;
    ll ans=0;
    vector<ll> A(N,0);
    rep(i,N) cin>>A[i];
    ll tmp=0;
    rep(i,N-1)FOR(j,i+1,N){
        if(A[i]>A[j]) tmp++;
    }
    ans+=tmp*K;
    ans%=MOD;
    
    map<ll,ll> m;
    //*K(K-1)/2
    rep(i,N){
        if(m.find(A[i])==m.ed) m[A[i]]=1;
        else m[A[i]]++;
    }
    tmp=0;
    ll tmtmp=0;
    for(auto it=m.bg;it!=m.ed;it++){
        tmtmp+=(tmp*(it->b))%MOD;
        tmtmp%=MOD;
        tmp+=(it->b);
        tmp%=MOD;
    }
    ll tmpK=(K*(K-1))/2;
    tmpK%=MOD;
    ans+=(tmtmp*tmpK)%MOD;
    ans%=MOD;
    cout<<ans<<endl;
}



Measured memory_bytes: 3624
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	string N;
	cin >> N;
	if((N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3])){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int  main(){
  int a,b;
  cin >> a>> b;
  int c[b];
  int yon = 0;
  rep(i,b){
    cin >> c[i];
    yon +=c[i];
  }
  if(a-yon>=0){
    cout << a-yon << endl;
  }else{
    cout << -1 << endl;
  }
 return 0;
}

Measured memory_bytes: 3656
using static System.Console;

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadLine();
            var nInt = int.Parse(n);
            var nca = n.ToCharArray();
            var nDoublets = Doublets(nca[0]);

            WriteLine((nInt <= nDoublets) ? nDoublets : Doublets((char)(nca[0] + 1)));
        }

        private static int Doublets(char c)
        {
            var cs = c.ToString();
            return int.Parse(cs + cs + cs);
        }


    }
}


Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
        double x = 0;
        double y = 0;
        int arg = 90;
        while(true){
        	String[] st = input.nextLine().split(",");
        	int rx = Integer.parseInt(st[0]);
        	int a = Integer.parseInt(st[1]);
        	if(rx == 0 && a == 0)break;
        	y += rx*Math.sin(Math.toRadians(arg));
        	x += rx*Math.cos(Math.toRadians(arg));
        	arg -= a;
        }
        System.out.println((int)x);
        System.out.println((int)y);
    }    
}

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

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define all(x) (x).begin(),(x).end()
#define cAll(x) (x).cbegin(),(x).cend()
#define COUT(x) cout << x << endl
//#define int long long

template<typename T> constexpr auto square(T x) { return (x) * (x); }

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

const int MOD = 1000000007;
const int INF = INT_MAX;

signed main()
{
	int N, D;
	cin >> N >> D;

	int watch = 2 * D + 1;

	int ans;
	if (N % watch == 0) ans = N / watch;
	else ans = N / watch + 1;

	COUT(ans);

	return 0;
}


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

int cnt=0;

void merge(int *A,int left,int mid,int right){
  int n1 = mid-left;
  int n2 = right-mid;
  int i,j,k;
  int L[N],R[N];
  
  for(i=0;i<=n1-1;i++){
    L[i] = A[left+i];
  }
  for(i=0;i<=n2-1;i++){
    R[i] = A[mid+i];
  }
  L[n1] = INFINITY;
  R[n2] = INFINITY;
  i=0;
  j=0;
  for(k=left;k<=right-1;k++){
    cnt++;
    if(L[i]<=R[j]){
      A[k] = L[i];
      i++;
    }
    else {
      A[k] = R[j];
      j++;
    }
  }
}
void mergeSort(int *A,int left,int right){
  int mid;
  if(left+1<right){
    mid = (left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}
int main(){
  int n,S[N],i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  mergeSort(S,0,n);
  for(i=0;i<n;i++){
    if(i==n-1) printf("%d\n",S[i]);
    else printf("%d ",S[i]);
  }

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



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

int main(){
  string str;
  cin >> str;
  if (str == "Sunny") {
    cout << "Cloudy" << endl;
  }else if (str == "Cloudy"){
  	cout << "Rainy" << endl;
  }else{
    cout << "Sunny" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "main.cpp"

long long solve(int N, const std::vector<long long> &L) {
  // TODO: edit here

  int ans = 0;
  REP(i, N) {
    FOR(j, i + 1, N) {
      FOR(k, j + 1, N) {
        vi a(3, 0);
        a[0] = L[i];
        a[1] = L[j];
        a[2] = L[k];
        sort(ALL(a));
        if (a[0] + a[1] > a[2] && a[0] != a[1] && a[1] != a[2]) {

          ans++;
        }
      }
    }
  }
  return ans;
}

// generated by online-judge-template-generator v4.4.0 (https://github.com/kmyk/online-judge-template-generator)
int main() {
  int N;
  std::cin >> N;
  std::vector<long long> L(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> L[i];
  }
  auto ans = solve(N, L);
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>

typedef long long ll;
using namespace std;

int main(void){
  ll n;
  ll ans=0;

  cin>>n;

  if(n%2==1){
    cout<<0<<endl;
    return 0;
  }
  else{
    for(ll t=10;t<=1e18;t*=5){
      ans+=n/t;
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.rmi.server.UnicastRemoteObject;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

//        int n = sc.nextInt();
        long s=sc.nextLong();
        long sq=(long)sqrt(s);
        if(sq*sq<s)sq++;
        long a=sq*sq-s,b=0;
        if(a!=0)b++;
        
        
        out.println("0 0"+" "+sq+" "+max(a,b)+" "+min(a,b)+" "+sq);
        out.flush();
    }



    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

class P {
	int x, y;
	P(int  x, int y) {
	  this.x=x;
	  this.y=y;
	}
}


//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

//class P implements Comparable<P>{
//    int a,b;
//    P(int a, int b) {
//    	this.b=b;
//    	this.a=a;
//    }
//
//    public int compareTo(P p){
//        return b-p.b;
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


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

int main() {
    int N, M; cin >> N >> M;
    vector<int> P(M), Y(M);
    for (int i = 0; i < M; i++) cin >> P[i] >> Y[i];
    vector<int> ord[100100];
    for (int i = 0; i < M; i++) ord[P[i]].push_back(Y[i]);
    for (int i = 1; i <= N; i++) sort(ord[i].begin(), ord[i].end());
    for (int i = 0; i < M; i++) {
        printf("%06d", P[i]);
        int n = lower_bound(ord[P[i]].begin(), ord[P[i]].end(), Y[i]) - ord[P[i]].begin() + 1;
        printf("%06d\n", n);
    }
    return 0;
}

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

int main() {
	//入力
	int N;
	cin >> N;

	//処理
	int ans = 0;
	int W = 0;
	for (int i = 1; i <= N; i++) {
		int count = 0;
		int k = i;
		
		while (k % 2 == 0) {
			k /= 2;
			count++;
		}

		if(k == 1) W = 1;

		if (ans < count) {
			ans = count;
			W = i;
		}
		
	}

	cout << W << endl;
	

}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>


using namespace std;

int main() {
	int d, w, h;
	while (true) {
		cin >> d >> w >> h;
		if (!d && !w && !h)break;
		int min1, min2;
		min1 = min(d, w);
		if (min1 == d)min2 = min(w, h);
		else min2 = (d, h);

		double s = sqrt(min1 * min1 + min2 * min2);

		int n;
		cin >> n;
		for (int i = 0; i < n; i++) {
			int r;
			cin >> r;
			if (s < 2*r) cout << "OK\n";
			else cout << "NA\n";
		}
	}
	return 0;
}


Measured memory_bytes: 2992
#include<cstdio>
const long long mod=1e9+7;
long long n,mx[1000007],a[1000007];
long long pow(long long a,long long b){
	long long ret=1;
	for(;b;b>>=1,a=a*a%mod)
        if(b&1)
            ret=ret*a%mod;
	return ret;
}
int main(){
	scanf("%d",&n);
	for(long long i=1;i<=n;++i){
		scanf("%d",a+i);
		long long x=a[i];
		for(long long i=2;i*i<=x;++i)
            if(x%i==0){
                long long cnt=0;
                while(x%i==0)
                    ++cnt,x/=i;
			if(cnt>mx[i])
                mx[i]=cnt;
		}
		if(x>1&&!mx[x])
            mx[x]=1;
	}
	long long s=1,ans=0;
	for(long long i=1;i<=1000000;++i)
        if(mx[i])
            s=1ll*s*pow(i,mx[i])%mod;
	for(long long i=1;i<=n;++i)
        ans=(ans+s*pow(a[i],mod-2))%mod;
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 8704
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n = read_as_vec::<usize>()[0];
    let mut shi: Vec<Vec<char>> = vec![];
    for _ in 0..n{
        shi.push(read_as_string().chars().collect::<Vec<char>>());
    }

    for i in 0..n-1{
        for j in i+1..n{
            if shi[i] == shi[j]{
                println!("No");
                return;
            }
        }
    }

    let mut cur: char = *shi[0].last().unwrap();
    for i in 1..n{
        if cur == *shi[i].first().unwrap(){
            cur = *shi[i].last().unwrap()
        }else{
                println!("No");
                return;
        }
    }

    println!("Yes");
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
using namespace std;
int a, b, c, d;
int cnt;
int main() {
	cin >> a >> b >> c >> d;
	while (a > 0 && c > 0) {
		cnt++;
		if (cnt % 2) c -= b;
		else a -= d;
	}
	if (c > 0) puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 3636
// V solo
#include <bits/stdc++.h>

#define forn(i, a, b) for (int i = a; i <= b; ++i)

using namespace std;

const int N = (int)2e5 + 1;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef long double ld;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

int n, mx, mn = INF;
int main (){
  scanf ("%d", &n);
  forn (i, 1, n){
    int x;
    scanf ("%d", &x);
    mx = max(mx, x);
    mn = min(mn, x);
  }
  printf ("%d\n", mx - mn);
  return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define SORT(s) sort((s).begin(),(s).end())
#define SORTR(s,t) sort((s).begin(),(s).end(),greater<t>())

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000ll;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;

int N; vi P;
void input()
{
    cin>>N;
    rep(i,N){
        int a; cin>>a; P.emplace_back(a);
    }
    return;
}

void solve()
{
    int mi=INF;
    int ans=0;
    rep(i,N){
        if(mi>P[i]){
            mi=P[i];
            ans++;
        }
    }
    cout<<ans<<endl;
    return;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 1400