akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Satoshi
{
	class Program
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			string[] s = Console.ReadLine().Split(' ');
			int mod = 1000000000 + 7;
			bool check = true;
			int ans = 1;
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
			{
				a[i] = int.Parse(s[i]);
			}
			if (n % 2 == 0)
			{
				int[] count = new int[n];
				foreach (int x in a)
				{ count[x]++; }
				for (int i = 1; i <= n - 1; i += 2)
				{
					if (count[i] != 2)
					{
						check = false;
						break;
					}
				}
				if (check)
				{
					int m = n / 2;
					for (int i = 0; i < m; i++)
					{
						ans *= 2;
						ans %= mod;
					}
				}
				else
					ans = 0;
			}
			else
			{
				int[] count = new int[n];
				foreach (int x in a)
				{ count[x]++; }
				if (count[0] != 1) check = false;
				for (int i = 2; i <= n - 1; i += 2)
				{
					if (count[i] != 2)
					{
						check = false;
						break;
					}
				}

				if (check)
				{
					int m = (n - 1) / 2;
					for (int i = 0; i < m; i++)
					{
						ans *= 2;
						ans = ans % mod;
					}
				}
				else
					ans = 0;
			}
			Console.WriteLine(ans);
		}
	}
}

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

void solve(int x,int y,int z){
}

int main(){
   string s,t;
   cin>>s>>t;
   if(t.size()-s.size()==1){
        for(int i=0;i<s.size();i++){
            if(s[i]!=t[i]){
            cout<<"No";
            return 0;
            }
        }
        cout<<"Yes";
   }
   else cout<<"No";
}


Measured memory_bytes: 3592
N=int(input())
n=[input() for _ in range(N)]
M=int(input())
m=[input() for _ in range(M)]
l=list(set(n))
ans=0
for i in range(len(l)):
  tmp=0
  tmp+=n.count(l[i])
  tmp-=m.count(l[i])
  ans=max(ans,tmp)
print(max(ans,0))

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>

using namespace std;

namespace io
{
	const int maxb = 1 << 15;
	char b[maxb], *s = b, *t = b;
	bool Getchar(char &ch)
	{
		return ch = s == t && (t = (s = b) + fread(b, 1, maxb, stdin)) == b ? 0 : *s ++;
	}
	int Getint()
	{
		char ch;
		while (Getchar(ch) && (ch < '0' || ch > '9'));
		int s = ch - '0';
		while (Getchar(ch) && ch >= '0' && ch <= '9')
			s = s * 10 + ch - '0';
		return s;
	}
}

using io::Getint;

const int maxn = 2e5 + 10;

int p[maxn], q[maxn];

bool Check(int a, int b, int c)
{
	if (a < b && b < c) return true;
	if (b < c && c < a) return true;
	if (c < a && a < b) return true;
	return false;
}

int main()
{
	int n = Getint();
	for (int i = 1; i <= n; ++ i)
		q[p[i] = Getint()] = i;
	int T = 0, f;
	for (int i = n - 1; i; -- i)
	{
		if (!T)
		{
			if (q[i] < q[i + 1]) T = 0;
			else ++ T, f = i + 1;
		}
		else
			if (!Check(q[f], q[i], q[i + 1])) ++ T, f = i + 1;
	}
	printf("%d\n", T);
	return 0;
}


Measured memory_bytes: 1792
using System;
using System.Linq;
class program{
  static void Main(){
    int k = int.Parse(Console.ReadLine());
    var wr = Console.ReadLine();
    int rct = wr.Count(c => c == 'R');
    var swr = wr.Substring(0, rct);
    int srct = swr.Count(c => c == 'R');
    Console.Write(rct-srct);
  }
}

Measured memory_bytes: 28532
#include<iostream>

int main(){

  int N,v,j;

  std::cin>>N;

  int A[N];

 for(int i=0;i<N;i++){
   std::cin>>A[i];
  }

 for(int i=0;i<N;i++){
   if(i==N-1){
     std::cout<<A[i];
   }else{
   std::cout<<A[i]<<" ";
   }
 }

 std::cout<<"\n";

  for(int i=1;i<N;i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){

      A[j+1]=A[j];
      j--;
    }
 A[j+1]=v;

      for(int k=0;k<N;k++){
 if(k==N-1){
     std::cout<<A[k];
   }else{
   std::cout<<A[k]<<" ";
   }
}
      std::cout<<"\n";
    }
 
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll p,q,r;
    cin>>p>>q>>r;
    if(p>=r&&p>=q) {
        cout<<r+q<<endl;
    }else if(q>=r&&q>=p){
        cout<<r+p<<endl;
    }else{
        cout<<p+q<<endl;
    }
    return  0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K;
    cin >> K;
    string S;
    cin >> S;
    cout << (S.size()<=K? S:S.substr(0,K)+"...");    
}

Measured memory_bytes: 3640
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

