akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <tuple>
using namespace std;
typedef long long ll;

int main() {
    string s;
    cin >> s;

    int ans[100010] = {}, idx = 0, left = -1;
    while (idx < s.size()) {
        int l = 0, r = 0;
        while (s[idx + l] == 'R') l++;
        while (s[idx + l + r] == 'L') r++;

        ans[idx + l - 1] = r / 2 + (l - l / 2);
        ans[idx + l] = l / 2 + (r - r / 2);
        idx += l + r;
    }

    for (int i = 0; i < s.size(); i++) {
        if (i != 0) cout << " ";
        cout << ans[i];
    }
    cout << endl;
}


Measured memory_bytes: 1024
from itertools import groupby
from operator import itemgetter
import numpy as np
N = int(input())
arm = []
for i in range(N):
  x, l = map(int, input().split())
  a = [x-l, x+l]
  arm.append(a)
arm = sorted(arm, key=lambda x: x[1])
now = arm[0][1]
count = 1
for i in range(1,N):
  if now <= arm[i][0]:
    count += 1
    now = arm[i][1]
print(count)

Measured memory_bytes: 31112
#include <iostream>
#include <queue>
#include <algorithm>

using namespace std;


int N, M;

const int INF = 1000000;

typedef vector<int> VI;

VI visited;

const int N_MAX = 10;
int G[N_MAX][N_MAX];


int dfs(int v, int n) {
  if (n == 1) return 1;

  visited[v] = 1;

  int res = 0;
  for (int i = 0; i < N; i++) {
    if (G[v][i] && visited[i] == 0) {
      res += dfs(i, n-1);
    }
  }

  visited[v] = 0;

  return res;
}


int main() {
  cin >> N >> M;
  visited = VI(N, 0);

  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a][b] = 1;
    G[b][a] = 1;
  }
  cout << dfs(0, N) << endl;

  return 0;
}


Measured memory_bytes: 256
import math
import itertools
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque
 
 
# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")
 
 
##### stdin ####
def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_I(): return map(int, stdin)
def ALL_IL(): return LM(int,stdin)
 
##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))
 
 
 
##### main #####
 
class BIT(object):
 
	def __init__(self,l):
		self.size = l
		self.bit = [0]* (self.size+1)
 
	def sum(self, i):
		s = 0
		while i > 0:
			s += self.bit[i]
			i -= i & -i
		return s
 
	def add(self, i, x):
		while i < self.size:
			self.bit[i] += x
			i += i & -i
 
	def __str__(self):
		return str(self.bit)
 
 
def main():
	N,M = LI()
 
	bit = BIT(M+2)
	L = []
	R = []
	b = [[] for i in range(M+1)]
 
 
	for i in range(N):
		l,r = LI()
		L.append(l); R.append(r)
		b[r-l +1].append(i)
 
 
	gone = 0
	for d in range(1, M+1):
		for i in b[d]:
			gone+=1
			bit.add(L[i], 1)
			bit.add(R[i]+1, -1)
 
 
		ans = N-gone
 
		for m in range(d, M+1, d):
 
			ans += bit.sum(m)
		print(ans)
 
 
 
 
if __name__ == '__main__':
	main()

Measured memory_bytes: 120368
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static int count;
	static long[][] dp;
	static long[] numberArray;

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		count = scan.nextInt();
		scan.nextLine();

		numberArray = Arrays.stream(scan.nextLine().split(" "))
				.mapToLong(Long::parseLong)
				.toArray();

		dp = new long[count + 1][count + 1];

		long result = dpMethod(new int[] { 0, 0 });

		println(result);
	}

	public static long dpMethod(int[] situation) {

		if (dp[situation[0]][situation[1]] != 0) {
			return dp[situation[0]][situation[1]];
		}

		if (situation[0] + situation[1] == count) {
			return 0;
		}

		long value = Math.max(
				numberArray[situation[0]] - dpMethod(
						new int[] { situation[0] + 1, situation[1] }),
				numberArray[count - 1 - situation[1]] - dpMethod(
						new int[] { situation[0], situation[1] + 1 }));

		dp[situation[0]][situation[1]] = value;

		return value;
	}

	public static void println(Object target) {
		System.out.println(target);
	}
}


