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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;


ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    (a *= a) %= MOD;
    n >>= 1;
  }
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  vll a(n), s(n+1);
  rep(i,n){
    cin>>a[i];
    s[i+1]=s[i]+a[i]%MOD;
  }
  
  // cout<<s[n]<<endl;
  
  ll ans=0;
  rep(i,n){
    (ans+=(s[n]-s[i+1]+MOD)%MOD*a[i]%MOD)%=MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 6316
#include <iostream>

using namespace std;

int main(){
	int A, B, N; cin>>N>>A>>B;
	bool w = false;
	while(!w){
		if(B!=A+1){
			A++;
		} else {
			if(A==1){
				cout << "Borys" << endl;
				w = true;
				break;
			} else {
				A--;
			}
		}
		if(A!=B-1){
			B--;
		} else {
			if(B==N){
				cout << "Alice" << endl;
				break;
			} else {
				B++;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
const COST: [usize; 10] = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6];

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let m: usize = sc.read();
    let a: Vec<usize> = sc.vec(m);
    let mut dp = vec![String::new(); n + 1];
    for i in 0..n {
        if dp[i].is_empty() && i > 0 {
            continue;
        }
        for &a in a.iter() {
            let cost = COST[a];
            if i + cost > n {
                continue;
            }
            let next_cost = i + cost;
            let mut next = dp[i].clone();
            next.push((a as u8 + '0' as u8) as char);
            if next.len() > dp[next_cost].len()
                || (next.len() == dp[next_cost].len() && next > dp[next_cost])
            {
                dp[next_cost] = next;
            }
        }
    }

    println!("{}", dp[n]);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 59644
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    i64 x;
    std::cin >> n >> x;
    std::vector<i64> a(n);
    for (auto &e : a) std::cin >> e;

    i64 ret = 0;
    for (int i = 1; i < n; i++) {
        const i64 s = a[i - 1] + a[i];
        if (s <= x) continue;
        const i64 d = s - x;
        ret += d;
        a[i] = std::max(0ll, a[i] - d);
    }

    std::cout << ret << std::endl;

    return 0;
}


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

using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rInt(a) scanf("%d",&a);

main(){
    int n;
    int posx = 0, posy = 0, tim = 0;
    scanf("%d",&n);
    int t,x,y;
    while(n--){
        scanf("%d %d %d",&t,&x,&y);
        int diff = abs(posx-x);
        diff+= abs(posy-y);
        int val = t - tim;
        if(diff>val){
            cout << "No" << endl;
            return 0;
        }else{
            if(val>diff){
                int temp = val-diff;
                if(temp%2==1){cout << endl << "No" << endl; return 0;}
            }
            posx = x; posy = y; tim = t;
        }
    }
    cout << "Yes" << endl;
}

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

using namespace std;

#define all(x) (x).begin(), (x).end()
typedef long double ld;
typedef long long ll;


int main() {
#ifdef LOCAL
  assert(freopen("b.in", "r", stdin));
#endif

  ios_base::sync_with_stdio(false);

  int n;
  map<int, int> cnt;
  vector<int> a;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    cnt[x]++;
    a.push_back(x);
  }

  sort(all(a), greater<int>());

  int pw = (1 << 30);
  int ans = 0;

  for (int x : a) {
    while (pw - x > x) {
      pw >>= 1;
    }
    if (pw - x == x) {
      int bon = cnt[x] / 2;
      cnt[x] -= 2 * bon;
      ans += bon;
    } else {
      int bon = min(cnt[x], cnt[pw - x]);
      cnt[x] -= bon;
      cnt[pw - x] -= bon;
      ans += bon;
    }
  }

  cout << ans << "\n";

}



Measured memory_bytes: 19828
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int main(){
  //解説見ました
  string s,t;
  cin >> s >>t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end(),greater<char>());
  if(s<t){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const int N_MAX = 2010;
int N,x,y;
int v[N_MAX];
bool checked[N_MAX];
PII dp[N_MAX];

//first:最小値,second:最大値
PII dfs(int cur){
  if(checked[cur]) return dp[cur];
  PII ret = PII(MAX_I,MIN_I);
  int z = cur>0 ? v[cur-1]:y;
  repp(i,cur,N-1){
    PII r = dfs(i+1);
    ret.first = min(ret.first,r.second);
    ret.second = max(ret.second,r.first);
  }
  ret.first = min(ret.first, abs(z-v[N-1]));
  ret.second = max(ret.second, abs(z-v[N-1]));
  checked[cur] = true;
  return dp[cur] = ret;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cin >> N >> x >> y;
  rep(i,N)cin >> v[i];
  PII r = dfs(0);
  cout << r.second << endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int ar[1000006];
class compatible
{
public:
    int n1, n2, n3, n4;
};
bool checkbracket(string s)
{
    int i;
    stack<char> st;
    st.push(s[0]);
    for(i=1;s[i];i++){
        if(s[i] == ')'){
            if(st.empty())return false;
            if(st.top() == '(')st.pop();
            else return false;
        }
        if(s[i] == '(')
            st.push(s[i]);
    }
    return st.size() == 0;
}

int sumofn(int n)
{
    return n * (n+1) / 2;
}

int main()
{
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    int ar[1005];
    for(int i=1;i<=999;i++){
        ar[i] = sumofn(i);
    }

    for(int i=1;i<=998;i++){
        if(ar[i+1] - ar[i] == b - a){
            cout << ar[i] - a << "\n";
            return 0;
        }
    }


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  	int N;
  	cin >> N;
  	int w[N];
  	int sum = 0;
  	int sbsum[N];
  	for(int i=0;i<N;i++){
  		cin >> w[i];
  		sum += w[i];
  		sbsum[i] = sum;
  	}

  	int ans = 100000;
  	for(int i=0;i<N-1;i++){
  		ans = min(ans, abs(sum- 2*sbsum[i]));
  	}
  	cout << ans <<endl;
    
  	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define pi acos(-1)
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

void solve()
{

    lli n;
    cin>>n;
    vector<pair<lli, lli> > v;
    for(int i = 0; i < n; i ++) {
        lli a, b;
        cin>>a>>b;
        v.push_back({b, a});
    }
    sort(v.begin(), v.end());

    lli l = 0;
    bool ok = 1;

    for(int i = 0; i < n; i ++) {
        lli a = v[i].ss;
        lli b = v[i].ff;
        l += a;
        if(l <= b) {
            ;
        }
        else {
            ok = 0;
        }
    }

    if(ok)
        cout<<"Yes";
    else
        cout<<"No";

    cout<<"\n";
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 6640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main(void){
    int n;
    cin >> n;
    n %= 10;

    if(n==7 || n==9 || n == 2 || n==4||n==5) cout << "hon" << endl;
    else if(n==0||n==1||n==6||n==8) cout << "pon" << endl;
    else cout << "bon" << endl;
    return 0;
}

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

int main() {
    size_t N;
    cin >> N;
    vector<int> A(N);
    for (int &Ai : A) cin >> Ai;

    while (true) {
        sort(A.begin(), A.end());
        A.erase(unique(A.begin(), A.end()), A.end());

        if (A.size() == 1uL) {
            cout << A.at(0) << '\n';
            return 0;
        }

        for (size_t i = 1uL; i < A.size(); ++i) {
            A.at(i) %= A.at(0);
            if (A.at(i) == 0) {
                A.erase(A.begin() + i);
                --i;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3736
import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;

immutable long mod = 10^^9 + 7;

void main(){
    auto col = new int[](8);

    int n = readln.chomp.to!int;
    auto a = readln.split.to!(int[]);

    int over = 0;

    foreach(ai ; a){
        if(ai >= 3200){
            over += 1;
        }
        else {
            col[ai / 400] = 1;
        }
    }

    auto mina = sum(col);

    if (mina == 0){
        mina = 1;
    }
    auto maxa = sum(col) + over;

    writeln(mina, " ", maxa);
}


void readVars(T...)(auto ref T args){
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        throw new Exception("args num < input num");
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ABC148B
    {
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var N = NN;
            var S = NS;
            var T = NS;
            var ary = new List<char>();
            for (var i = 0; i < N; i++)
            {
                ary.Add(S[i]);
                ary.Add(T[i]);
            }
            Console.WriteLine(new string(ary.ToArray()));
        }
        static class Console_
        {
            static Queue<string> param = new Queue<string>();
            public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }
        static long NN => long.Parse(Console_.NextString());
        static double ND => double.Parse(Console_.NextString());
        static string NS => Console_.NextString();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
    }
}
namespace Library {
}


Measured memory_bytes: 12768
#include <string>
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>

using namespace std;
typedef long long ll;

int main(int argc, char const *argv[])
{
    int A,B;
    cin >> A >> B;
    cout << A*B;
    
    

    return 0;
}


Measured memory_bytes: 3620
n=gets.to_i
pi=gets.split.map(&:to_f)

arr = (0..n).map{|i|[0]*(i+1)}
arr[0][0]=1

pi.each.with_index{|pii,i|
  arii = arr[i+1]
  rpii = 1-pii
  arr[i].each.with_index{|ai,j|
    arii[j] += ai * rpii
    arii[j+1] += ai * pii
  }
}
p arr[n][-n/2..-1].inject(:+)

Measured memory_bytes: 157308
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,x=0,y=0;
  cin >> N;
  string s;
  cin >> s;
  for(int i=0; i<N; i++){
    if(s[i] == 'I'){
      x++; 
      if(x>y){
        y = x;
      }
    }
    else{
      x--;
    }
  }
  cout << y <<  endl;
}


Measured memory_bytes: 3600
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

// AOJ 0000
public class Main {

	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		for (int i = 1; i <= 9; i++) {
			for (int j = 1; j <= 9; j++) {
				System.out.println(i + "x" + j + "=" + j * i);
			}
		}
	}
}

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

typedef unsigned uint;
typedef long long INT;
typedef unsigned long long UINT;
const int INF = 1001001001;
const INT INFLL = 1001001001001001001LL;

 int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
INT lin() { INT x; scanf("%lld", &x); return x; }
UINT luin() { UINT x; scanf("%llu", &x); return x;}


int main(){
    int a, b, c;
    double fa, fb, fc;
    char S[128], sa[128], sb[128], sc[128];
    // int N = in();
    // int K = in();
    // scanf("%s", S);

    int K = in();
    scanf("%s", S);

    // std::vector<INT> vecA;
    // for (INT i = 0; i < N; ++i) {
    //     vecA.push_back(lin());
    // }

    int i = 0;
    while(1) {
        if (S[i] == '\0'){
            break;
        }

        if (i >= K) {
            printf("...");
            break;
        }

    printf("%c", S[i]);
    ++i;
    }
 


    return 0;
}







Measured memory_bytes: 3764
// In the name of god
#include <bits/stdc++.h>
using namespace std;
 string s;
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin>>s;
	if(s[0]=='7'||s[1]=='7'||s[2]=='7'){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
}


Measured memory_bytes: 3616
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  string a;
  cin >> a;
  ll n = a.size();

  vector<ll> cnts(26);
  rep(i, n) {
    ++cnts[a[i]-'a'];
  }
  ll ans = n * (n-1)/2 + 1;

  rep(i, 26) {
    ans -= cnts[i] * (cnts[i]-1)/2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin>>n;
  ll lb=0,rb=50001;
  while(rb-lb>1){
    ll mid=(lb+rb)/2;
    if((ll)(mid*1.08)<=n) lb=mid;
    else rb=mid;
  }
  if((ll)(lb*1.08)==n) cout<<lb<<endl;
  else cout<<":("<<endl;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    s = S()
    t = S()
    ans = 0
    for i in range(len(s)):
        if s[i] == t[i]:
            ans += 1
    print(ans)
    return

#B
def B():
    a,b = LI()
    for i in range(10000):
        if 1+i*a-i >= b:
            print(i)
            return
    return

#C
def C():
    n = I()
    a = LI()
    ans = 0
    r = 1
    for l in range(n):
        if r == l:
            r += 1
        while r < n and a[r-1] >= a[r]:
            r += 1
        ans = max(ans, r-l-1)
    print(ans)
    return

#D
def D():
    n = I()
    print(n*(n-1)>>1)
    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    D()


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

inline void fin(bool w) { printf("%s\n", w ? "Yes" : "No"), exit(0); }

int fr[100000];

int main(){
	int n;
	scanf("%d", &n);
	int mn = 1e9, mx = -1;
	f(i, 0, n){
		int t;
		scanf("%d", &t);
		++fr[t];
		mn = min(mn, t);
		mx = max(mx, t);
	}
	if (mx - mn > 1)fin(false);
	if (mx == mn){
		if (mx == n - 1)fin(true);
		if (n / mx <= 1)fin(false);
		fin(true);
	}
	int un = fr[mn];
	int al = mx;
	int lft = al - un;
	int z = fr[mx];
	if (lft <= 0 || z / lft <= 1)fin(false);
	fin(true);
}

Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
using namespace std;
typedef vector<int> vi;
const int inf=1e9;
int w,h;
int ldx[]={-1,0,1,0};
int ldy[]={0,1,0,-1};
int rdx[]={1,0,-1,0};
int rdy[]={0,1,0,-1};
bool vis[55][55][55][55];
string rin[55];
string len[55];
bool treasure;
int rinsx,rinsy,ringx,ringy,lensx,lensy,lengx,lengy;
struct P
{
  int ly,lx,ry,rx;
  P(int ly,int lx,int ry,int rx):ly(ly),lx(lx),ry(ry),rx(rx){};
};
void bfs(int lx,int ly,int rx,int ry)
{
  vis[ly][lx][ry][rx]=true;
  // lenvis[ly][lx]=true;
  //rinvis[ry][rx]=true;
  queue<P> q;
  q.push(P(ly,lx,ry,rx));
  while(!q.empty())
    {
      P now=q.front();q.pop();
      int lennx,lenny,rinnx,rinny;
      bool lengoal=false;
      bool ringoal=false;
      for(int k=0;k<4;k++)
	{
	  lennx=now.lx+ldx[k];
	  lenny=now.ly+ldy[k];
	  rinnx=now.rx+rdx[k];
	  rinny=now.ry+rdy[k];
	  if(lennx>=w || lennx<0 || lenny>=h || lenny<0 || len[lenny][lennx]=='#')
	    {
	      lennx=now.lx;
	      lenny=now.ly;
	    }
	  if(rinnx>=w || rinnx<0 || rinny>=h || rinny<0 || rin[rinny][rinnx]=='#')
	    {
	      rinnx=now.rx;
	      rinny=now.ry;
	    }
	  if(vis[lenny][lennx][rinny][rinnx])continue;
	  if(len[lenny][lennx]=='%') lengoal=true;
	  else lengoal=false;
	  if(rin[rinny][rinnx]=='%') ringoal=true;
	  else ringoal=false;
	  if(lengoal && ringoal)
	    {
	      treasure=true;
	      return;
	    }
	  if((lengoal ||ringoal) && !(lengoal && ringoal)) continue;
	  q.push(P(lenny,lennx,rinny,rinnx));
	  vis[lenny][lennx][rinny][rinnx]=true;
	}
    }
}

int main()
{
  while(cin >> w >> h && w)
    {
      treasure=false;
      memset(vis,false,sizeof(vis));
      //memset(lenvis,false,sizeof(lenvis));
      //memset(rinvis,false,sizeof(rinvis));
      for(int i=0;i<h;i++)
	{
	  cin >> len[i] >> rin[i];
	}
      for(int i=0;i<h;i++)
	{
	  for(int j=0;j<w;j++)
	    {
	      if(len[i][j]=='L')
		{
		  lensy=i;
		  lensx=j;
		}
	      if(rin[i][j]=='R')
		{
		  rinsy=i;
		  rinsx=j;
		}
	    }
	}
      bfs(lensx,lensy,rinsx,rinsy);
      if(treasure)
	{
	  cout << "Yes" << endl;
	}
      else
	{
	  cout << "No" << endl;
	}
    }
}



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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

const int INF = 1001001001;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

void solve() {
  int a, b;
  cin >> a >> b;
  cout << a * b << endl;
}


Measured memory_bytes: 3656
inf = float('inf')

N, K = list(map(int, input().split()))
v = list(map(int, input().split()))

volume = max(N, K)
take_max = min(N, K)

dpl = [[-inf] * (volume + 1) for _ in range(N + 1)]
dpr = [[-inf] * (volume + 1) for _ in range(N + 1)]
dpl[0][0] = dpr[0][0] = 0

for i, vv in enumerate(v, 1):
    for take in range(i + 1):
        dpl[i][take] = dpl[i - 1][take]
        if take > 0:
            dpl[i][take] = max(dpl[i][take], dpl[i - 1][take - 1] + vv)

for i, vv in enumerate(reversed(v), 1):
    for take in range(i + 1):
        dpr[i][take] = max(dpr[i][take], dpr[i - 1][take])
        if take > 0:
            dpr[i][take] = max(dpr[i][take], dpr[i - 1][take - 1] + vv)

ans = 0
for take_frm_left in range(take_max + 1):
    for take_frm_right in range(take_max + 1):
        if take_frm_left + take_frm_right > take_max: break
        for use_frm_left in range(take_frm_left + 1):
            remove_frm_left = take_frm_left - use_frm_left
            vl = dpl[take_frm_left][use_frm_left]
            for use_frm_right in range(take_frm_right + 1):
                remove_frm_right = take_frm_right - use_frm_right
                if (take_frm_left + take_frm_right + remove_frm_left + remove_frm_right) > K: continue
                vr = dpr[take_frm_right][use_frm_right]
                # print(vl + vr, take_frm_left, use_frm_left, take_frm_right, use_frm_right)
                ans = max(ans, vl + vr)
print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <algorithm> //next_permutation

using namespace std;
typedef long long ll;
//typedef pair<int, int> P;

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


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

using namespace std;

long long cube(long long x) {
  return x * x * x;
}

int main() {
  long long n, K;
  cin >> n >> K;
  if (K % 2 == 0) {
    cout << cube(n / K) + cube((n + K / 2) / K) << endl;
  } else {
    cout << cube(n / K) << endl;
  }
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static class State {
		int a;
		int b;
		int c;

		public State(int a, int b, int c) {
			super();
			this.a = a;
			this.b = b;
			this.c = c;
		}

	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		State init = new State(a, b, c);
		
		String[] s = new String[n];
		for (int i = 0; i < n; i++) {
			s[i] = sc.next();
		}
		
		List<String> result = new ArrayList<>();  
		dfs( result, s, 0,n, init );
		
		if( result.size()== n ) {
			System.out.println("Yes");
			for (int i = result.size() -1; i >=0; i--) {
				System.out.println(result.get(i));
			}
		}else {
			System.out.println("No");
			
		}

	}

	private static boolean dfs(List<String> result, String[] s, int i, int n, State init) {
		if( i==n )return true;
		
		boolean noob = false;;
		switch (s[i]) {
		case "AB":
			noob = tryQueue(result,s, i, n, init,1,-1,0 , "A") ||
			tryQueue(result,s, i, n, init,-1,1,0 , "B");
			break;
		case "AC":
			noob = 
			tryQueue(result,s, i, n, init,1,0,-1 , "A") ||  
			tryQueue(result,s, i, n, init,-1,0,1 , "C");
			break;
		case "BC":
			noob = 
			tryQueue(result,s, i, n, init,0,1,-1 , "B") ||
			tryQueue(result,s, i, n, init,0,-1,1 , "C");
			break;
		default:
			break;
		}	
		return noob;
	}

	private static boolean tryQueue(List<String> result, String[] s, int level, int n,  State init, int i, int j, int k, String dir) {
		int a = init.a + i;
		int b = init.b + j;
		int c = init.c + k;

		if (a < 0 || b < 0 || c < 0)
			return false;
		State e = new State( a, b, c);
		if( dfs(result, s, level+1, n, e) ) {
			result.add(dir);
			return true;
		};
		
		return false;
	}

}


Measured memory_bytes: 91412
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N = INT()
    maxv = 0
    maxv2 = 0
    A = [INT() for i in range(N)]
    A_ = sorted(A, reverse = True)
    maxv = A_[0]
    maxv2 = A_[1]
    for i in range(N):
        if A[i] == maxv:
            print(maxv2)
        else:
            print(maxv)

if __name__ == '__main__':
    main()


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

int main()
{
        vector<double> ans;

        while (1) {
                int n;
                cin >> n;
                if (n == 0) break;
                int s[n];
                double sum = 0;
                for (int i = 0; i < n; ++i) {
                        cin >> s[i];
                        sum += s[i];
                }
                double av = sum / n;
                double tmp = 0;
                for (int i = 0; i < n; ++i) {
                        tmp += ((s[i] - av) * (s[i] - av));
                }
                tmp /= n;
                ans.push_back(sqrt(tmp));
        }

        for (int i = 0; i < ans.size(); ++i) {
                printf("%.8lf\n", ans[i]);
        }





}



Measured memory_bytes: 3292
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random,resource

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,k = LI()
    a = sorted(LI())

    r = 1
    i = n - 1
    j = 0
    if k % 2 == 1:
        r = a[i]
        i -= 1

    mf = r < 0

    for _ in range(k//2):
        t = a[i] * a[i-1]
        u = a[j] * a[j+1]
        if (not mf and t >= u) or (mf and t < u):
            r *= t
            r %= mod
            i -= 2
        else:
            r *= u
            r %= mod
            j += 2

    return r


print(main())




Measured memory_bytes: 33756
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;

int main()
{
	ll r,d,x;
	cin >> r >> d >>x;
	rep(i,10)
	{
		x = r*x - d;
		cout<<x<<endl;
	}
	
	return 0;
}

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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> cnt(M);

    for (int i = 0; i < N; i++)
    {
        int K;
        cin >> K;
        for (int j = 0; j < K; j++)
        {
            int A;
            cin >> A;
            A--;
            cnt[A]++;
        }
    }

    int ans = 0;
    for (int i = 0; i < M; i++)
    {
        if (cnt[i] == N)
        {
          ans += 1;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

typedef complex<double> Point;
typedef complex<int> Point_i;

struct Piece {
  double g;
  int weight;
  int minx, maxx;
  vector<Piece*> children;
};

double fill(vector<string> &v, int x, int y, char c, vector<Point_i> &has, vector<int> &under) {
  //cout << x << ' ' << y << ' ' << c << endl;
  const int dx[] = {1, -1, 0, 0};
  const int dy[] = {0, 0, 1, -1};

  if(x < 0 || v[0].size() <= x || y < 0 || v.size() <= y) return 0;
  if(v[y][x] != c) return 0;

  v[y][x] = '%';
  double g = x+0.5;

  for(int i = 0; i < 4; ++i) {
    g += fill(v, x+dx[i], y+dy[i], c, has, under);
  }

  if(y > 0 && v[y-1][x] != '.' && v[y-1][x] != '#' && v[y-1][x] != c) {
    has.push_back(Point_i(x, y-1));
  }
  if(y < v.size()-1 && v[y+1][x] == '#') {
    under.push_back(x);
  }
  v[y][x] = '%';
  return g;
}

Piece* getPiece(vector<string> &v, int x, int y) {
  //cout << x << ' ' << y << endl;
  char c = v[y][x];
  vector<Point_i> has;
  vector<int> under;
  double g = fill(v, x, y, c, has, under);
  Piece *p = new Piece;
  p->g = g/4;
  //cout << p->g << endl;
  p->weight = 4;
  for(int i = 0; i < v.size(); ++i) {
    for(int j = 0; j < v[0].size(); ++j) {
      if(v[i][j] == '%') v[i][j] = '#';
    }
  }
  for(int i = 0; i < has.size(); ++i) {
    char c = v[has[i].imag()][has[i].real()];
    if(c != '#' && c != '.') {
      Piece *c = getPiece(v, has[i].real(), has[i].imag());
      p->children.push_back(c);
    }
  }

  int minx = under[0];
  int maxx = under[0];
  for(int i = 0; i < under.size(); ++i) {
    minx = min(minx, under[i]);
    maxx = max(maxx, under[i]);
  }
  p->minx = minx;
  p->maxx = maxx+1;
  //cout << p->minx << ' ' << p->maxx << endl;
  return p;
}

bool stable(Piece *p) {
  for(int i = 0; i < p->children.size(); ++i) {
    if(!stable(p->children[i])) return false;
  }
  double w = 0, g = 0;
  int minx = p->minx, maxx = p->maxx;
  for(int i = 0; i < p->children.size(); ++i) {
    w += p->children[i]->weight;
    g += p->children[i]->g * p->children[i]->weight;
    //minx = min(p->children[i]->minx, minx);
    //maxx = max(p->children[i]->maxx, maxx);
  }
  w += p->weight;
  g += p->g * p->weight;

  g /= w;
  //cout << g << endl;

  p->g = g;
  p->weight = w;
  return (minx < p->g && p->g < maxx);
}


int main() {
  while(true) {
    int W, H;
    cin >> W >> H;
    if(!W && !H) break;

    vector<string> v;
    for(int i = 0; i < H; ++i) {
      string l;
      cin >> l;
      v.push_back(l);
    }
    string s;
    for(int i = 0; i < W; ++i) {
      s += '#';
    }
    v.push_back(s);
    Piece *root;
    for(int x = 0; x < W; ++x) {
      if(v[H-1][x] != '.') {
        root = getPiece(v, x, H-1);
        break;
      }
    }
    //root->minx = -1;
    //root->maxx = W+10;

    cout << (stable(root) ? "STABLE" : "UNSTABLE") << endl;
  }
  return 0;
}

Measured memory_bytes: 0
def main():
    n, m = map(int, input().split())
    Xs = sorted(list(map(int, input().split())))
    Xs_diff = []
    if n >= m:
        print(0)
        exit()

    for i in range(1, m):
        Xs_diff.append(Xs[i]-Xs[i-1])

    Xs_diff.sort()
    ans = sum(Xs_diff[:(m-n)])
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 20536
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n,ans=1<<30,a[10005];
int main(){
	in(n);
    for(int i=1;i<=n;i++)in(a[i]);
    for(int i=1;i<=100;i++){
        int sum=0;
        for(int j=1;j<=n;j++)sum+=(a[j]-i)*(a[j]-i);
        ans=min(ans,sum);
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import math

while True:
    Rzero, W, C, R = map(int, input().split())
    # 最初のルウRzero, 最初の水, 濃度Cのルウがベスト, 一個のルウが
    if Rzero == 0:
        break
    aim_status = W * C
    ans = math.ceil((aim_status-Rzero)/R)
    if ans < 0:
        ans = 0
    print(ans)



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

#define read(num) scanf("%d", &num)
#define readll(num) scanf("%lld", &num)
#define read2(num1, num2) scanf("%d%d", &num1, &num2)
#define read3(num1, num2, num3) scanf("%d%d%d", &num1, &num2, &num3)
#define reads(str) scanf("%s", str)
#define readc(ch) scanf("%c", &ch)

#define pb push_back
#define mp make_pair

#define pii pair<int, int>
#define vi vector<int>
#define ll long long

int need[2001][10];
vector<vector<int>>dp;

int main()
{
       ll s,w;
       cin>>s>>w;
       if(w>=s){
           cout<<"unsafe";
       }else {
           cout<<"safe";
       }
}

Measured memory_bytes: 3636
#include<stdio.h>

int main(){
	unsigned int a,b;
	int ad,or,xr,x[32] = {0},y[32] = {0},i;
	
	scanf("%d %d",&a,&b);
	
	
	for(i = 0; a>0; i++){
		x[i] = a % 2;
		a = a / 2;
	}
	
	for(i = 0; b>0; i++){
		y[i] = b % 2;
		b = b / 2;
	}
	
	for(i=31;i>=0;i--){
		if(x[i]==1&&y[i]==1)printf("1");
		else printf("0");
	}
	printf("\n");
	
	
	for(i=31;i>=0;i--){
		if(x[i]==1||y[i]==1)printf("1");
		else printf("0");
	}
	printf("\n");
	
	
	for(i=31;i>=0;i--){
		if(x[i]==1&&y[i]==0||x[i]==0&&y[i]==1)printf("1");
		else printf("0");
	}
	printf("\n");
	
    return 0;
}



Measured memory_bytes: 2056
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, L):
    L.sort()
    ans = 0
    for i in range(N-2):
        for j in range(i+1, N-1):
            for k in range(j+1, N):
                if L[i] != L[j] and L[j] != L[k] and L[i] != L[k] and L[i] + L[j] > L[k]:
                    ans += 1
    return ans


def main():
    N = read_int()
    L = read_int_n()
    print(slv(N, L))


if __name__ == '__main__':
    main()


Measured memory_bytes: 78484
package main

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

func printIntArray(values []int) {
	arraySize := len(values)
	strValues := make([]string, arraySize)
	for i, elm := range values {
		strValues[i] = strconv.Itoa(elm)
	}

	fmt.Printf("%v\n", strings.Join(strValues, " "))
}

func insertionSort(values []int) {
	for i := 1; i < len(values); i++ {
		v := values[i]
		j := i - 1
		for {
			if (j < 0) || (values[j] <= v) {
				break
			}

			values[j+1] = values[j]
			j--
		}
		values[j+1] = v
		printIntArray(values)
	}
}

func main() {
	var arraySize int
	fmt.Scan(&arraySize)
	// fmt.Println("arraySize", arraySize)

	values := make([]int, arraySize)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < arraySize; i++ {
		sc.Scan()
		s := sc.Text()
		// fmt.Println("scan", s)
		values[i], _ = strconv.Atoi(s)
	}

	printIntArray(values)
	insertionSort(values)

}



Measured memory_bytes: 1464
#include <atcoder/all>
#include <bits/stdc++.h>


using namespace std;


int main(int argc, char const *argv[])
{
    int N, M;
    scanf("%d%d", &N, &M);

    atcoder::dsu disjointSet(N);

    for (int i = 0; i < M; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        
        disjointSet.merge(u-1, v-1);
    }

    int ans = -1;
    for (int i = 0; i < N; ++i) {
        if (i == disjointSet.leader(i)) ans++;
    }

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


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

int main(void){
    int a,b;
    string s,t;
    cin >> a >> b;
    s = to_string(a);t = to_string(b);
    for(int i = 1;i < b;i++)s += to_string(a); 
    for(int i = 1;i < a;i++)t += to_string(b);
    if(s > t)cout << t;
    else cout << s;
}

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

int main()
{
    int a,b;
         cin>>a>>b;
         char arr[a][b];
         for(int i=0;i<a;i++)
         {
             for(int j=0;j<b;j++)
             cin>>arr[i][j];
         }
         for(int x=0;x<b+2;x++)
         cout<<"#";
         cout<<endl;
         for(int y=0;y<a;y++)
         {
             cout<<"#";
             for(int z=0;z<b;z++)
             cout<<arr[y][z];
             cout<<"#"<<endl;
         }
         for(int s=0;s<b+2;s++)
         cout<<"#";
         return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] a = new int[M];
        int[] b = new int[M];
        int[] num = new int[N+1];
        for(int i = 0;i < M;i++){
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
        for(int i = 0;i < M;i++){
            num[a[i]]++;
            num[b[i]]++;
        }
        for(int i = 1;i <= N;i++){
            System.out.println(num[i]);
        }
    }
}


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

int main(){
    string S;
    cin >> S;
    int count;
    count=0;
    for( int i=0; i<S.size()/2; i++ ){
        if( S[i]!=S[S.size()-1-i] ){
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#![allow(
  non_snake_case,
  unused_variables,
  unused_assignments,
  unused_mut,
  unused_imports,
  dead_code
)]
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
//use std::num;
//use petgraph::unionfind::UnionFind;
//use permutohedron::LexicalPermutation as _;

const MOD: i64 = 1000_000_007;
//#[fastout()]
fn main() {
  input! {
      N:usize,
  }
  // 10^N から、0を含まないものと9を含まないものをひき、0と9を含まないものを足す。
  let mut ans = 1;
  let mut x9 = 1;
  let mut x8 = 1;
  for i in 0..N{
    ans = ans * 10 % MOD;
    x9 = x9 * 9 % MOD;
    x8 = x8 * 8 % MOD;
  }
  ans = ans - x9 * 2 + x8 + (MOD*2);
  ans %= MOD;
  println!("{}", ans);
}


Measured memory_bytes: 2028
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            decimal iW = decimal.Parse(sS[0]);
            decimal iH = decimal.Parse(sS[1]);
            decimal iX = decimal.Parse(sS[2]);
            decimal iY = decimal.Parse(sS[3]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            decimal iOut = (iW * iH) / 2M;
            int iOu2 = 0;
            if (iW / 2 == iX && iH / 2 == iY) { iOu2 = 1; }

            // 出力
            System.Console.WriteLine("{0} {1}", iOut.ToString().Trim(), iOu2.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
n = gets.to_i
array = []
i = 1
n.times do
  a = gets.strip.split
  a[1] = a[1].to_i
  a.push(i)
  array << a
  i += 1
end

i = 0
array.sort_by!{|a,b,c|-b}
result = array.sort_by{|a,b,c| [a, i += 1]}


result.each do |ele|
  puts ele[2]
end

Measured memory_bytes: 1788