template <typename F>
void forSubset(int n, int k, F f)
{
    int comb = (1 << k) - 1;
    while (comb < (1 << n)) {
        f(comb);

        int x = comb & -comb;
        int y = comb + x;
        comb = ((comb & ~y) / x >> 1) | y;
    }
}

int ones(int n)
{
    n = (0x5555'5555 & n) + ((~0x5555'5555 & n) >> 1);
    n = (0x3333'3333 & n) + ((~0x3333'3333 & n) >> 2);
    n = (0x0f0f'0f0f & n) + ((~0x0f0f'0f0f & n) >> 4);
    n = (0x00ff'00ff & n) + ((~0x00ff'00ff & n) >> 8);
    n = (0x0000'ffff & n) + ((~0x0000'ffff & n) >> 16);
    return n;
}

int main()
{
    int n, a, b, c;
    cin >> n >> a >> b >> c;
    vector<int> bamboo(n);
    rep(i, n)
    {
        cin >> bamboo[i];
    }

    int result = numeric_limits<int>::max();
    rep(combA, 1 << n)
    {
        if (ones(combA) >= 1 && ones(combA) <= n - 2) {
            rep(combB, 1 << n)
            {
                if ((combA & combB) == 0 && ones(combB) >= 1 && ones(combA) + ones(combB) <= n - 1) {
                    int combC = ((1 << n) - 1) & ~combA & ~combB;

                    int target[] = { a, b, c };
                    int flags[] = { combA, combB, combC };

                    int total = 0;
                    rep(i, 3)
                    {
                        int cost = numeric_limits<int>::max();
                        rep(f, 1 << n)
                        {
                            int sub = f & flags[i];
                            if (ones(sub) >= 1) {
                                int len = 0;
                                int tmpcost = 10 * (ones(sub) - 1);
                                rep(j, n)
                                {
                                    if (((sub >> j) & 1) != 0) {
                                        len += bamboo[j];
                                    }
                                }
                                tmpcost += abs(target[i] - len);
                                cost = min(cost, tmpcost);
                            }
                        }
                        total += cost;
                    }
                    result = min(result, total);
                }
            }
        }
    }
    cout << result << endl;

    return 0;
}

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

using namespace std;

int main(){

	int a,b;
	cin>>a>>b;
	int c=b;
	int x=1;
	while(c>0){
	
		x*=10;
		c/=10;
	}

	int temp=sqrt(a*x+b);
	if(temp*temp==a*x+b){
	
		cout<<"Yes"<<"\n";
		return 0;
	}
	cout<<"No"<<"\n";
	return 0;
}


Measured memory_bytes: 3520
#include <iostream>
#include <set>
using namespace std;
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int CommandNum;
    set<string> List;
    string Command, ss;
     
    List.clear();
    cin >> CommandNum;
    for(int i = 0; i < CommandNum; i++){
        cin >> Command >> ss;
        if(Command[0] == 'i'){
            List.insert(ss);
        } else if(Command[0] == 'f'){
            set<string>::iterator itr = List.find(ss);
            if(itr != List.end())   cout << "yes" << endl;
            else    cout << "no" << endl;
        }
    }
}

Measured memory_bytes: 27812
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

const int MAX_V = 110;

vector<int> G[MAX_V];
int V;
bool visited[MAX_V]; 
vector<int> ans;
int degree[MAX_V];

void bfs(int s){
	queue<int> q;
	q.push(s);
	visited[s] = true;
	while(!q.empty()){
		int u = q.front(); q.pop();
		ans.push_back(u);
		for (int i = 0; i < G[u].size(); ++i)
		{
			int v = G[u][i];
			degree[v]--;
			if (degree[v] == 0 && !visited[v]){
				visited[v] = true;
				q.push(v);
			}
		}
	}
}


void topologicalSort(){
	fill(degree, degree + V, 0);

	for (int u = 0; u < V; ++u)
	{
		for (int i = 0; i < G[u].size(); ++i)
		{
			int v = G[u][i];
			degree[v]++;
		}
	}

	for (int u = 0; u < V; ++u)
		if (degree[u] == 0 && !visited[u]) bfs(u);
}

int main(int argc, char const *argv[])
{
	int E;
	cin >> V >> E;

	fill(visited, visited + V, false);

	for (int i = 0; i < E; ++i)
	{
		int s, t;
		cin >> s >> t;
		G[s].push_back(t);
	}

	topologicalSort();

	if (ans.size() == V) cout << 0 << endl;
	else cout << 1 << endl;
	return 0;
}


Measured memory_bytes: 3180
# https://atcoder.jp/contests/abc072/tasks/arc082_a



N = gets.to_i
as = gets.split.map(&:to_i)

max = 0
as.each_with_object(Hash.new(0)) do |ai, hash|
  hash[ai - 1] += 1
  hash[ai] += 1
  hash[ai + 1] += 1

  this_max = [hash[ai - 1], hash[ai], hash[ai + 1]].max
  if this_max > max
    max = this_max
  end
end