Measured memory_bytes: 172916
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		double c=Math.toRadians(sc.nextInt());
		double S,L,h;
		sc.close();
		double x=b*Math.tan(c)/Math.sin(c)-a;
		L=Math.sqrt(a*a+b*b-2*a*b*Math.cos(c))+a+b;
		S=a*Math.sin(c)*b/2;
		h=b*Math.sin(c);
		System.out.printf("%f %f %f%n",S,L,h);
				

	}
}

Measured memory_bytes: 17184
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef int in;
#define int long long
#define pb push_back
#define f first
#define s second
const int MAX=1e5;
const int MAAX=1e9;
const int MOD=1e9+7;
in main()
{
int a,b;
cin>>a>>b;
int ans;
if(a<10)
{
    ans=b+100*(10-a);
}
else ans=b;
cout<<ans<<endl;
    return 0;
}


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

string s;
int n;
bool f = 1;

int main()
{
	cin >> s;

	n = s.size();

	for (int i = 0; i < n / 2; i++)
		if (s[i] != s[n - 1 - i] || s[i] != s[n / 2 - 1 - i])
			f = 0;

	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] C = new int[N];
		int[] S = new int[N];
		int[] F = new int[N];
		for(int i = 1; i < N; i++) {
			C[i] = sc.nextInt();
			S[i] = sc.nextInt();
			F[i] = sc.nextInt();
		}
		for(int i = 1; i < N; i++) {
			int ans = S[i] + C[i];
			for(int j = i+1; j < N; j++) {
				if(ans >= S[j]) {
					if((ans-S[j]) % F[j] == 0)
						ans += C[j];
					else
						ans += C[j] + F[j] - (ans-S[j]) % F[j];
				}
				else
					ans = S[j]+C[j];
			}
			System.out.println(ans);
		}
		System.out.println(0);
		
	}

}


