akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 998244353
#define INF 1145141919810364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n;
int ans = INF;

signed main() {
	cin >> n;
	for (int i = 0; i <= n; i++) {
		int cnt = 0;
		int k = i;
		int p = 1;
		while (p * 6 <= k)p *= 6;
		while (k) {
			cnt += k / p;
			k %= p;
			p /= 6;
		}
		k = n - i;
		p = 1;
		while (p * 9 <= k)p *= 9;
		while (k) {
			cnt += k / p;
			k %= p;
			p /= 9;
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
//saikyogakusei1_a.cpp
//Sun Sep 15 07:52:00 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int m,d;
	cin >> m >> d;

	int ans = 0;
	for (int i=1;i<=d;i++){
		int x = i%10;
		int y= i/10;
		if (x>=2 && y>=2 && x*y<=m){
			ans++;
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

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

int main()
{
    int N, M;
    cin >> N >> M;

    int correct = 0;
    int wrong = 0;

    int list[N]{0};

    for (int i = 0; i < M; i++)
    {
        int x;
        string y;
        cin >> x >> y;
        //不正解or未回答
        if (list[x - 1] != -1)
        {
            //正解
            if (y == "AC")
            {
                correct++;
                wrong += list[x - 1];
                list[x - 1] = -1;
            }
            //また不正解
            else
            {
                list[x - 1] ++;
            }
        }
    }
    cout << correct << " " << wrong;
}

Measured memory_bytes: 640
// D - Derangement
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int solve(int N, vi &P){
	int ans = 0;
	rp(i, 1, N){
		if(P[i-1] == i){//L=X
			swap(P[i-1], P[i]);//LR swap
			ans++;
			i++;
		}
	}
	// i=N の処理
	if(P[N-1] == N){//R=X
		swap(P[N-1], P[N-2]);//LR swap
		ans++;
	}
	return ans;
}

int main(){
	int N; cin>>N;
	vi P(N); rp(i, 0, N) cin>>P[i];
	cout<< solve(N, P) <<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 800010
using namespace std;
ll n,q,bin[N],sum[N],dp,val[N][2];
vector<pair<ll,ll> > vp;
void update(ll x,ll tl,ll tr,ll l,ll r,ll v,ll num)
{
	if(l<=tl&&r>=tr)
	{
		val[x][num]=max(val[x][num],v);
		return;
	}
	ll mid=(tl+tr)>>1;
	ll nl=x+((mid-tl+1)<<1);
	if(l<=mid)
	{
		update(x+1,tl,mid,l,r,v,num);
	}
	if(r>mid)
	{
		update(nl,mid+1,tr,l,r,v,num);
	}
	val[x][num]=max(val[x+1][num],val[nl][num]);
	return;
}
ll getans(ll x,ll tl,ll tr,ll l,ll r,ll num)
{
	if(l<=tl&&r>=tr)
	{
		return val[x][num];
	}
	ll mid=(tl+tr)>>1,ret;
	ll nl=x+((mid-tl+1)<<1);
	if(r<=mid)
	{
		ret=getans(x+1,tl,mid,l,r,num);
	}
	else if(l>mid)
	{
		ret=getans(nl,mid+1,tr,l,r,num);
	}
	else
	{
		ret=max(getans(x+1,tl,mid,l,r,num),getans(nl,mid+1,tr,l,r,num));
	}
	val[x][num]=max(val[x+1][num],val[nl][num]);
	return ret;
}
int main(){
	ll i,x,y,ans=0;
	cin>>n;
	memset(val,-127,sizeof(val));
	sum[0]=0;
	for(i=0;i<n;i++)
	{
		cin>>bin[i];
		if(bin[i]==1)
		{
			sum[i+1]=sum[i]+1;
		}
		else
		{
			sum[i+1]=sum[i]-1;
		}
	}
	cin>>q;
	while(q--)
	{
		cin>>x>>y;
		vp.push_back(make_pair(x,y));
	}
	sort(vp.begin(),vp.end());
	update(0,0,n-1,0,0,0,0);
	for(i=0;i<vp.size();i++)
	{
		x=vp[i].F;
		y=vp[i].S;
		dp=max(sum[y]-sum[x-1]+getans(0,0,n-1,0,x-1,0),sum[y]+getans(0,0,n-1,x,y,1));
		update(0,0,n-1,y,y,dp,0);
		update(0,0,n-1,y,y,dp-sum[y],1);
		ans=max(ans,dp);
	}
	for(i=0;i<n;i++)
	{
		if(bin[i]==0)
		{
			ans++;
		}
	}
	cout<<n-ans<<endl;
	return 0;
}

Measured memory_bytes: 22896
from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    """
    https://qiita.com/drken/items/4a7869c5e304883f539b#3-3-dfs-%E3%81%AE%E5%86%8D%E5%B8%B0%E9%96%A2%E6%95%B0%E3%82%92%E7%94%A8%E3%81%84%E3%81%9F%E5%AE%9F%E8%A3%85
    cf. https://atcoder.jp/contests/abc138/submissions/13273052
    """

    N, M = map(int, input().split())  # 頂点数，辺数
    # グラフ入力受取 (ここでは無向グラフを想定)
    G = [[] for _ in range(N)]
    for i in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        G[a].append(b)
        G[b].append(a)
    ans = 0

    for i in permutations(range(N)):
        flag = True
        if i[0] != 0:
            continue
        nn=0
        for j in range(N-1):
            if i[j+1] not in G[nn]:
                flag = False
            nn=i[j+1]
        if flag:
            ans += 1
    print(ans)


resolve()

Measured memory_bytes: 71496
N = int(input())
a = []
ans = 0
BA = 0
B = 0
A = 0
for i in range(N):
  x = input()
  for j in range(len(x)-1):
    if x[j] == "A" and x[j+1] == "B":
      ans += 1
  if x[0] == "B" and x[-1] == "A":
    BA += 1
  elif x[0] == "B":
    B += 1
  elif x[-1] == "A":
    A += 1
if BA != 0:
  ans += (BA-1)
  if A != 0 and B != 0:
    ans += (min(A,B)+1)
  elif A == 0 and B == 0:
    ans = ans
  else:
    ans += 1
else:
  ans += min(A,B)
print(ans)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static int MAX = 500000;
	public static int SENTINEL = 2000000000;
	public static int[]L = new int[MAX / 2 + 2];
	public static int[]R = new int[MAX / 2 + 2];
	public static int cnt;

	public static void main(String[] args) throws IOException {
		//Scanner scan = new Scanner(System.in);
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		//scan.close();
		int []A = new int[n];
//		for(int i = 0; i < n; i++) {
//			A[i] = scan.nextInt();
//		}

		String s = br.readLine();
		String[] num = s.split(" ");
		for(int i = 0; i < n; i++) {
			A[i] = Integer.parseInt(num[i]);
		}
		br.close();
		cnt = 0;
		mergeSort(A, n, 0, n);
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < n - 1; i++) {
			sb.append(A[i]);
			sb.append(" ");
			//System.out.print(A[i] + " ");
		}
		System.out.print(sb.toString());
		System.out.println(A[n - 1]);
		System.out.println(cnt);
	}

	public static void merge(int A[], int n, int left, int mid, int right) {
		int n1 = mid - left;
		int n2 = right - mid;
		for(int i = 0; i < n1; i++) {
			L[i] = A[left + i];
		}
		for(int i = 0; i < n2; i++) {
			R[i] = A[mid + i];
		}
		L[n1] = SENTINEL;
		R[n2] = SENTINEL;
		int i = 0;
		int j = 0;
		for(int k = left; k < right; k++) {
			cnt ++;
			if(L[i] <= R[j]) {
				A[k] = L[i ++];
			}else {
				A[k] = R[j ++];
			}
		}
	}
	public static void mergeSort(int A[], int n, int left, int right) {
		if(left + 1 < right) {
			int mid = (left + right) / 2;
			mergeSort(A, n, left, mid);
			mergeSort(A, n, mid, right);
			merge(A, n, left, mid, right);
		}
	}
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using LL = long long;
using ULL = unsigned long long;


void solve() {
	int n; cin >> n;
	pair<int, int> x[500]; rep(i, n) { x[i].second = i + 1; cin >> x[i].first; }
	sort(x, x + n);

	vector<int> buf;
	buf.resize(n*n);
	size_t p = 0;
	rep(i, n) {
		int k = x[i].second;
		size_t kp = x[i].first - 1;
		for (int j = 0; j < k - 1; j++) {
			for (; buf[p] != 0; p++) {
				if (p == kp) {
					cout << "No" << endl; return;
				}
			}
			buf[p] = k;
		}
		buf[kp] = k;
	}
	rep(i, n) {
		int k = x[i].second;
		size_t kp = x[i].first - 1;
		for (int j = 0; j < n - k; j++) {
			for (; buf[p] != 0; p++) {}
			if (p < kp) {
				cout << "No" << endl; return;
			}
			buf[p] = k;
		}
	}

	cout << "Yes" << endl;
	rep(i, buf.size()) {
		if (i != 0) cout << " ";
		cout << buf[i];
	}
}

int main() {

	solve();

	return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    string  S,T;
    cin >> S >> T;
    int A,B;
    cin >> A >> B;
    string U;
    cin >> U;
    if(S == U){
        A--;
    }else{
        B--;
    }
    cout << A << " " << B << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define mod(n, m) (((n%m) + m)%m)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'

/*
 * Constraints:
 * n = 2e5
 * a[i] = [1, 1e9]
 */

const int N = 2e5 + 100;
int n;

ll vec[N];

ll check(ll mid)
{
	ll ret = 0;

	rep(i, 0, n)
		ret += abs(vec[i] - (mid + (i*1ll + 1)));

	return ret;
}

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

	cin >> n;

	rep(i, 0, n)
		cin >> vec[i];

	ll st = -1e16, en = 1e16, mid, ret = st - 1;

	while (st <= en)
	{
		mid = (st + en) / 2ll;

		if (check(mid) > check(mid + 1))
			st = mid + 1;
		else
			en = mid - 1, ret = mid;
	}

	cout << check(ret) << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
int main()
{
    string s,t;
    cin >> s;
    cin >> t;

    if(strncmp(s.c_str(),t.c_str(),s.size())==0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
/*



*/


#include<bits/stdc++.h>

using namespace std;

#define fstinpt     ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll          long long
#define sn          1010
#define bn          6000007
#define M           1000000007
#define sss         cout<<" "
#define nnn         cout<<"\n"



int main()
{
        fstinpt;
        ll a,b;
        cin>>a>>b;
        if(b%2) cout<<"No";
        else if(2*a > b) cout<<"No";
        else if(4*a < b) cout<<"No";
        else cout<<"Yes";
        return 0;
}


/*











*/






















/**/


Measured memory_bytes: 3656
#pragma GCC target ("avx2")
#pragma GCC optimize ("Ofast")
#pragma GCC push_options
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
#define pb push_back
#define __V vector
#define all(x) x.begin(), x.end()
#define oit ostream_iterator
#define mod 998244353ll
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
}
template<typename X, typename Y>
istream& operator>>(istream& in, pair<X, Y> &a) {
	in >> a.first >> a.second;
	return in;
}
template<typename T>
void getv(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv(vector<T>& v, int n, Ns ... ns) {
	v.resize(n);
	for (auto& i : v)
		getv(i, ns...);
}
template<typename T>
void getv1(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv1(vector<T>& v, int n, Ns ... ns) {
	v.resize(n + 1);
	for (int i = 1; i <= n; i++)
		getv(v[i], ns...);
}
#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
inline void getch(char &x) {
	while (x = getchar_unlocked(), x < 33) {
		;
	}
}
inline void getstr(string &str) {
	str.clear();
	char cur;
	while (cur = getchar_unlocked(), cur < 33) {
		;
	}
	while (cur > 32) {
		str += cur;
		cur = getchar_unlocked();
	}
}
template<typename T> inline bool sc(T &num) {
	bool neg = 0;
	int c;
	num = 0;
	while (c = getchar_unlocked(), c < 33) {
		if (c == EOF)
			return false;
	}
	if (c == '-') {
		neg = 1;
		c = getchar_unlocked();
	}
	for (; c > 47; c = getchar_unlocked())
		num = num * 10 + c - 48;
	if (neg)
		num *= -1;
	return true;
}
typedef unsigned long long ull;
typedef long long ll;
typedef float ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
using AntonTsypko = void;
using arsijo = AntonTsypko;
using god = arsijo;
uniform_real_distribution<double> double_dist(0, 1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
int main() {
//	doin();
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(b / a, c);
	return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

void solve()
{
	int n;
	cin >> n;
	unsigned long long int sum = 0;
	for(int i = 0; i < n; ++i)
	{
		int a;
		cin >> a;
		sum += a;
	}
	cout << sum / n << endl;
}

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

Measured memory_bytes: 1152
//Dlove's template
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>

#define R register
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define sqr(_x) ((_x) * (_x))
#define Cmax(_a, _b) ((_a) < (_b) ? (_a) = (_b), 1 : 0)
#define Cmin(_a, _b) ((_a) > (_b) ? (_a) = (_b), 1 : 0)
#define Max(_a, _b) ((_a) > (_b) ? (_a) : (_b))
#define Min(_a, _b) ((_a) < (_b) ? (_a) : (_b))
#define Abs(_x) (_x < 0 ? (-(_x)) : (_x))

using namespace std;

namespace Dntcry
{
	inline int read()
	{
		R int a = 0, b = 1; R char c = getchar();
		for(; c < '0' || c > '9'; c = getchar()) (c == '-') ? b = -1 : 0;
		for(; c >= '0' && c <= '9'; c = getchar()) a = (a << 1) + (a << 3) + c - '0';
		return a * b;
	}
	inline ll lread()
	{
		R ll a = 0, b = 1; R char c = getchar();
		for(; c < '0' || c > '9'; c = getchar()) (c == '-') ? b = -1 : 0;
		for(; c >= '0' && c <= '9'; c = getchar()) a = (a << 1) + (a << 3) + c - '0';
		return a * b;
	}
	int Main()
	{
		R int a = read(), b = read();
		b >>= 1;
		printf("%d\n", a + b);
		return 0;
	}
}
int main()
{
	return Dntcry :: Main();
}


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

using namespace std;
int N, A, B, C;
int INF = 1e9;
vector<int>l(N);

int dfs(int tmp,int a,int b,int c) {
	if (tmp == N) {
		if (min({ a, b, c }) > 0) {
			return abs(a - A) + abs(b - B) + abs(c - C) - 30;
		}
		else {
			return INF;
		}
	}
	int ans = dfs(tmp + 1, a, b, c);
	int ans1 = dfs(tmp + 1, a + l[tmp], b, c) + 10;
	int ans2 = dfs(tmp + 1, a, b + l[tmp], c) + 10;
	int ans3 = dfs(tmp + 1, a, b, c + l[tmp]) + 10;

	return min({ ans,ans1,ans2,ans3 });
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> A >> B >> C;
	for (int i = 0; i < N; i++){
		int k;
		cin >> k;
		l.push_back(k);
	}
	cout << dfs(0, 0, 0, 0) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 1e18
#define pi 3.1415926535898
#define popcount __builtin_popcount //确定二进制中1的个数
using namespace std;
const int N=4e5+10;
vector <pair<int,int> > x[N],y[N];
int n,dic[150],f[2*N][2],g[2*N][2];
ll ans=inf;
int main()
{
    cin>>n;
    dic['U']=0;
    dic['D']=1;
    dic['R']=2;
    dic['L']=3;
    for(int i=1; i<=n; i++)
    {
        int a,b,c;
        cin>>a>>b;
        char str[6];
        scanf("%s",str);
        a++,b++;
        c=dic[str[0]];
        x[a].push_back(make_pair(b,c));
        y[b].push_back(make_pair(a,c));
    }
    for(int i=1; i<N; i++)
    {
        sort(x[i].begin(),x[i].end());
        sort(y[i].begin(),y[i].end());
        ll a=inf;
        ll b=inf;
        for(auto j:x[i])
        {
            if(j.second==0)
                a=j.first;
            else if(j.second==1)
                b=j.first;
            if(a<b)
                ans=min(ans,(b-a)*5);
        }
        a=inf;
        b=inf;
        for(auto j:y[i])
        {
            if(j.second==2)
                a=j.first;
            else if(j.second==3)
                b=j.first;
            if(a<b)
                ans=min(ans,(b-a)*5);
        }
    }
    for(int i=1; i<N; i++)
        for(auto j:x[i])
        {
            int t=j.first;
            if(j.second==2)
            {
                f[j.first-i+N][0]=i;
                f[j.first+i][1]=i;
            }
            else if(j.second==3)
            {
                int k=g[j.first+i][1];
                if(k)
                    ans=min(ans,(i-k)*10LL);
                k=g[j.first-i+N][0];
                if(k)
                    ans=min(ans,(i-k)*10LL);
            }
            else if(j.second==1)
            {
                int k=f[j.first-i+N][0];
                if(k)
                    ans=min(ans,(i-k)*10LL);
                g[j.first+i][1]=i;
            }
            else if(j.second==0)
            {
                int k=f[j.first+i][1];
                if(k)
                    ans=min(ans,(i-k)*10LL);
                g[j.first-i+N][0]=i;
            }
        }
    if(ans>inf/2)
        cout<<"SAFE"<<endl;
    else
        cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 40168
n = [0]
n1 = list(input())
n2 = [int(s) for s in n1]
nn = len(n1)
n = n + n2
# print(n)

ans = 0
for i in range(nn, -1, -1):
    # print(n[i])
    if n[i] >= 10:
        n[i - 1] += 1
    elif n[i] == 5:
        if n[i - 1] >= 5:
            ans += n[i]
            n[i - 1] += 1
        else:
            ans += n[i]
    elif n[i] < 5:
        ans += n[i]
    else:
        ans += 10 - n[i]
        n[i - 1] += 1
print(ans)


Measured memory_bytes: 29164
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n;cin>>n;
    vector<vector<ll> >a(10000*n+n);
    vector<ll>in(10000*n+n,-1);
    rep(i,n){
        ll x;cin>>x;
        rep(j,n-2){
            in[min(i+1LL,x)*10000+max(i+1LL,x)]=0;
            ll y;cin>>y;
            a[min(i+1LL,x)*10000+max(i+1LL,x)].pb(min(i+1LL,y)*10000+max(i+1LL,y));
            x=y;
            in[min(i+1LL,x)*10000+max(i+1LL,x)]=0;
        }
    }
    rep(i,a.size()){
        if(a[i].size()){
            for(auto e:a[i]){
                in[e]++;
            }
        }
    }
    queue<ll> q;
    vector<ll>depth(10000*n+n);
    rep(i,a.size()){
        if(in[i]==0)q.push(i);
        depth[i]=1;
    }
    ll cnt=0;
    while(!q.empty()){
        ll k=q.front();
        //cout<<k<<endl;
        cnt++;
        for(auto e:a[k]){
            in[e]--;
            if(in[e]==0){
                q.push(e);
                depth[e]=depth[k]+1;
            }
        }
        q.pop();
    }
    ll ma=0;
    rep(i,a.size())ma=max(ma,depth[i]);
    cout<<(cnt==n*(n-1)/2?ma:-1)<<endl;
}

Measured memory_bytes: 406528
#include <stdio.h>

int main()
{
    int W=0,H=0,x=0,y=0,r=0;
    
    scanf("%d %d %d %d %d\n",&W,&H,&x,&y,&r);
    
    if((x-r)<0 || (x+r)>W)
    {
        printf("No\n");
    }else if((y-r)<0||(y+r)>H)
    {
        printf("No\n");
    }else
    {
        printf("Yes\n");
    }
    
    return 0;
}


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

using namespace std;

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

Measured memory_bytes: 256
#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;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string inp;
    cin >> inp;
    
    rep(i, inp.size()){
        if(inp[i] == 'U' or inp[i] == 'D') continue;
        
        if(i % 2 == 0){
            if(inp[i] == 'L') {
                cout <<"No" << endl;
                return 0;
            }
        }else{
            if(inp[i] == 'R'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    
    cout << "Yes" << endl;
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,N) for(int i=(int)(j);i<(int)(N);i++)
const ll inf=1e9+7;
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; }

int n;
int main(){
  int a[20],b[20],c[20];

  cin>>n;
  rep(i,0,n) cin>>a[i];
  rep(i,0,n) cin>>b[i];
  rep(i,0,n-1) cin>>c[i];

  int ans=0;
  rep(i,0,n){
    int num=a[i]-1;
    ans+=b[num];

    if(num<n-1 && i<n-1){
      if(a[i]+1==a[i+1]) ans+=c[num];
    }
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <ull> vu;
typedef vector <vector <int>> vvi;
typedef vector <vector <ll>> vvl;
typedef pair <int, int> pi;
typedef vector <pair <int, int>> vpi;

int n, k;

void read() {
  cin >> n >> k;
  --k;
}

void solve() {
  cout << (n + k - 2) / k;
}

int main() {
  ios :: sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  //cin >> t; //please do not forget to comment this if there are no queries
  while(t) {
    --t;
    read();
    solve(); 
  }
  return 0;
}


Measured memory_bytes: 256
$tg = []

def build(ts)
  tn = []
  ts.each do |ss|
    s = ss.to_s
    ['3', '5', '7'].each do |c|
      s.length.times do |i|
        ns = s.dup
        ns.insert(i, c)
        tn.push(ns.to_i)
      end
    end
  end
  tn.uniq!

  return tn
end

def solve(ns)
  fig = ns.length
  n = ns.to_i

  ts = [ 357, 375, 537, 573, 735, 753]
  $tg.push(ts)
  for i in 3...fig do
    $tg.push(ts)
    ts = build(ts)
    $tg.push(ts)
  end

  $tg.flatten!
  $tg.sort!.uniq!
  $tg.reverse!
  at = $tg.length
  $tg.length.times do |j|
     if $tg[j] <= n
       at = j
       break
     end
  end
  num = $tg.length - at
  return num
end

ns = gets.chomp
num = solve(ns)
puts num


Measured memory_bytes: 6212
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))
 
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;
 
#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))
 
int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}
 
const int N = 1 << 20;
 
const int mod = 924844033;
 
const int g = 5;
 
int fpow(int a, int x)
{
	int ret = 1;
	for (; x; x >>= 1)
	{
		if (x & 1) ret = 1LL * ret * a % mod;
		a = 1LL * a * a % mod;
	}
	return ret;
}
 
int n;
 
vector<int> edge[N];
 
int cnt[N], siz[N], fac[N], ifac[N];
 
int C(int n, int m)
{
	if (n < m || m < 0) return 0;
	return 1LL * fac[n] * ifac[n - m] % mod * ifac[m] % mod;
}
 
void dfs(int u, int fa)
{
	siz[u] = 1;
	for (auto v : edge[u])
	{
		if (v == fa) continue;
		dfs(v, u);
		siz[u] += siz[v];
	}
	for (auto v : edge[u])
	{
		if (v == fa)
		{
			++cnt[n - siz[u]];
			continue;
		}
		++cnt[siz[v]];
	}
}
 
void dft(int *a, int n, int sig)
{
	for (int i = 0, j = 0; i < n; ++i)
	{
		if (i > j) swap(a[i], a[j]);
		for (int l = n >> 1; (j ^= l) < l; l >>= 1);
	}
	for (int i = 1; i < n; i <<= 1)
	{
		int m = i << 1;
		int w = fpow(g, (mod - 1) / m);
		if (sig == -1) w = fpow(w, mod - 2);
		for (int j = 0; j < n; j += m)
		{
			int v = 1;
			for (int k = j; k < j + i; ++k, v = 1LL * v * w % mod)
			{
				int x = a[k], y = 1LL * a[k + i] * v % mod;
				a[k] = (x + y) % mod;
				a[k + i] = (x - y + mod) % mod;
			}
		}
	}
	if (sig == -1)
	{
		int invn = fpow(n, mod - 2);
		for (int i = 0; i < n; ++i) a[i] = 1LL * a[i] * invn % mod;
	}
}
 
int main()
{
	gi(n);
	for (int i = 1; i < n; ++i)
	{
		int u, v;
		gii(u, v);
		edge[u].pb(v);
		edge[v].pb(u);
	}
	dfs(1, 0);
	fac[0] = 1;
	for (int i = 1; i <= n; ++i) fac[i] = 1LL * fac[i - 1] * i % mod;
	ifac[n] = fpow(fac[n], mod - 2);
	for (int i = n; i; --i) ifac[i - 1] = 1LL * ifac[i] * i % mod;
	static int f[N], g[N];
	for (int i = 0; i <= n; ++i) g[i] = ifac[n - i];
	for (int i = 0; i <= n; ++i) f[i] = 1LL * cnt[i] * fac[i] % mod;
	int m = 1;
	for (; m <= (n << 1); m <<= 1);
	dft(f, m, 1), dft(g, m, 1);
	for (int i = 0; i < m; ++i) f[i] = 1LL * f[i] * g[i] % mod;
	dft(f, m, -1);
	for (int k = 1; k <= n; ++k)
	{
		int ans = n;
		ans = 1LL * ans * C(n, k) % mod;
		ans = (ans - 1LL * ifac[k] * f[n + k]) % mod;
		if (ans < 0) ans += mod;
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 61312
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int [] ary = new int[5];
    int min = 130;
    int mini = 16;
    for(int i=0; i<5; ++i) {
      ary[i] = sc.nextInt();
      if(ary[i]%10<min & ary[i]%10 !=0) {
        min=ary[i]%10;
        mini = i;
      }
    }
    if(mini!=16) {
      int w = ary[4];
      ary[4] = ary[mini];
      ary[mini] = w;
    }

    int ans =0;
    for(int i=0; i<5; ++i) {
      ans += ary[i];
      if(i<4 & ans % 10 != 0) {
        ans = (ans+10)/10 * 10;
      }
    }
      System.out.println(ans);
  }
}

Measured memory_bytes: 23252
#include <iostream>
using namespace std;
const int maxn = 1e5 + 10;
int       ans[maxn];
int main()
{
    string s; int mid = 0;
    cin >> s;
    for (int i = s.size() - 1; i >= 0; i--)
    {
        if (s[i] == 'R')
        {
            ans[i + 1] += (mid + 1) / 2;
            ans[i]     += mid / 2;
            mid         = 0;
        }
        else
            mid++;
    }
    mid = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'L')
        {
            ans[i - 1] += (mid + 1) / 2;
            ans[i]     += mid / 2;
            mid         = 0;
        }
        else
            mid++;
    }
    for (int i = 0; i < s.size(); i++)
        cout << ans[i] << " ";
    return 0;
}


Measured memory_bytes: 1024
N = int(input())
X = list(map(int, input().split()))
A = range(min(X), max(X)+1, 1)

ans = set()
for p in A:
    HP = 0
    for j in range(N):
        HP += (X[j] - p) ** 2
    ans.add(HP)

print(min(ans))

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

int main() {
    int height[11];
    int temp;
    for (int i = 0; i < 10; i++) {
        cin >> height[i];
    }
    for (int i = 0; i < sizeof(height - 2); i++) {
        for (int j = i+1; j < 10; j++) {
            if (height[i] < height[j]) {
                swap(height[i], height[j]);
            }
        }
    }
    for (int i = 0; i < 3; i++) {
        cout << height[i] << endl;
    }
}


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

/*
	<http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_G>
	Combinatorial - Knapsack Problem with Limitations

	References: programming contests challenge book <p.302>
*/

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	long long N, W; cin >> N >> W;
	vector<long long> v(N), w(N), m(N);
	for (int i = 0; i < N;i++) {
		cin >> v[i] >> w[i] >> m[i];
	}
	/* solve1	*/
	vector<long long> dp(W + 1, 0);
					 // deq: index    deqv : value
	vector<long long> deq(W + 1, 0), deqv(W + 1, 0);
	for (int i = 0; i < N;i++) {
		for (int a = 0; a < w[i]; a++) {
			int s = 0, t = 0;	// start and end of deq
			for (int j = 0; j * w[i] + a <= W; j++) {
				// push j into deq[t]
				int val = dp[j * w[i] + a] - j*v[i];
				while (s < t && deqv[t - 1] <= val) t--;
				deq[t] = j;
				deqv[t++] = val;
				// pop top from deq[s]
				dp[j * w[i] + a] = deqv[s] + j * v[i];
				if (deq[s] == j - m[i]) {
					s++;
				}
			}
		}
	}
	/*	solve2	*/
	/*
	vector<long long> dp(W + 1, 0);
	for (int i = 0; i < N; i++) {
		int num = m[i];
		for (int k = 1; num > 0; k <<= 1) {
			int mul = min(k, num);
			for (int j = W; j >= w[i] * mul; j--) {
				dp[j] = max(dp[j], dp[j - w[i] * mul] + v[i] * mul);
			}
			num -= mul;
		}
	}
	*/
	cout << dp[W] << endl;
}

Measured memory_bytes: 3256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
int dp[3001][6001];
typedef pair<int, int> P;
P p[3000];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int N, T;
    cin >> N >> T;
    int A[3000], B[3000];
    for(int i = 0; i < N; i++){
        cin >> A[i] >> B[i];
        p[i] = P(A[i], B[i]);
    }
    sort(p, p+N);
    for(int i = 0; i < N; i++){
        A[i] = p[i].first;
        B[i] = p[i].second;
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j <= 6000; j++){
            dp[i+1][j] = dp[i][j];
        }
        for(int j = 0; j < T; j++){
            dp[i+1][j+A[i]] = max(dp[i+1][j+A[i]], dp[i][j]+B[i]);
        }
    }
    int ans = 0;
     for(int j = 0; j <= 6000; j++){
        ans = max(ans, dp[N][j]);
    }
    cout << ans << endl;
}

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

int main() {

  // レストランの数
  int N;
  cin >> N;
  
  vector<tuple<string, int, int>> t(N);
  
  for (int i=0; i<N; i++) {
    cin >> get<0>(t.at(i)) >> get<1>(t.at(i));
    get<1>(t.at(i)) *= -1;
    get<2>(t.at(i)) = i+1;
  }
  
  sort(t.begin(), t.end());
  
  for (int j=0; j<N; j++) {
    cout << get<2>(t.at(j)) << endl;
  }  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define MP make_pair
#define F first
#define S second
#define inf 10000000000000
#define vll vector<ll>
using namespace std;
const int N=200005;

void solve()
{
	ll a,b;
	cin>>a>>b;
	a=a*3+b;
	cout<<a/2;
}
 
int main() {
    
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
 
    
    return 0;
}

Measured memory_bytes: 256
x = int(input())
a = [i ** 5 for i in range(120)]

for i in range(120):
    for j in range(i + 1, 120):
        if a[j] - a[i] == x:
            print(j, i)
            break
        elif a[j] + a[i] == x:
            print(j, -i)
            break

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

using namespace std;

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

  int A, B;
  cin >> A >> B;

  int ans = 0;
  int outlet = 1;
  while (outlet < B) {
    outlet += A - 1;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//↑templete
int main() {
	int N;
	cin>>N;
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++){
			if(i*j==N){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false ll_MAX ll_MIN insert erase clear pop push compare ll64_MAX ll64_MIN  reverse replace stringstream string::npos length substr front priority_queue

#ifndef ONLINE_JUDGE
#include "debug.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define debug(...) 42
#endif

#define endl '\n'
#define ll long long
#define rint register int
#define minpq priority_queue <int, vector<int>, greater<int> >
#define maxpq  priority_queue <int>

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX

#define conutBits(n)	__builtin_popcount(n)
#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

int32_t main() {
	ios::sync_with_stdio(0); 		cin.tie(0); cout.tie(0);

	ll t, i, x, j, y, 	z, k, n;
	tc(tt) {
		cout << "ACL";
	}
}



Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define pb       push_back
#define mp       make_pair
//#define mod      10000007
#define pi       acos(-1.0)
#define test     int t; cin>>t ;while(t--)
typedef long long ll;
using namespace std;
ll bigmod(ll a,ll b,ll mod)
{
 
    ll  res=1;
    a=a%mod;
    if(a==0)
       return 0;
    while(b>0)
    {
 
           if(b%2)
            res=(res*a)%mod;
 
            b=b/2;;
            a=(a*a)%mod;
 
 
    }
   return res;
 
}
int main()
{      


     ios::sync_with_stdio(false);
     cin.tie(NULL);
     
    string s="ACL";
     int n;
     cin>>n;
     for(int i=0;i<n;i++)
      cout<<s;
    
   
      return 0;
    
 } 

Measured memory_bytes: 3580
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (size_t i = 0; i < (n); i++)
#define nvec(T, v, n) vector<T> v(n); REP(i, n) {cin>>(v)[i];}
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(i, n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(i, n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}

#define min_index(v) size_t( min_element(all(v)) - (v).begin() )
#define max_index(v) size_t( max_element(all(v)) - (v).begin() )
#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))

#define count_le(v, a) size_t( upper_bound(ALL(v), a) - (v).begin() )
#define count_lt(v, a) size_t( lower_bound(ALL(v), a) - (v).begin() )
#define count_ge(v, a) size_t( (v).end() - lower_bound(ALL(v), a) )
#define count_gt(v, a) size_t( (v).end() - upper_bound(ALL(v), a) )

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))

#define GCD(v) gcd(ALL(v), 0l)

/*template <typename T>
T gcd(T a, T b) {
    if (a > b) swap(a, b);
    if (a == 0) return b;
    return gcd(b%a, a);
}
template <typename InputItr, typename T>
T gcd(InputItr first, InputItr last, T init) {
    for (; first != last; ++first) init = gcd(init, *first);
    return init;
}*/

template <typename T>
using vec = vector<T>;

template <typename T>
using vvec = vector<vector<T>>;

int main(){
  int n;
  cin>>n;
  nvec(int,l,n);
  SORT(l);
  int cnt=0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      for (int k = 0; k < j; k++) {
        if(l[i]>l[j]&&l[j]>l[k]&&l[i]<l[j]+l[k]) cnt++;
      }
    }
  }
  cout<<cnt;
}


/* きょむ〜 */


Measured memory_bytes: 3600
import scala.io.StdIn

object Main extends App {

  val n = StdIn.readLine().toInt
  val r = (0 until n).foldLeft(0) { (acc, _) =>
    val a = StdIn.readLine().split(' ').map(_.toInt)
    acc + (a(1) - a(0)) + 1
  }
  println(r)

}


Measured memory_bytes: 28216
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main(){
    int n;
    cin >> n;
    vector<int> nums;
    for(int j = 1; j <= 30000; j++){
        if(j % 2 == 0 || j % 3 == 0 || j % 5 == 0){
            nums.push_back(j);
        }
    }
    while(1){
        // try
        random_shuffle(nums.begin(), nums.end());
        int g = 0;
        int sum = 0;
        for(int j = 0; j < n; j++){
            g = __gcd(g, nums[j]);
            sum += nums[j];
        }
        if(sum % 30 != 0) continue;
        if(g != 1) continue;
        for(int j = 0; j < n; j++){
            cout << nums[j] << " ";
        }
        cout << endl;
        break;
    }
}


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

int main()
{
	int a[3] = { 0 };
	cin >> a[0] >> a[1] >> a[2];
	for (int i = 0; i < 2; i++){
		for (int j = 2; j > 0;j--){
			if (a[i] > a[j]){
				int tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}
	cout << a[0] << " " << a[1] << " " << a[2] << endl;
	return 0;
}

Measured memory_bytes: 1164
fn bfs(adjl: &Vec<Vec<usize>>, v: usize) {}

fn main() {
    let (n, m): (usize, usize) = (read::<usize>(), read::<usize>());
    let mut adjl = vec![vec![]; n];
    for _ in 0..m {
        let (u, v): (usize, usize) = (read::<usize>() - 1, read::<usize>() - 1);
        adjl[u].push(v);
        adjl[v].push(u);
    }
    const INF: usize = std::usize::MAX - 10;
    let mut dir = vec![INF; n];
    let mut que: VecDeque<(usize, usize)> = VecDeque::new();
    que.push_back((0, 0));
    while let Some((c, f)) = que.pop_front() {
        if dir[c] != INF {
            continue;
        } else {
            dir[c] = f;
            for &n in &adjl[c] {
                if n != f {
                    que.push_back((n, c));
                }
            }
        }
    }
    println!("{}", "Yes");
    for di in dir.iter().skip(1) {
        println!("{}", di + 1);
    }
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::process::exit;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 14884
/**
 * 
 */
import java.util.*;
/**
 * @author afterCmidday
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		while(scan.hasNextDouble()){
			double a = scan.nextDouble(), ans = a;
			for(int i = 0;i < 4;i++){
				a *= 2;
				ans += a;
				a /= 3;
				ans += a;
			}
			a *= 2;
			ans += a;
			System.out.println("" + ans);
		}
		
	}

}

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

int m, n, num;
int arr[100500];

int main()
{
    int a, b, c;
    scanf("%d %d", &n, &m);
    c = m;
    while(c--)
    {
        scanf("%d %d", &a, &b);
        arr[a]++;
        arr[b + 1]--;
    }
    for(int i = 1; i <= n; i++)
    {
        arr[i] = arr[i] + arr[i - 1];
        if(arr[i] == m)
        {
            num++;
        }
    }
    printf("%d\n", num);
    return 0;
}


Measured memory_bytes: 640
# -*- coding:utf-8 -*-
import math
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    factorA = []
    factorB = []
    for index in range(n):
        if a[index] > b[index]:
            factorB.append(a[index]-b[index])
        elif a[index] < b[index]:
            factorA.append((b[index]-a[index])//2)
        else:
            pass
    else:
        if sum(factorA) >= sum(factorB):
            print("Yes")
        else:
            print("No")

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

//N:1,W:2,E:3,S:4
void RotateDice(int* a,int n)
{
    int c = a[0];
    a[0] = a[n];
    a[n] = a[5];
    a[5] = a[5 - n];
    a[5 - n] = c;
}
int main()
{
    int a[6], q, top, front;
    for (int i = 0; i < 6; i++)
    {
        cin >> a[i];
    }

    cin >> q;
    for (int i = 0; i < q; i++)
    {
        cin >> top >> front;
        for (int j = 0; j < 4;j++)
        {
            if(a[1] == front)
            {
                break;
            }
            RotateDice(a, 1);
        }

        if (a[1] != front)
        {
            RotateDice(a, 3);
            for (int j = 0; j < 4; j++)
            {
                if(a[1] == front)
                {
                    break;
                }
                RotateDice(a, 1);
            }
        }

        for (int j = 0; j < 4; j++)
        {
            if (a[0] == top)
            {
                break;
            }
            RotateDice(a, 3);
        }
        cout << a[2] << endl;
    }
    
    return 0;
}



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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1e9+7;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
    int K, l;
    string S;
    cin >> K >> S;
	l = (int)(S.length());
    
  	combination c(K+l);
    mint ans = 0;
    for(int i=0; i<=K; i++){
        ans +=  mint(25).pow(i) * c(i+l-1, l-1) * mint(26).pow(K-i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 35524
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll n;
cin>>n;
vector<ll>v;
unordered_map<ll,ll>mp;
for(ll i=0;i<n;i++)
{
    ll a;
    cin>>a;
    v.pb(a);
    mp[a]++;
}
ll ans=0;
for(auto it:mp)
{
    ll x=(it).fi;
    ll cnt=(it).se;
    ans+=(cnt*(cnt-1))/2;
}
for(ll i=0;i<n;i++)
{
    ll temp=ans;
    ll cnt=mp[v[i]];
    temp=ans-((cnt*(cnt-1))/2);
    temp+=((cnt-1)*(cnt-2))/2;
    cout<<temp<<endl;
}
return 0;
}


Measured memory_bytes: 9404