puts max


Measured memory_bytes: 16900
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    long long int x,y;
    cin>>x>>y;
    long long int result=0;
    result += (max(4 - x, 0ll) * 100000)+(max(4 - y, 0ll) * 100000);
    if(x==y&&y==1){
        result += 400000;
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 888
import java.util.Scanner;

public class Main {

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

        while(true){
            int h = scan.nextInt();
            int w = scan.nextInt();
            if(h == 0 && w == 0){
                break;
            }
            for(int i = 0;i<h;i++){
                for(int j= 0;j<w;j++){
                    if(i % 2 == 0 ){
                        if(j % 2 == 0){
                            System.out.printf("#");
                        }else{
                            System.out.printf(".");
                        }
                    }else{
                        if(j % 2 != 0){
                            System.out.printf("#");
                        }else{
                            System.out.printf(".");
                        }
                    }
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }


    }

}


Measured memory_bytes: 62316
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

  ll N, K;
  vector<ll> A;
  map<ll,ll> cont;
  cin >> N >> K;
  rep(i,N){
    ll inp; cin >> inp;
    A.pb(inp);
    cont[inp]++;
  }
  rmsame(A);

  
  if((A.size()<K)){ cout << 0 << endl;return 0;}


  ll kinds = A.size()-K;
  vector<ll> ans;
  rep(i,A.size()){
    ans.pb(cont[A[i]]);
  }
  sort(all(ans));
  ll res = 0;
  
  rep(i,kinds){
    res += ans[i] ;
  }
  cout << res << endl;
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


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

using db = double;
using ll = long long;
using vi = vector <int>;
#define op operator
#define pb push_back

struct poi {
	db x, y;
	poi op -(poi p) {
		return {x - p.x, y - p.y};
	}
	db cross(poi p) {
		return x * p.y - y * p.x;
	}
}p[4];
db xmul(poi a, poi b, poi c) {
	return (b - a).cross(c - a);
}

int main() {
	ios :: sync_with_stdio(0);

	while(cin >> p[0].x) {
		char c; cin >> c >> p[0].y;
		for(int i = 1; i < 4; i ++)
			cin >> c >> p[i].x >> c >> p[i].y;
		int c1 = 0, c2 = 0;
		for(int i = 0; i < 4; i ++)
			if(xmul(p[i], p[(i + 1) % 4], p[(i + 2) % 4]) > 0)
				c1 ++;
			else
				c2 ++;
		cout << (!c1 || !c2 ? "YES" : "NO") << '\n';
	}
	
	return 0;
}

Measured memory_bytes: 3116
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <memory>

//#define int long long

using namespace std;

void Main()
{
	int n, x;
	cin >> n >> x;

	vector<int> l(n, 0);
	vector<int> d(n + 1, 0);
	int ans = 1;
	for (int i = 0; i < n; i++) {
		cin >> l[i];
		d[i + 1] = d[i] + l[i];
		if (d[i + 1] <= x) {
			ans++;
		}
		else {
			break;
		}
	}
	cout << ans << endl;
}

int32_t main()
{
	Main();
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#ifdef DEBUG
#include <boost/core/demangle.hpp>
#define dump(x) cerr << "L" << __LINE__ << ": in " << __PRETTY_FUNCTION__ << " \e[32;1m" << boost::core::demangle(typeid(x).name()) << "\e[37m" << " " << (#x) << " = " << (x) << "\e[m" << endl;
#else
#define dump(x)
#endif
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T> ostream& operator<<(ostream &os, vector<T> &v){os << "{";ITR(i,v){if(i!=v.begin())os << ","; os << *i;}os << "}"; return os;}
template <typename T, typename U> ostream& operator<<(ostream& os, pair<T,U> &p){os << "(" << p.first << "," << p.second << ")"; return os;}

template <typename T> T& chmin(T &a, const T &b){return a = min(a,b);}
template <typename T> T& chmax(T &a, const T &b){return a = max(a,b);}

bool dp[2][101000];
bool visit[2][101000];

bool rec(bool p, int k, vector<int> &a){
  if(k<0) return p;
  if(visit[p][k]) return dp[p][k];
  visit[p][k] = true;

  for(auto x : a){
    if(rec(!p, k-x, a) == p){
      return dp[p][k] = p;
    }
  }

  return dp[p][k] = !p;
}

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

  int N,K; cin >> N >> K;
  vector<int> a(N); cin >> a;

  if(rec(true,K,a)){
    cout << "First" << endl;
  }else{
    cout << "Second" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 9984
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long long int
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e7;
const ll MOD=998244353;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
int main() 
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    cout.tie(0);
    int x ,n;
    cin>>x>>n;
    map<int , int > mp;
    for(int i=1;i<=n;i++){
      int x;
      cin>>x;
      mp[x]=1;
    }
    int ans=INT_MAX;
    int p=0;
    for(int i=-200;i<=200;i++){
      if(!mp[i]){
        if(abs(x-i)<ans){
          ans=abs(x-i);
          p=i;
        }
      }
    }
      cout<<p;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
#define PB push_back
#define loop(i,x,y) for(int i=x;i<y;i++)
#define rloop(i,x,y) for(int i=x;i>y;i--)
#define NL cout<<"\n"
#define ans(x) cout<<x<<"\n"
#define out(x) cout<<x<<" "
#define F first
#define S second
#define ansf(x,y) cout<<fixed<<setprecision(y)<<x<<endl;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
void solve()
{
  string A[]={"Sunny","Cloudy","Rainy"};
  std::map<int,string> mp;
  std::map<string,int> m;
  loop(i,0,3) mp[i]=A[i],m[A[i]]=i;
  string s;
  cin>>s;
  ans(mp[(m[s]+1)%3]);
}
signed main()
{
  // FAST;
  int T=1;
  // cin>>T;
  while(T--) solve();
  return 0;
}

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

using namespace std;

int main() {
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    int n = 5;
    // 注文してから届くまでの時間
    vector<int> time = {a, b, c, d, e};
    // 順番の並び替え
    vector<int> index = {0, 1, 2, 3, 4};

    int bestTime = (int)1e9;  //←10の9乗(double)

    do {
        int nowTime = 0;
        for (int i = 0; i < n; ++i) {
            // 10で割り切れるようになるまで1を足し続ける
            while (nowTime % 10 != 0) ++nowTime;
            nowTime += time[index[i]];
        }
        bestTime = min(nowTime, bestTime);
    } while (next_permutation(index.begin(), index.end()));
    // next_permutation(index.begin(), index.end());
    // 0, 1, 2, 3, 4
    // 0, 1, 2, 4, 3
    // :
    // 4, 3, 2, 1, 0
    // の全数探索を行う(DFSを実装して求めてもよし)

    cout << bestTime << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import itertools
import math


def compute(n):
    res = [0 for _ in range(n + 1)]
    n_ub = math.ceil(math.sqrt(n) + 1.0)
    for x, y, z in itertools.product(range(1, n_ub + 1), repeat=3):
        m = x * x + y * y + z * z + x * y + y * z + z * x
        if 0 <= m <= n:
            res[m] += 1
    return res



def main():
    n = int(input())
    res = compute(n)
    print(*res[1:], sep="\n")


if __name__ == '__main__':
    main()

Measured memory_bytes: 9484
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fi first
#define se second
#define ll long long
#define ld long double
#define all(x)              (x).begin(), (x).end()
#define inf                 1e18

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve() {
	ll n;
	cin >> n;

	map <ll, int> mp;
	for (ll i = 2; i * i <= n; ++i) {
		while (n % i == 0) ++mp[i], n /= i;
	}
	if (n != 1) ++mp[n];

	ll res = 0;
	for (auto x : mp) {
		ll cur = x.se;

		ll l = 1, r = 1000, mid, ans = 0;
		while (l <= r) {
			mid = (l + r) >> 1;
			if ((mid * (mid + 1)) / 2 <= cur) ans = mid, l = mid + 1;
			else r = mid - 1;
		}
		res += ans;
		if (ans * (ans + 1) / 2 != cur) ++ans;
	}
	cout << res;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//	ifstream cin("input.txt");
//	ofstream cout("output.txt");
	int q = 1; // cin >> q;
	while (q--) {
		solve();
	}
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int in[105*105];
int dp[105][105];

int stoi (string s )
{
	stringstream ss (s );
	int res = 0;
	ss >> res;

	return res;
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.SPRP", "r", stdin );
	memset (in, -1, sizeof (in ) );
	memset (dp, 0, sizeof (dp ) );
	string str = "";
	int pos = 0;
	while (getline (cin, str ) ){
		rep (i, str.length() ){
			if (str[i] == ',' ) str[i] = ' ';
		} // end rep
		stringstream ss (str );
		string s = "";
		while (ss >> s ){
			in[pos++] = stoi (s );
		} // end while
	} // end while

	int n = (int)sqrt (pos );
	int k = 0;
	rep (i, n ){
		for (int j = 0; j <= i; j++ ){
			dp[i-j][j] = in[k++];
		} // end for
	} // end rep
	for (int i = n-1; i > 0; i-- ){
		for (int j = 1; j <= i; j++ ){
			dp[n-j][n-1-i+j] = in[k++];
		} // end for 
	} // end for
/*
	rep (i, n ){
		rep (j, n ){
			cout << setw(2) << dp[i][j];
		} // end rep
		cout << endl;
	} // end rep
*/
	for (int i = 1; i < n; i++ ) dp[i][0] += dp[i-1][0];
	for (int j = 1; j < n; j++ ) dp[0][j] += dp[0][j-1];
	for (int i = 1; i < n; i++ ) 
		for (int j = 1; j < n; j++ )
			dp[i][j] += max (dp[i-1][j], dp[i][j-1] );

	printf ("%d\n", dp[n-1][n-1] );
		
	return 0;
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int main()
{
    int n;
    cin >> n;
    
    cout << (n + 1) / 2 << '\n';
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  string W[N];
  for(int i = 0; i < N; i++){
    cin >> W[i];
  }
  bool can = true;
  for(int i = 1; i < N; i++){
    for(int j = 0; j < i; j++){
      if(W[j] == W[i]) can = false;
    }
    if(W[i][0] != W[i-1][W[i-1].size()-1]) can = false;
  }
  cout << (can ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
int main(){
  ll n, x, ans = 0;
  cin >> n >> x;
  vll a(n);
  for (ll i = 0; i < n; i++) cin >> a[i];
  for (ll i = 1; i < n; i++) {
    ll sum = a[i] + a[i-1];
    if (sum > x) {
      ans += a[i] + a[i-1] - x;
      a[i] = max(x - a[i-1], (ll)0);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1024
//kruskal tree
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
#define M 9999
int parent[M],a[M],b[M];
pair<double,int>node[M];
int root(int a){return parent[a]==a?a:parent[a]=root(parent[a]);}
int unite(int a,int b){
	int x=root(a),y=root(b);
	if(x==y)return 0;
	parent[x]=y;
	return 1;
}
int main(){
	int i,j,k,m,n,q;
	double x,y,z,r,t;
	for(;scanf("%d",&n),n;){
		vector<vector<double> >v;
		for(i=0;i<n;i++)scanf("%lf%lf%lf%lf",&x,&y,&z,&r),v.push_back({x,y,z,r}),parent[i]=i;
		for(q=m=i=0;i<n;i++)for(j=0;j<i;j++){
			for(x=k=0;k<3;k++)x+=(t=v[i][k]-v[j][k])*t;
			x=sqrt(x)-v[i][3]-v[j][3];
			if(x<=0){if(unite(i,j))q++;}
			else a[m]=i,b[m]=j,node[m].first=x,node[m++].second=m;
		}
		sort(node,node+m);
		for(x=i=0;i<m&&q<n-1;i++)if(unite(a[node[i].second],b[node[i].second]))x+=node[i].first,q++;
		printf("%.3f\n",x);
	}
}

Measured memory_bytes: 1292
program coincidence
  implicit none
  integer(8), parameter :: md = 1000000007_8
  integer(8) :: l, r, dp(0:60,0:1,0:1,0:1) = 0_8
  integer :: i, j, k, s, lb, rb, x, y, jj, kk, ss
  read(*,*) l, r
  dp(60,0,0,0) = 1_8
  do i = 59, 0, -1
    lb = 0
    rb = 0
    if (btest(l,i)) lb = 1
    if (btest(r,i)) rb = 1
    do j = 0, 1
      do k = 0, 1
        do s = 0, 1
          do x = 0, 1
            do y = 0, 1
              if (x-y == 1) cycle
              jj = j
              kk = k
              ss = s
              if (s == 0 .and. x /= y) cycle
              if (x*y == 1) ss = 1
              if (lb-j-x == 1) cycle
              if (x-lb == 1) jj = 1
              if (y-k-rb == 1) cycle
              if (rb-y == 1) kk = 1
              dp(i,jj,kk,ss) = mod(dp(i,jj,kk,ss)+dp(i+1,j,k,s),md)
            end do
          end do
        end do
      end do
    end do
  end do
  write(*,'(i0)') mod(sum(dp(0,:,:,:)),md)
end program coincidence

Measured memory_bytes: 256
#include <cstdio>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int No, score;
	vector<int> vc;
	map<int,int> f;
	map<int,int> rank;

	while( scanf("%d,%d", &No , &score ) , No|score ){
		if( !count(vc.begin(),vc.end(),score) ) vc.push_back( score );
		f[No] = score;
	}
	unique( vc.begin() , vc.end() );
	sort( vc.begin() , vc.end() );
	reverse( vc.begin() , vc. end() );
	for(int i=0 ; i<(int)vc.size() ; ++i )
		rank[ vc[i] ] = i+1;

	while( ~scanf("%d", &No ) ){
		printf("%d\n", rank[ f[No] ] );
	}
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
 
int main()
{
  int A,B;
  cin >> A >> B;
 
  if(A%3==0 || B%3==0 || (A+B)%3==0)
    cout << "Possible";
  else
    cout << "Impossible";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <algorithm>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
#include <cmath>
#include <stack>
#include <limits>
#include <ctime>

using namespace std;

#define ll long long
#define sc(n) static_cast<ll>(n)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {
	IO;
#ifdef _DEBUG
	ifstream cin("In.txt");
#endif	
	ll n, m, a, sm = 0;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a;
		sm += a;
	}
	cout << max(sc(-1), n - sm) << endl;
	return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------

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

  cin >> s;
  cout << ((s[0] == '7' || s[1] == '7' ||  s[2] == '7') ? "Yes" : "No") << endl;
}


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

int main() {
    int i,j,n;
    string s;
    
    scanf("%d", &n);
    vector<int> suff(n + 5, 0);
    vector<int> pref(n + 5, 0);
    cin >> s;
    suff[0] = 0;
    for(i = 0; i < n; i++){
        suff[i + 1] = suff[i] + (s[i] == 'W');
    }
    
    pref[n + 1] = 0;
    for(i = n - 1; i >= 0; i--){
        pref[i + 1] = pref[i + 2] + (s[i] == 'E');
    }
    
    int mini = INT_MAX;
    for(i = 1; i <= n; i++){
        // printf("%d %d %d\n", i, suff[i], pref[i]);
        mini = min(mini, suff[i - 1] + pref[i + 1]);
    }
    printf("%d", mini);
    
    
	return 0;
}


Measured memory_bytes: 3204
#include<iostream>
#include<string>
#include <cctype>

using namespace std;

int main(void) {
	string R,a,d;
	int b=0;
	int c;
	int e = 0;
	cin >> R;
	a = R.substr(2);
	a.erase(a.end() -1);
	c = a.find("C");
	while (c!=std::string::npos) {
		b++;
		c = a.find("C", c + 1);
	}
	
	if (R.substr(0,1) == "A") {
		if (b == 1) {
			for (int i=1; i <= R.size();i++) {



				if (isupper(R[i]) ){
					e++;
				}
			}
			if (e == 1) {
				cout << "AC"<<endl;
			}
			else {
				cout << "WA" << endl;
			}


		}
		else {
			cout << "WA" << endl;
		}
	}
	else {
		cout << "WA" << endl;
	}


}

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

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

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.first,", ",x.second,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vi arr (N);
	F0R(i, N) cin >> arr[i];

	map<int, int> occ;
	F0R(i, N) occ[arr[i]]++;

	if (occ.size() > 3) {
		print("No");
		return 0;
	}

	if (N % 3 != 0) {
		if (occ.size() == 1 && occ[0] == N) {
			print("Yes");
		} else {
			print("No");
		}
		return 0;
	}

	vi reps;
	for (pair<int, int> x : occ) {
		if (x.second % (N/3) != 0) {
			print("No");
			return 0;
		}
		if (x.second == 3 * (N/3)) reps.push_back(x.first);
		if (x.second >= 2 * (N/3)) reps.push_back(x.first);
		reps.push_back(x.first);
	}

	int a = reps[0];
	int b = reps[1];
	int c = reps[2];
	if (((a ^ c) == b) && ((b ^ a) == c) && ((b ^ c) == a)) {
		print("Yes");
	} else {
		print("No");
	}
}

Measured memory_bytes: 4224
#include "bits/stdc++.h"
using namespace std;
void InsertionSort(int N, vector<int>& A) {
	for (int i = 1; i < N; i++) {
		if (A.at(i - 1) > A.at(i)) {
			int tmp = A.at(i);
			int j = i - 1;
			while (j >= 0) {
				if (A.at(j) <= tmp) break;
				A.at(j + 1) = A.at(j);
				j--;
			}
			A.at(j) = tmp;
		}
		for (int k = 0; k < N; k++) {
			cout << A.at(k);
			if (k != N - 1) cout << ' ';
		}
		cout << endl;
	}
}
long long GCD(long long A, long long B) {
	if (B == 0) return A;
	else return GCD(B, A % B);
}
bool Prime_Num(long long N) {
	for (long long i = 2; i <= sqrt(N); i++) {
		if (N % i == 0) {
			return false;
		}
	}
	return true;
}
void BubbleSort(long long N, vector<long long>& A) {
	long long ans = 0;
	long long Limits = N;
	for (int i = 0; i < N; i++) {
		for (long long i = 1; i < Limits; i++) {
			if (A.at(i - 1) > A.at(i)) {
				ans++;
				swap(A.at(i - 1), A.at(i));
			}
		}
		Limits--;
	}
	for (long long i = 0; i < N; i++) {
		cout << A.at(i);
		if (i != N - 1) cout << ' ';
	}
	cout << endl << ans << endl;
}
int main() {
	long long N;
	cin >> N;
	vector<long long>A(N);
	for (long long i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	BubbleSort(N, A);
}


Measured memory_bytes: 3116
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
using namespace std;

struct cr{
	int price;
	string name;
	int abcTime,deTime;
	int nutNum,salePrice,year;
	//double Efficiency;
};

int main(){
	int n;
	struct cr cropDt;//[51];
	pair<double,string> cropDP;
	//map<double,string>::iterator it;
	while(cin>>n,n){
		vector<pair<double,string> > cropRank;
		//input
		for(int i=0;i<n;i++){
			cropDt.abcTime=cropDt.deTime=0;
			
			cin>>cropDt.name>>cropDt.price;
			for(int j=0;j<5;j++){
				int inpTime;
				cin>>inpTime;
				if(j<=2){
					cropDt.abcTime+=inpTime;
				}
				if(j>2){
					cropDt.deTime+=inpTime;
				}
			}
			cin>>cropDt.nutNum>>cropDt.salePrice>>cropDt.year;
			
			int revenue=cropDt.nutNum *cropDt.year * cropDt.salePrice - cropDt.price;
			//-をつけて逆順ソートするように設定
			double Efficiency=-(double)revenue/(double)(cropDt.abcTime+cropDt.deTime*cropDt.year);
				
			cropDP.first=Efficiency;
			cropDP.second=cropDt.name;
			cropRank.push_back(cropDP);
		}
		sort(cropRank.begin(),cropRank.end());
		for(int i=0;i<cropRank.size();i++){
			cout<<cropRank[i].second<<endl;
		}
		cout<<'#'<<endl;
	}
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int N,M,R;
  cin>>N>>M>>R;
  vector<vector<int>> d(N,vector<int>(N,INFint));
  vector<int> r(R);
  for (int i(0);i<R;i++){
     cin>>r[i];
     r[i]--;
  }
  for (int i(0);i<M;i++){
    int a,b,c;
    cin>>a>>b>>c;
    a--;
    b--;
    d[a][b] = c;
    d[b][a] = c;
  }
  for (int k = 0; k < N; k++){       // 経由する頂点
    for (int i = 0; i < N; i++) {    // 始点
      for (int j = 0; j < N; j++) {  // 終点
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  sort(r.begin(),r.end());
  int ans(1e9);
  do{
    int tmp(0);
    for (int i(0);i<R-1;i++){
      tmp += d[r[i]][r[i+1]];
    }
    ans = min(ans,tmp);
  }while(next_permutation(r.begin(),r.end()));
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 384
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
A=get_i
lcm=A.inject(1){|res,x| res.lcm(x)}
puts A.inject(0){|res,x| res+=lcm/x}% (10**9+7)

Measured memory_bytes: 91816
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)

Measured memory_bytes: 12824
import itertools
N, M = [int(x) for x in input().split()]
lst = [[int(x) for x in input().split()] for i in range(M)]
N_lst = list(range(1, N + 1))
per = []

def check(tup):
    for i in range(N - 1):
        x = tup[i]
        y = tup[i + 1]
        if x > y:
            x, y = y, x
        if not [x, y] in lst:
            return False
    return True

for v in itertools.permutations(N_lst):
    if v[0] == 1:
        per.append(v)
cnt = 0
for p in per:
    if check(p): cnt += 1
print(cnt)


Measured memory_bytes: 3700
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;



int main(void){
    ll ans=0;
    ll n;
    cin>>n;
    vector<ll>l(n);
    for(ll i=0;i<n;i++)cin>>l[i];
    sort(l.begin(),l.end());
    ll count=0;
    for(ll i=0;i<n-2;i++){
        for(ll j=i+1;j<n-1;j++){
            ll x=l[i]+l[j];
            ll y=l[j]-l[i];
            ll s1=upper_bound(l.begin()+j+1,l.end(),y)-l.begin();
            ll s2=lower_bound(l.begin()+j+1,l.end(),x)-l.begin();
            ans+=s2-s1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <random>

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

using namespace std;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

#define INF 1000000

ll evalNow(vector<vector<int>>& s, vector<int>& c, vector<int>& t, int d, vector<int> last) {
    ll ans = 0;
    ans += s[d][t[d]-1];
    last[t[d]-1] = d+1;
    rep(j, 26) {
        ans -= c[j]*(d+1 - last[j]);
    }
    return ans;
}

ll evalAll(vector<vector<int>>& s, vector<int>& c, vector<int>& t, int d) {
    ll ans = 0;
    vector<int> last(26,0);
    rep(i, d) {
        ans += s[i][t[i]-1];
        last[t[i]-1] = i+1;
        rep(j, 26) {
            ans -= c[j]*(i+1 - last[j]);
        }
    }
    return ans;
}

int main(){
    int d; cin >> d;
    vector<int> c(26);
    rep(i, 26) {
        cin >> c[i];
    }
    vector<vector<int>> s(d, vector<int>(26,0));
    rep(i, d) {
        rep(j, 26) {
            cin >> s[i][j];
        }
    }
    vector<int> t(d);
    ll ans = 0;
    vector<int> last(26,0);

    rep(i, d) {
        ll tmpmax = - (1LL << 60);
        ll candidate = -1;
        rep(j, 26) {
            t[i] = j+1;
            if(tmpmax < evalNow(s,c,t,i,last)) {
                tmpmax = evalNow(s,c,t,i,last);
                candidate = j+1;
            }
        }
        last[t[i]-1] = i + 1;
        t[i] = candidate;
    }

    std::random_device rnd;     // 非決定的な乱数生成器を生成
    std::mt19937 mt(rnd());     //  メルセンヌ・ツイスタの32ビット版、引数は初期シード値
    std::uniform_int_distribution<> randd(0, d-1);
    std::uniform_int_distribution<> rand26(0, 25);

    //この時点でtはgreedy
    // rep(x, 1000) {
    //     ll candidate;
    //     int i = randd(mt);
    //     ll tmpmax = evalAll(s,c,t,d);
    //     rep(j, 26) {
    //         t[i] = j+1;
    //         ll tmp = evalAll(s,c,t,d);
    //         if(tmpmax < tmp) {
    //             tmpmax = tmp;
    //             candidate = j+1;
    //         }
    //     }
    //     t[i] = candidate;
    // }

    ll tmpmax = evalAll(s,c,t,d);

    double start,end;
    start = 0;
    end = 1000;

    rep(x, 4000) {
        int i = randd(mt);
        int j = rand26(mt);
        int original = t[i];
        t[i] = j+1;
        ll tmp = evalAll(s,c,t,d);
        if(tmpmax < tmp) {
            tmpmax = tmp;
        } else {
            double temp = start + (end - start)*x/4000;
            double prob = exp(tmpmax-tmp/temp);
            ll diff = tmpmax - tmp;
            if (prob <= (rand()%INF)/(double)INF) {
                t[i] = original;
            }
        }
    }


    rep(i, d) {
        cout << t[i] << endl;
    }
}


Measured memory_bytes: 4056
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
using namespace std;

#pragma region

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, int>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

#pragma endregion


int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    cin >> a;
    
    sort(a.rbegin(), a.rend());
    ll sum = 0;
    rep(i, n - 1) sum += a[(i + 1) / 2];
    cout << sum << endl;
}

Measured memory_bytes: 4768
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>


using namespace std;

int main() {
    int n, x;
    cin >> n >> x;
    int cnt = 1, sum = 0;
    for (int i=0; i<n; i++) {
        int l; cin >> l;
        sum += l;
        if (sum <= x) cnt++;
    }
    cout << cnt << '\n';
    return 0;
}


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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

int A, B, C, D, E, F;

int max_x, max_y;
double maxc;

int main(void){
	cin>>A>>B>>C>>D>>E>>F;

	A *= 100, B *= 100;

	int now_water, max_water = 0, limit_water = F;
	int now_sugar, max_sugar = 0, limit_sugar;
	double now_density, max_density = 0, limit_density = (double)(E) / (double)(100 + E);

	for (int i = 0; A * i <= limit_water; i++) {
		for (int j = 0; A*i + B*j <= limit_water; j++) {
			now_water = A*i + B*j;
			limit_sugar = F - now_water;

			for (int k = 0; C*k <= limit_sugar; k++) {
				for (int l = 0; C*k + D*l <= limit_sugar; l++) {
					now_sugar = C*k + D*l;
					if (now_water + now_sugar == 0) continue;
					now_density = (double)(now_sugar) / (double)(now_water + now_sugar);

					if (now_density <= limit_density && max_density <= now_density) {
						max_density = now_density;
						max_water = now_water;
						max_sugar = now_sugar;
					}
				}
			}
		}
	}

	cout<< max_water + max_sugar << " " << max_sugar <<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
/*struct UF
{
  vector<int> par;
  vector<int> sz;
  vector<int> rank;
  UF(int n):par(n),sz(n),rank(n){
    for(int i = 0; i < n; i++){
      par[i] = i;sz[i] = 1;rank[i] = 0;
    }
  }
  int find(int x) {
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
  }
  void merge(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return;
    if(rank[x] < rank[y]){
      par[x] = y;
      sz[y] += sz[x];
    }
    else{
      par[y] = x;
      sz[x] += sz[y];
      if(rank[x] == rank[y])rank[x]++;
    }
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int n){return sz[find(n)];}
  };*/
set<string>se;
ll n;
void dfs(ll dep,string s,ll un){
  if(dep == n){
    se.insert(s);
    return;
  }
  for(int i=0;i<=un;i++){
    s.pb((char)(i+'a'));
    if(i == un)
      dfs(dep+1,s,un+1);
    else
      dfs(dep+1,s,un);
    s.pop_back();
  }
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  if(n == 1){
    cout<<'a'<<endl;
    return 0;
  }
  dfs(0,"",0);
  /*
  for(ll i=0;i<BITLE(n-1);i++){
    UF uni(n+10);
    vector<bool>used(n+10);
    vector<char>hoge(n+10);
    for(ll j=0;j<n-1;j++){
      if(i&(BITLE(j))){
	uni.merge(j,j+1);
      }
    }  
    char now = 'a';
    string s = "";
    for(int j=0;j<n;j++){
      ll po = uni.find(j);
      if(used[po] == false){
	used[po] = true;
	hoge[po] = now;
	s.pb(now);
	now++;
      }else{
	s.pb(hoge[po]);
      }
    }
    //cout<<s<<endl;
    se.insert(s);
  }
  */
  for(auto &a:se)cout<<a<<endl;
  return 0;
}


Measured memory_bytes: 13824