Measured memory_bytes: 27016
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int M = in.nextInt();
        Map<Integer, List<Integer>> roads = new HashMap<>(M);
        for (int i = 0; i < M; i++) {
            int u = in.nextInt();
            int v = in.nextInt();
            roads.compute(u, (k, val) -> {
                if (val == null) val = new ArrayList<>();
                val.add(v);
                return val;
            });
            roads.compute(v, (k, val) -> {
                if (val == null) val = new ArrayList<>();
                val.add(u);
                return val;
            });
        }

        boolean[] visited = new boolean[N + 1];
        int components = 0;
        for (int i = 1; i <= N; i++) {
            if (!visited[i]) {
                dfs(roads, visited, i);
                components++;
            }
        }
        System.out.println(components - 1);
    }

    private static void dfs(Map<Integer, List<Integer>> roads, boolean[] visited, int start) {
        Stack<Integer> stack = new Stack<>();
        stack.push(start);
        while (!stack.isEmpty()) {
            int city = stack.pop();
            visited[city] = true;
            List<Integer> neighbours = roads.get(city);
            if (neighbours != null) {
                for (Integer n : neighbours) {
                    if (!visited[n]) {
                        stack.push(n);
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 74712
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())


N,K = MI()
dt = []
for i in range(N):
    t,d = MI()
    dt.append((d,t))

dt.sort(reverse=True)

basic_point = 0
ans = 0
used = set()
neta = [10**10]*(N+1)  # neta[t] = ネタtのある、最も左の位置
for i in range(K):
    d,t = dt[i]
    used.add(t)
    basic_point += d
    neta[t] = min(neta[t],i)
shurui = len(used)  # ネタの種類数
ans = basic_point + shurui**2

a,b = K-1,K
while a >= 0 and b < N:
    d1,t1 = dt[a]
    if neta[t1] != a:
        basic_point -= d1
        while b < N:
            d2,t2 = dt[b]
            if not t2 in used:
                used.add(t2)
                basic_point += d2
                shurui += 1
                ans = max(ans,basic_point + shurui**2)
                b += 1
                break
            else:
                b += 1
    a -= 1

print(ans)


Measured memory_bytes: 90036
def main():
    N, T = map(int, input().split())
    A = list(map(int, input().split()))
    tmp = A[-1]
    diff_A = [0] * N
    for i in range(N-1,-1,-1):
        tmp = max(A[i],tmp)
        diff_A[i] = tmp - A[i]

    print(diff_A.count(max(diff_A)))



if __name__ == "__main__":
    main()

Measured memory_bytes: 62704
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

#include <cmath>


using namespace std;

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

  int lowest = 0;

  for (int i = 0; i < n; i++) {
    int h;
    cin >> h;

    if (h < lowest) {
      cout << "No" << endl;
      return 0;
    }

    lowest = max(lowest, h - 1);
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
 
w, h, N = list(map(int, input().split()))
 
rect = [0, w, 0, h]
for i in range(N):
    x, y, a = list(map(int, input().split()))
    if [1, -1][a % 2] * ([x, y][a > 2] - rect[a - 1]) < 0:
        rect[a - 1] = [x, y][a > 2]

w, h = rect[1] - rect[0], rect[3] - rect[2]
if w > 0 and h > 0:
    print(w * h)
else:
    print(0)

Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define maxn 100005
using namespace std;
int a,b,c,d,e,f;
int ans1=0,ans2=0;
int main()
{
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);

	ans1=a*100;

	for(int i=0;i<=30;i++)
	{
		for(int j=0;j<=30;j++)
		{
			int sum1=i*100*a+j*100*b;
			if(sum1>=f) break;
			
			for(int k=0;k<=100;k++)
			{
				for(int o=0;o<=100;o++)
				{
					int sum2=k*c+o*d;
					if(sum1+sum2>f) break;

					if(sum2>sum1*e/100) continue;

					if(ans2*(sum1+sum2)<sum2*ans1)
					{
						ans2=sum2;
						ans1=(sum1+sum2);
					}
				}
			}
		}
	}

	printf("%d %d\n",ans1,ans2);
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define INF LONG_LONG_MAX
#define MOD 1000000007
#define yn(f) cout << (f ? "Yes" : "No") << endl;
#define YN(f) cout << (f ? "YES" : "NO") << endl;

int n,m,h[100000];
bool f[100000];

signed main() {
    rep(i,100000) f[i] = true;
    cin >> n >> m;
    rep(i,n) cin >> h[i];
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        --a,--b;
        if (h[a] <= h[b]) f[a] = false;
        if (h[b] <= h[a]) f[b] = false;
    }
    int ans=0;
    rep(i,n) if (f[i]) ans++;
    cout << ans << endl;
}




Measured memory_bytes: 4496
#include <bits/stdc++.h>
//#include <random>
#define int long long
#define double long double
#define endl "\n" 
const int INF = (int) 1e18 + 7;
const int maxn = (int) 1e4 + 6;
//const md = (int) 1e9 + 7;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using namespace std;

int dist(int x, int y) {
    return x*x + y*y;
}
signed main() {
    // d^2 <= dist
    int n, d; cin >> n >> d;
    int ans  = 0;
    d *= d;
    while(n--) {
        int x, y;
        cin >> x >> y;
        if(dist(x, y) <= d) ans++;
    }
    cout << ans << endl;
    return 0;
}



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

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 T gcd(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T lcm(T a,T b){return a*b/gcd(a,b);}

const ll INF = 1LL << 60;


int main(){
  int a[10];
  FOR(i,3){
    cin >> a[i];
  }
  sort(a,a+3);
  int count=0;
  while(a[0]!=a[1] || a[1]!=a[2] || a[0]!=a[2]){
    if(a[0]==a[1]){
      a[2]--;count++;
    }else if(a[1]==a[2]){
      a[0]+=2;count++;
    }else{
      a[0]+=2;count++;
    }
    sort(a,a+3);
  }
  cout << count << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define REP(i,s,n) for(int (i)=s; (i)<(int)(n);(i)++)
#define RIT(it,c) for(__typeof(c.begin()) it = c.begin();it!=c.end();it++)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)(x).size()
#define MSET(m,v) memset(m,v,sizeof(m))
 
 
using namespace std;
 
 
typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<LL> vL;
typedef vector<bool> vb;
typedef pair<int,vi> iv;
typedef pair<LL,LL> pLL; 
typedef long double LD;
typedef unordered_set<int> ui;

int N,M;
vector<ui> E;
vector<ii> Es;

bool conn(int i,int j){
	vb av(N, true);
	queue<int> que;
	av[i] = false;
	que.push(i);
	while(!que.empty()){
		int k = que.front();
		que.pop();
		for(auto l:E[k]) if(av[l]){
			if(l == j) return true;
			av[l] = false;
			que.push(l);
		}
	}
	return false;
}


int main(){
	std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>N>>M;
	E.resize(N);
	for(int i=0;i<M;++i){
		int u,v;
		cin>>u>>v;
		E[u-1].insert(v-1);
		E[v-1].insert(u-1);
		Es.push_back(ii(u-1,v-1));
	}
	int ans = M;
	for(auto p:Es){
		int u = p.first, v = p.second;
		E[u].erase(v);
		E[v].erase(u);
		if(conn(u,v)) --ans;
		E[u].insert(v);
		E[v].insert(u);
	}
	cout<<ans<<endl;
	return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    string s;
    cin >> s;

    for (int i = 2; i < s.size(); i += 2)
    {
        if (s.substr(0, (s.size() - i) / 2) == s.substr((s.size() - i) / 2, (s.size() - i) / 2))
        {
            OP(s.size() - i);
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  string A, B;
  A = to_string(a);
  B = to_string(b);
  int sum = stoi(A + B);
  int tmp = sqrt(sum);
  if(tmp*tmp==sum){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

int main(){
  int n, k; string s; cin >> n >> k >> s; k--;
  if(s[k] >= 'A') s[k] = 'a' + s[k] - 'A';
  cout << s << endl;
}


Measured memory_bytes: 256
import string

N = int(input())

alphabet = string.ascii_lowercase

SC = [50 for _ in range(len(alphabet))]

for _ in range(N):
    S = input()
    for i, x in enumerate(alphabet):
        SC[i] = min(SC[i], S.count(x))

print("".join([alphabet[i] * c for i, c in enumerate(SC)]))


Measured memory_bytes: 3772
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
mod=10**9+7
fan=[1]*(N+1)
for i in range(2,N):
  fan[i]=fan[i-1]*(i)%mod
ans=0
def comb(a,b):
  return fan[a]*pow(fan[b],mod-2,mod)*pow(fan[a-b],mod-2,mod)
for i in range(N-K+1):
  ans+=comb(N-i-1,K-1)*(A[N-i-1]-A[i])
  ans%=mod
print(ans)

Measured memory_bytes: 14412
#include <bits/stdc++.h>
#include <atcoder/all>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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 long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Q;
    cin >> N >> Q;
    auto uni = atcoder::dsu(N);
    for(int q = 0; q < Q; q++) {
        int t, u, v;
        cin >> t >> u >> v;
        if(t == 0) uni.merge(u, v);
        else cout << uni.same(u, v) << endl;
    }
    return 0;
}

Measured memory_bytes: 3880
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
using namespace std;

inline int getint()
{
	static char c;
	while ((c = getchar()) < '0' || c > '9');

	int res = c - '0';
	while ((c = getchar()) >= '0' && c <= '9')
		res = res * 10 + c - '0';
	return res;
}

const int MaxN = 3000;

int n;
int a[MaxN + 1];

vector<int> adj[MaxN + 1];

bool dfs(const int &u, const int &fa)
{
	for (int v : adj[u])
		if (v != fa && a[v] < a[u] && !dfs(v, u))
			return true;
	return false;
}

int main()
{
	cin >> n;
	for (int u = 1; u <= n; ++u)
		a[u] = getint();
	for (int i = 1; i < n; ++i)
	{
		int u = getint(), v = getint();
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	for (int u = 1; u <= n; ++u)
		if (dfs(u, 0))
			printf("%d ", u);

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}
//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

int strsum(const int n){
    string s = to_string(n);
    int b(0);
    rep(i,s.size()){
        b += s[i]-'0';
    }
    return b;
}

int main(){
    int n;
    cin >> n;
    map<string,int> mp;

    rep(i,n){
        string x;
        cin >> x;
        mp[x]++;
    }

    cout  << mp.size() << endl;
}

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

int main() {
    string s;
    cin >> s;
    if (s.size() == 3) reverse(s.begin(), s.end());
    cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll A[6];
    rep(i,3){
        cin >> A[i];
    }
    // sort(A,A+3);
    cout << (A[0]+A[1])*A[2]/2 << endl;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 10000000000;
const ll MOD = 1000000007;

using namespace std;

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

int main() {
	string a, b;
	cin >> a >> b;

	int al = a.length();
	int bl = b.length();

	if (al > bl) {
		cout << "GREATER" << endl;
		return 0;
	}
	else if(al < bl){
		cout << "LESS" << endl;
		return 0;
	}

	for (int i = 0; i < al; i++) {
		if (a[i] > b[i]) {
			cout << "GREATER" << endl;
			return 0;
		}
		else if(a[i] < b[i]) {
			cout << "LESS" << endl;
			return 0;
		}
	}
	cout << "EQUAL" << endl;


}


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

signed main(){
	int n,a,b;cin >>n>>a>>b;
	vector<int> x(n);
	for(auto&& w:x)cin>>w;
	
 int sum=0ll;
	for(int i=0;i<n-1;i++){
	sum+=min((x[i+1]-x[i])*a,b);
}
cout<<sum<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  string s;
  int ans=-1;
  cin >> s;
  vector<string> rec;

  for(int i=0; i<=sz(s); i++){
    for(int j=0; j<=sz(s); j++){
      string tmp=s.substr(i,j);
      rec.pb(tmp);
    }
  }
  rep(i,sz(rec)){
    string tmp=rec[i];
    bool f=true;
    rep(i,sz(tmp)){
      if(tmp[i]!='A' && tmp[i]!='C' && tmp[i]!='G' && tmp[i]!='T') f=false;
    }
    if(f) chmax(ans,sz(tmp));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, a[99];
long long acc, stk;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	acc = 1000;
	for (int i = 0; i < n - 1; i++) {
		if (a[i] < a[i + 1]) {
			stk += acc / a[i];
			acc %= a[i];
		}
		else {
			acc += stk * a[i];
			stk = 0;
		}
	}
	acc += stk * a[n - 1];
	cout << acc << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 3644
main :: IO ()
main = do
  n <- readLn :: IO Int
  let m = n `mod` 10
  putStrLn $ solve m

solve :: Int -> String
solve x
  | x == 3 = "bon"
  | or [x == 0, x == 1, x == 6, x == 8] = "pon"
  | otherwise = "hon"


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

bool f[1000001] = {};

int main() {

    long long int a, b;
    cin >> a >> b;

    long long int ans = 1;

    for ( long long int i = 2; i <= 1000000; i++ ) {
        if ( f[i] == true ) continue;

        if ( ( a % i ) == 0 && ( b % i ) == 0 ) ans++;
        while( a % i == 0 ) {
            a /= i;
        }
        while( b % i == 0 ) {
            b /= i;
        }
        for ( long long int j = 2; j * i <= 1000000; j++ ) {
            f[j*i] = true;
        }
    }
    if ( a == b && a > 1 ) ans++;

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var bodystr = Console.ReadLine();
        var bodyArray = bodystr.ToCharArray();
        var countNum = int.Parse(Console.ReadLine());
        var endArray = new string[200000];
        var firstArray = new string[200000];
        var firstPlace = 0;
        var endPlace = 0;
        var gyaku = false;

        for (var i = 0; i < countNum; i++)
        {
            var allShiji = Console.ReadLine();
            var shijiList = allShiji.Split(' ');
            if (shijiList[0] == "1")
            {
                gyaku = !gyaku;
            }
            else
            {
                if (shijiList[1] == "1")
                {
                    if (gyaku)
                    {
                        endArray[endPlace] = shijiList[2];
                        endPlace++;
                    }
                    else
                    {
                        firstArray[firstPlace] = shijiList[2];
                        firstPlace++;
                    }
                }
                else
                {
                    if (!gyaku)
                    {
                        endArray[endPlace] = shijiList[2];
                        endPlace++;
                    }
                    else
                    {
                        firstArray[firstPlace] = shijiList[2];
                        firstPlace++;
                    }
                }

            }
        }

        var str = "";

        if (gyaku)
        {
            str = string.Join("", endArray.Reverse()) + string.Join("", bodyArray.Reverse()) + string.Join("", firstArray);
        }
        else
        {
            str = string.Join("", firstArray.Reverse()) + string.Join("", bodyArray) + string.Join("", endArray);
        }
        Console.WriteLine(str);
    }
}

Measured memory_bytes: 28208
#include <iostream>
#include <cstring>

using namespace std;

int main() {
  int n = 0;
  cin >> n;
  
  double sum = 0.0;
  double times = 380000.0;
  for(int i = 0; i < n; ++i) {
    double num = 0.0;
    string kind;
    
    cin >> num >> kind;
    if(kind[0] == 'J') {
      sum += num;
    } else {
      sum += (num * times);
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <functional>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言

int main() {
  int n;
  string a, b, c;
  cin >> n >> a >> b >> c;
  int cnt = 0;

  for(int i=0; i<n; ++i) {
    if(a[i] == b[i] && a[i]== c[i]) {
      continue;
    }

    if(a[i] == b[i]) {
      c[i] == a[i];
      cnt += 1;
    }else if(a[i] == c[i]) {
      b[i] == a[i];
      cnt += 1;
    }else if(b[i] == c[i]) {
      a[i] == b[i];
      cnt += 1;
    }else {
      b[i] = a[i];
      c[i] = a[i];
      cnt += 2;
    }
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define speedX ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout<< name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_time() cout << "\n\nTime of execution: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define trace(...)
#define end_time()
#endif


#define int long long 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
inline bool equals(ld a, ld b) {return fabs(a - b) < 1e-9;}
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define mod 1000000007


void solve(){
    int n;
    cin>>n;
    if(n%2==1){
        cout<<"0";
        return;
    }
    else{
        int tmp = 10;
        int ans = 0;
        while(n/tmp){
            ans+=(n/tmp);
            tmp*=5;
        }
        cout<<ans;
    }
}
signed main(){
    speedX;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    end_time();
    return 0;
}

Measured memory_bytes: 256
import math
from collections import deque
from collections import defaultdict

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq

x = readInt()
if x==2:
	print(x)
	exit()
if x%2==0:
	x+=1

for i in range(x,10**6,2):
	flg = 1
	for j in range(3,int(i**0.5),2):
		if i%j==0:
			flg = 0
			break
	if flg:
		print(i)
		break

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=103,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S,T;cin>>S>>T;
    int N=S.size(),M=T.size();
    
    vector<vector<int>> cnt(N+1,vector<int>(26)),cnt2(M+1,vector<int>(26));
    
    for(int i=1;i<=N;i++){
        cnt[i]=cnt[i-1];
        cnt[i][S[i-1]-'a']++;
    }
    
    int ans=0;
    
    for(int i=1;i<=M;i++){
        cnt2[i]=cnt2[i-1];
        cnt2[i][T[i-1]-'a']++;
    }
    
    for(int t=1;t<=min(N,M);t++){
        map<vector<int>,bool> MA;
        
        for(int i=1;i<=N;i++){
            for(int j=i-t;j<i-t+1;j++){
                if(j<0) continue;
                vector<int> c(26);
                for(int k=0;k<26;k++) c[k]=cnt[i][k]-cnt[j][k];
                
                MA[c]=1;
            }
        }
        
        for(int i=1;i<=M;i++){
            for(int j=i-t;j<i-t+1;j++){
                if(j<0) continue;
                vector<int> c(26);
                for(int k=0;k<26;k++) c[k]=cnt2[i][k]-cnt2[j][k];
                
                if(MA.count(c)) ans=max(ans,i-j);
            }
        }
    }
    
    cout<<ans<<endl;
}



Measured memory_bytes: 4744
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
        int count = 0;
        for (int i = Math.min(A,B); i > 0; i--) {
            if (A % i == 0 && B % i  == 0) {
                count++;
            }
            if (count == K) {
                System.out.println(i);
                break;
            }
        }
    }
}


Measured memory_bytes: 23764
ans = 0

def rec(num,flag,co,N):
    global ans
    if num>N:
         return  0

    else:
        if flag  == 0b111:
            # print(ans)
            ans += 1
        return rec(num * 10 + 7, flag|0b001,co + 1,N ) + rec(num * 10 + 3,flag|0b100,co + 1,N ) +rec(num * 10 + 5,flag|0b010 ,co + 1,N )
def c():
    bit07 = 0b001
    bit05 = 0b010
    bit03 = 0b100
    global ans
    N = input()
    N = int(N)
    rec(3,bit03,0,N)
    rec(5,bit05,0,N)
    rec(7,bit07,0,N)

    print(ans)
if __name__ == "__main__":
    c()

Measured memory_bytes: 3064
/*
 * Author:  heyuhhh
 * Created Time:  2020/5/31 20:01:06
 */
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
#include <functional>
#include <numeric>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A> 
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e5 + 5;
const ll MAX = 1e18;

void run() {
    int n; cin >> n;
    vector <ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) if (a[i] == 0) {
        cout << 0 << '\n';
        return;
    }
    ll ans = 1;
    for (int i = 0; i < n; i++) {
        if (a[i] > MAX / ans) {
            cout << -1 << '\n';
            return;
        }
        ans *= a[i];
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}

Measured memory_bytes: 3988
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int arr[200003] = {};
int mx[200003] = {};
int mx_rev[200003] = {};

int main() {
	int n;
	cin>>n;
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	mx[0] = arr[0];
	for(int i = 1; i <= n; i++) {
		mx[i] = max(mx[i-1],arr[i]);
	}
	mx_rev[n-1] = arr[n-1];
	for(int i = n-2; i >= 0; i--) {
		mx_rev[i] = max(mx_rev[i+1],arr[i]);
	}
	cout << mx_rev[1] << endl;
	for(int i = 1; i < n-1; i++) {
		cout << max(mx[i-1],mx_rev[i+1]) << endl;
	}
	cout << mx[n-2] << endl;
	return 0;
}


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

void Main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i,N) {cin >> A[i];}
  sort(A.begin(), A.end());
  int m = A[0];
  int prev = 1e7;
  int idx = 0;
  while (m != prev ) {
    prev = m;
    while (idx < A.size()) {
      int res = A[idx] % m;
      if (res != 0 && res < m) {
        m = res;
        A[idx] = m;
        sort(A.begin(), A.end());
        idx = 0;
      } else idx++;
    }
  }
  cout << m << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

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


int main() {
	int n,ans = 0;
	cin >> n;
	vector<string> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	int m;
	cin >> m;
	vector<string> b(m);
	rep(i, m) {
		cin >> b[i];
	}
	int sub;
	rep(i, n) {
		sub = 0;
		rep(j, n) {
			if (a[i] == a[j]) {
				sub++;
			}
		}
		rep(j, m) {
			if (a[i] == b[j]) {
				sub--;
			}
		}
		ans = max(ans, sub);
	}
	cout << ans << endl;
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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; }

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};

int main(){
  string s,t; cin >> s >> t;
  int a,b;
  string u; cin >> a >> b >>u;
  if(u == s) a--;
  else b--;
  cout << a << " " << b << endl;
}

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

#include <math.h>
#include <stdlib.h>


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

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; }

// const int INF = 1001001001;
// long long max => LLONG_MAX

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<int> l(n);
    for(int i = 0; i < n; i++) cin >> l[i];
    sort(l.rbegin(), l.rend());
    

    ll ans = 0;
    for(ll f = 0; f < n-2; f++){
        ll t = n-1;
        for(ll s = f+1; s < n-1; s++){
            if(t <= s) break;
            while(l[f] >= l[t] + l[s]) t--;
            if(t > s) ans += (t-s);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):
        return len(self.roots())
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
    
uf = UnionFind(N)
for _ in range(M):
    a, b = map(int, input().split())
    uf.union(a-1, b-1)

print(len(uf.roots())-1)

Measured memory_bytes: 12764
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int N = 2000005;
vector <int> prime;

void sieve() {
  vector <bool> pr(N, 1);
  for (int i = 2; i < N; i++) {
    if (pr[i]) {
      prime.push_back(i);
      for (long long j = 1ll * i * i; j < N; j += i) {
        pr[j] = 0;
      }
    }
  }
}

int main() {
  long long n, p;
  cin >> n >> p;
  if (n > 50) {
    cout << 1 << endl;
    return 0;
  }
  if (n == 1) {
    cout << p << endl;
    return 0;
  }
  sieve();
  long long ans = 1;
  for (int i = 0; i < prime.size(); i++) {
    bool ok = 1;
    long long res = 1;
    for (int j = 0; j < n && ok; j++) {
      res *= prime[i];
      if (res > p) {
        ok = 0;
        break;
      }
    }
    if (!ok) continue;
    while (p % res == 0) {
      p /= res;
      ans *= prime[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1656
N, Y = map(int, input().split())
x0, y0, z0 = [-1, -1, -1]
for x in range(0, N + 1):
  for y in range(0, N+1-x):
    z = N -x-y
    if (x*10000+y*5000+z*1000 == Y):
      x0, y0, z0 = [x, y, z]
print(x0, y0, z0)


Measured memory_bytes: 3060
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int n,m,ans=1;
vector<int> a;//何回割れたか
int fac[111111],finv[111111],inv[111111];

void COMinit(){
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<111111;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;
	}
}

int COM(int n,int k){
	if(n<k)return 0;
	if(n<0||k<0)return 0;
	return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

void solve(){
	for(int i=2;i*i<=m;i++){
		if(m%i==0){
			int tmp=0;
			for(;m%i==0;){
				m/=i;
				tmp++;
			}
			//cout<<tmp<<endl;
			a.pb(tmp);
		}
	}
    if(m!=1)a.pb(1);
	for(int x:a){
		ans*=COM(n+x-1,x);
		ans%=MOD;
	}
}

main(){
	COMinit();
	//rep(i,11111)cout<<fac[i]<<endl;
	cin>>n>>m;
	solve();
	//cout<<COM(4,2)<<endl;
	cout<<ans%MOD<<endl;
}


Measured memory_bytes: 2816
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		for(int i = 0 ; i < 3 ; i++) ou.print((char)(sc.next().charAt(0) - 32));
		ou.println();
		ou.flush();
	}
}

Measured memory_bytes: 35624