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

using namespace std;
using llong = long long int;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000007;
const static int IINF = INT_MAX;
const static llong LINF = LLONG_MAX;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

/* --------------- template start --------------- */
template <typename T> 
struct BinaryIndexTree { // [1, n]
    vector<T> array;
    int n;

    BinaryIndexTree(int _n) {
        array.resize(_n + 1, 0);
        n = _n;
    }

    T cumsum(int i) {
        T s = 0;
        while(i > 0) {
            s += array[i];
            i -= i & -i;
        }

        return s;
    }

    T sum(int i, int j) {
        T ret_i = cumsum(i - 1);
        T ret_j = cumsum(j);

        return ret_j - ret_i;
    }

    void add(int i, T x) {
        while (i <= n) {
            array[i] += x;
            i += i & -i;
        }
    }
};

template<typename T>
struct UnionFind {
    vector<int> par;
    vector<T> sz;

    UnionFind(int n) {
        par.resize(n);
        sz.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            sz[i] = 1;
        }
    }

    int find_root(int x) {
        return par[x] == x ? x : par[x] = find_root(par[x]);
    }

    bool same(int x, int y) {
        return find_root(x) == find_root(y);
    }

    void unite(int x, int y) {
        x = find_root(x);
        y = find_root(y);
        if (x == y) return;
        
        if (sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        par[y] = x;
    }

    T size_of_tree(int x) {
        return sz[find_root(x)];
    }
};
/* --------------- template end --------------- */

/* --------------- function start --------------- */
llong my_gcd(llong a, llong b) {
    return (a ? my_gcd(b % a, a) : b);
}
llong my_lcm(llong a, llong b) {
    return a * b / my_gcd(a, b);    
}

llong facmod(llong n) {
    if (n == 0) return 1;

    llong res = n;
    for (int i = n - 1; i > 0; --i) {
        res = (res * i) % MOD;
    }

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

    return res;
}
llong modinv(llong n) {
    return powmod(n, MOD - 2);
}
llong combmod(llong n, llong k) {
    llong res = 1;
    for (int i = 0; i < k; ++i) {
        res = (res * (n - i)) % MOD;
    }
    res = (res * modinv(facmod(k))) % MOD;

    return res;
}
/* --------------- function start --------------- */

int main(int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string S;
    cin >> S;
    if (S[0] == S[1] && S[1] == S[2]) cout << "No" << endl;
    else cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VII;
typedef pair<int,int> PII;

int main(){
  int N;
  cin>>N;
  ll ans=0;
  rep(i,N) if(i!=N-1) ans+=(i+1);
  cout<<ans<<endl;
}



Measured memory_bytes: 256
using AtCoderBeginnerContest148.Questions;
using AtCoderBeginnerContest148.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest148.Questions
{
    public class QuestionB : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            var st = inputStream.ReadString().Split(' ');
            var s = st[0];
            var t = st[1];

            var result = new StringBuilder();

            foreach (var chars in s.Zip(t, (s1, t1) => new { s1, t1 }))
            {
                result.Append(chars.s1);
                result.Append(chars.t1);
            }

            yield return result.ToString();
        }
    }
}


namespace AtCoderBeginnerContest148
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionB();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest148.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest148.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 11604
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n, t = 0;
	cin >> n;
	while(n) {
		if (n % 10 == 7)t = 1;
		n /= 10;
	}
	if (t == 1)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3624
//============================================================================
// Name        : abc141c.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;

int main() {
	int N, Q;
	long long K;
	cin >> N >> K >> Q;
	vector<long long> A(N, 0);
	long long maxPoint = 0;
	for(int i = 0; i < Q; ++i){
		int a;
		cin >> a;
		a = a - 1;
		++A[a];
	}

	for(int i = 0; i < N; ++i){
		cout << ((K - (Q - A[i])) <= 0 ? "No" : "Yes") << endl;
	}

	return 0;
}


Measured memory_bytes: 1408
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	int prev; cin >> prev;

	int idx = -1;
	for (int i = 1; i <n; i++) {
		int buf; cin >> buf;

		if (prev + buf >= l) {
			idx = i;
			break;
		}

		prev = buf;
	}

	if (idx != -1) {
		idx--;
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
		return 0;
	}
	

	for (int i = n - 2; i > idx; i--) {
		cout << i+1 << endl;
	}

	for (int i = 0; i < idx; i++) {
		cout <<i+1<< endl;
	}

	cout << idx+1 << endl;

}

Measured memory_bytes: 768
#define _USE_MATH_DEFINES
#include <math.h>
#include <time.h>
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i++)
#define reprev(i, n) reprrev(i, 0, n)

#define PI M_PI
#define INF 100000000

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<bool>> vvb;


int main()
{
	int X, t;
	cin >> X >> t;

	cout << max(0, X - t) << endl;

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#include <math.h>           // trunc(), sin(), cos(), M_PI
#include <stdbool.h>

int
main(int argc, char** argv)
{
	int d, a;

	double x = 0, y = 0;
	int th = 90;
	while (true)
	{
		scanf("%d,%d", &d, &a);
		if (d == 0 && a == 0)
			break;

		double rx = d * cos(M_PI * th / 180);
		double ry = d * sin(M_PI * th / 180);
		x += rx, y += ry;
		th = (th - a + 360) % 360;
	}

	printf("%.0f\n", trunc(x));
	printf("%.0f\n", trunc(y));
	return 0;
}

Measured memory_bytes: 632
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int mo=1e9+7;
#define M 200005
char S[M];
int main(){
	int n;
	scanf("%s",S);
	n=strlen(S);
	for(int i=0;i<n;++i) if(S[i]=='?') putchar('D'); else putchar(S[i]);
	puts("");
	return 0;
 }

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

int main() {
  int n, k, ans;
  cin >> n >> k;
  ans = 0;
  rep(i,n){
    int a;
    cin >> a;
    if(a >= k){
      ans++;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);

			int n=sc.nextInt();
            int []h=new int [n];
            int [] ans=new int [n];
            for(int i=0;i<n;i++)
            {
                h[i]=sc.nextInt();
            }
            ans[0]=0;
            ans[1]=ab(h[0]-h[1]);
           for(int i=2;i<n;i++)
            {
                ans[i]=min(ab(h[i]-h[i-1])+ans[i-1],ab(h[i]-h[i-2])+ans[i-2]);
            }	
            System.out.println(ans[n-1]);
    }
    public static int ab(int n)
    {
        if(n<0)
            return -n;
        return n;
    }
    public static int min(int a,int b)
    {
        if(a<b)
            return a;
        return b;
    }
   
 
}


Measured memory_bytes: 63068
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B = map(int, readline().split())

    for x in range(1, 1500):
        if 8 * x // 100 == A and 10 * x // 100 == B:
            print(x)
            return

    print('-1')
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll d;
    cin >> d;
    Vi c(26);
    matrix s(d,Vi(26));
    rp(i,26) cin >> c[i];
    rp(i,d){
        rp(j,26) cin >> s[i][j];
    }
    Vi t(d);
    rp(i,d) {
        cin >> t[i];
        t[i]--;
    }
    ll score=0;
    Vi last(26,-1);
    rp(i,d){
        score+=s[i][t[i]];
        rp(j,26){
            if(j==t[i]) {
                last[t[i]]=i;
                continue;
            }
            score-=c[j]*(i-last[j]);
        }
        print(score);
    }
    
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

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

typedef pair<int,int> pi;
typedef vector<int> vi;
 
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define pb push_back

template<typename T> void max_self(T &a, T b) { a = max(a,b); return;}
template<typename T> void min_self(T &a, T b) { a = min(a,b); return;}
 
const int nax = 3e6 + 5;
const int mod = 1e9 + 7;

int solve(int a,int b,int c){
	
	a = a % c;	
	if(b == 0) return 1;
	else if((b % 2) == 0) return solve((a * a) % c,b / 2,c) % c;
	else return (a * solve((a * a) % c,b / 2,c) % c) % c;
}

int n;
int dp[1 << 21];

signed main(){
	
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int t = 1;
	//cin >> t;
	while(t--){
		cin >> n;
		
		int arr[n][n];
		for(int i = 0; i < n ; ++i){
			for(int j = 0; j < n; ++j){
				cin >> arr[i][j];
			}
		}
		
		memset(dp,0,sizeof(dp));
		dp[0] = 1;
		
		for(int mask = 0; mask < (1 << n) - 1; ++mask){
			int women = __builtin_popcount(mask);
			for(int i = 0; i < n; ++i){
				if((mask & (1 << i)) == 0 && arr[i][women]){
					int newmask = mask | (1 << i);
					dp[newmask] = (dp[newmask] + dp[mask]) % mod;
				}
			}
		}
		
		cout << dp[(1 << n) - 1];
	}
	
	return 0;
}


Measured memory_bytes: 20032
#include<bits/stdc++.h>
using namespace std;
int main(){int x,y,k;
           cin>>x>>y;
           k=(4*x-y)/2;
           k=x-k;
           if(4*x-y>=0&&(4*x-y)%2==0&&k>=0){cout<<"Yes";}
           else{cout<<"No";}
  return 0;}


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

int main(void) {
  int N;
  cin >> N;
  vector<int> a(N);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    if ((i + 1) % 2 == 1 && a[i] % 2 == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define ll long long
#define INF 0x3f3f3f3f 
#define MEM(x,y) memset(x,y,sizeof(x))
#define int long long
#define rep(i , a , b) for(int i = a ; i <= b ; i ++)
#define P pair<int,int>
#define  sc(a) scanf("%lld",&a)
#define pf(a) printf("%lld ",a)
using namespace std;
#define int long long
const int N = 1005;
char s[1005];
int a[1005];
int n, k, ans;
int dp[1005][5];
signed main() {
    cin >> s+ 1;
    n = strlen(s + 1);
    for (int i = 1; i <= n; i++) a[i] = s[i]-'0';
    cin >> k;
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        dp[i][0] = dp[i - 1][0];
        for (int j = 1; j <= 3; j++) {
            dp[i][j] = dp[i - 1][j] + 9 * dp[i - 1][j - 1];
        }
    }
    int temp = 0;
    for (int i = 1; i <= n; i++) {
        if (a[i]) {
            if (k - temp >= 0) ans += dp[n - i][k - temp];
            if (k - temp - 1 >= 0) ans += (a[i] - 1) * dp[n - i][k - temp - 1];
            temp++;
        }
      
    }
    if (temp == k) ++ans;
    cout << ans;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        ww: usize,
        wv: [(usize, i64); n],
    }
    let mut dp = vec![vec![0; ww + 1]; 2];
    for i in 0 .. n {
        for j in 0 .. ww - wv[i].0 + 1 {
            dp[1][j + wv[i].0] = max(dp[1][j + wv[i].0], dp[0][j] + wv[i].1);
        }
        for j in 0 .. ww + 1 {
            dp[1][j] = max(dp[1][j], dp[0][j]);
        }
        dp.swap(0, 1);
    }
    puts!("{}\n", dp[0][ww]);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 10620
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
ld a,b,c,d,e,f,g;
cin >> a >> b;
d=max(a/0.08,b/0.10);
c=ceil(d);
if((floor(c*0.08)==a) && (floor(c*0.10)==b)){
cout << c << endl;
}else{
  cout << "-1" << endl;
}
}

Measured memory_bytes: 256
let read f = stdin.ReadLine() |> f
let n = read int
let s = stdin.ReadLine()
let table = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray()
for x in s do
    let i = Array.findIndex ((=)x) table
    table.[i+n]
    |> printf "%c"

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    int n; cin >> n;
    lint s = 0;
    map<int, int> mp;
    rep(i, n){
        int a; cin >> a;
        mp[a] += 1; s += a;
    }

    int q; cin >> q;
    rep(i, q){
        int b,c; cin >> b >> c;
        s += mp[b] * (c-b);
        mp[c] += mp[b]; mp[b] = 0; 
        out(s);
    }
}

Measured memory_bytes: 7888
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int n = 0;
        int a = (N-K)/(K-1);
        if ((N-K)%(K-1) == 0) {
            n = 1 + a;
        }else{
            n = 2 + a;
        }
        System.out.println(n);
    }
}

Measured memory_bytes: 23764
// C# program to build the smallest number 
// by removing n digits from a given number 
using System;
using System.Collections.Generic;
using System.Linq;
class GFG
{

    public static void Main(String[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var input = Console.ReadLine().Split(' ');
        var l = int.Parse(input[0]);
        var u = int.Parse(input[1]);
        Golf(n, l, u);
    }

    public static void Golf(int k, int l, int u)
    {

        for (int i = l; i <= u; i++)
        {
            var tmp = i % k;
            if (tmp==0)
            {
                Console.Write("OK");
                Console.WriteLine();
                return;
            }
        }
        Console.Write("NG");
        Console.WriteLine();
    }
}



Measured memory_bytes: 17876
#include <bits/stdc++.h>
#include <string>
using namespace std;
 
int main() {
  int64_t A,B,C,K;
  cin >> A >> B >> C >> K;
  if(A>=K){
    cout << K << endl;
  }else if((A+B) >= K){
    cout << A << endl;
  }else{
    cout << A -(K -(A+B)) << endl;
  }
}

Measured memory_bytes: 3624
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

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

int n;
vpi ans;
signed main(){
    I(n);
    int passsum = n/2*2+1;

    REPS(i,n){
        FOR(j,i+1,n+1){
            if(i+j == passsum) continue;
            ans.eb(i,j);
        }
    }
    cout << sz(ans) << endl;
    for(auto p:ans){
        cout << p.first << " " << p.second << endl;
    }

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }

typedef long long ll;



int main() {
    int N,M;
    cin >> N >> M;
    vector<bool> a(N,false);
    vector<ll> dp(N+1,1);
    REP(i,M){
        int ainp;
        cin >> ainp;
        a[ainp]=true;
    }
    REP(i,N+1) {
        if (a[i]) {
            dp[i]=0;
            continue;
        }
        if (i==0 || i==1) continue;
        dp[i]=(dp[i-1]+dp[i-2])%((ll)(1e9)+7);
    }
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string.h>
using namespace std;
using ll = long long;

int main()
{
  double w,h,x,y;
  cin>>w>>h>>x>>y;
  cout<<fixed<<setprecision(10)<<w*h/2.0<<' '<<((w==x*2&&h==y*2)?1:0)<<endl;

  return 0;
}

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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

template <class T>
struct SegmentTree{
  using F = function<T(T,T)>;
  F f;
  T inf;
  int n;
  vector<T> node;

  SegmentTree(vector<T> v,T inf,F f):inf(inf),f(f){
    n = 1; while(n < v.size()) n *= 2;
    node.resize(2*n-1,inf);
    for(int i = 0; i < v.size(); i++) node[i+n-1] = v[i];
    for(int i = n-2; i >= 0; i--) node[i] = f(node[2*i+1],node[2*i+2]);
  }

  void update(int k,T val){
    k += n-1;
    node[k] = val;
    while(k > 0){
      k = (k-1) / 2;
      node[k] = f(node[2*k+1],node[2*k+2]);
    }
  }

  void add(int k,T val){
    k += n-1;
    node[k] += val;
    while(k > 0){
      k = (k-1) / 2;
      node[k] = f(node[2*k+1],node[2*k+2]);
    }
  }

  T getval(int a,int b){ return getval(a,b,0,0,n); }
  T getval(int a,int b,int k,int l,int r){
    //区間[a, b)の値を返す
    if(r <= a || b <= l) return inf;
    if(a <= l && r <= b) return node[k];
    T vl = getval(a, b, 2*k+1, l, (l+r)/2);
    T vr = getval(a, b, 2*k+2, (l+r)/2, r);
    return f(vl, vr);
  }
};

const int MOD = 1e9+7;

signed main(){

  int n,m; cin >> n >> m;
  vector<int> s(n),t(m);
  for(int i = 0; i < n; i++) cin >> s[i];
  for(int i = 0; i < m; i++) cin >> t[i];

  SegmentTree<int> seg(vector<int>(m+1,0),0,[&](int x,int y){
    return (x + y) % MOD;
  });
  for(int i = 0; i < n; i++){
    for(int j = m-1; j >= 0; j--){
      if(s[i] == t[j]){
        seg.add(j,seg.getval(0,j)+1);
      }
    }
  }
  cout << seg.getval(0,m) + 1 << endl;

  return 0;
}


Measured memory_bytes: 384
N=int(input())
A=list(map(int,input().split()))

result=0

D={}

for j in range(N):
    if j+A[j] in D:
        D[j+A[j]] += 1
    else:
        D[j+A[j]]=1

for j in range(N):
    if j-A[j] in D:
        result += D[j-A[j]]

print(result)

Measured memory_bytes: 40312
#include <stdio.h>
#include <stdlib.h>

int px[900001],py[900001];
int d[900001];

int main(void){
  int H,W,D;
  scanf("%d%d%d",&H,&W,&D);

  int A;
  for(int i = 0;i < H;i++){
    for(int j = 0;j < W;j++){
      scanf("%d",&A);
      px[A] = i; py[A] = j;
    }
  }

  for(int i = D+1;i <= H*W;i++){
    d[i] = d[i-D]+abs(px[i]-px[i-D])+abs(py[i]-py[i-D]);
  }
  int Q;
  scanf("%d",&Q);

  int L,R;
  for(int i = 0;i < Q;i++){
    scanf("%d%d",&L,&R);
    printf("%d\n",d[R]-d[L]);
  }

  return 0;
}

Measured memory_bytes: 5504
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N, A, B = map(int, input().split())
V = list(map(int, input().split()))

dp = [-1] * (N + 1)
dp[0] = 0
cnt = [0] * (N + 1)
cnt[0] = 1

for i in range(N):
    for j in range(N, 0, -1):
        if dp[j - 1] < 0:
            continue
        if dp[j] < dp[j - 1] + V[i]:
            dp[j] = dp[j - 1] + V[i]
            cnt[j] = cnt[j - 1]
        elif dp[j] == dp[j - 1] + V[i]:
            cnt[j] += cnt[j - 1]

up = -1
btm = -1
s = 0

for i in range(A, B + 1):
    if dp[i] < 0:
        continue
    if up < 0:
        up, btm = dp[i], i
        s = cnt[i]
    elif up * i < dp[i] * btm:
        up, btm = dp[i], i
        s = cnt[i]
    elif up * i == dp[i] * btm:
        s += cnt[i]


print(up / btm)
print(s)

Measured memory_bytes: 3676
'''Author- Akshit Monga'''
n=int(input())
x=input()
x=x[::-1]
ans1=0
ans2=0
c=x.count('1')
for i in range(0,n):
    if x[i]=='1':
        ans1=(ans1+pow(2,i,c+1))%(c+1)
        if c!=1:
            ans2=(ans2+pow(2,i,c-1))%(c-1)
to_print=[]
for i in range(0,n):
    if x[i]=='1':
        if c==1:
            to_print.append(0)
            continue
        var=(ans2%(c-1)-pow(2,i,c-1))%(c-1)
        a = 1
        while var:
            var = var % bin(var).count('1')
            a += 1
        to_print.append(a)
    else:
        # print(ans1)
        var = (ans1%(c+1) + pow(2, i, c +1))%(c+1)
        # print(c+1)
        # print(var)
        a = 1
        while var:
            var = var % bin(var).count('1')
            a += 1
        to_print.append(a)
for i in to_print[::-1]:
    print(i)

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

constexpr const int maxElem = 10000;

void CountingSort( std::vector<int>& v ){
    std::vector<int> count( maxElem + 1 ); // 0-origin, C inlec
    for( auto& cElem : count ){
        cElem = 0;
    }

    int i = 1;
    for( ; i <= v.size(); ++i ){
        ++count[v[i]];
    }

    for( i = 1; i <= maxElem; ++i ){
        count[i] += count[i-1];
    }

    //----test----
    // for( const auto& elem : count ){
    //     std::cout << elem << " ";
    // }
    // std::cout << "\n";
    //------------

    std::vector<int> result( v.size() );
    for( i = v.size(); i > 0; --i ){
        result[count[v[i]]] = v[i];
        --count[v[i]];
    }
    v = std::move(result);
}


int main(){
    int n;
    std::cin.tie(0);
    std::cin >> n;

    std::vector<int> v( n + 1 );
    for( int i = 1; i <= n; ++i ){
        std::cin >> v[i];
    }

    CountingSort(v);

    for( int i = 2; i <= v.size(); ++i ){
        std::cout << v[i] << ( ( i != v.size() )? " " : "\n" );
    }
}


Measured memory_bytes: 18416
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
struct edge { ll s, t, x; };
typedef pair<int, int> P;
typedef pair<ll,P> event;
const ll MAX = 510000;
const ll MOD = 1000000007;
#define INF (ll)1000000000000

int main() {
  ll N;
  cin>>N;
  map<int,int>mp;
  ll ans=0ll;
  queue<int>qu[N];
  rep(i,N){
    rep(j,N-1){
      int a;cin>>a;a--;
      qu[i].push(a);
    }
  }
  queue<int>play;
  rep(i,N){
    mp[i]=qu[i].front();
    qu[i].pop();
  }
  rep(i,N){
    int t=mp[i];
    if(mp[t]==i){
      play.push(i);
    }
  }
  
  while(!play.empty()){
    ans++;
    int g=play.size();
    rep(i,g){
      int x=play.front();play.pop();
      if(!qu[x].empty()){mp[x]=qu[x].front();qu[x].pop();}
      else{mp[x]=-1;continue;}
      int t=mp[x];
      if(mp[t]==x){
        play.push(t);
        play.push(x);
      }
    }
  }
  rep(i,N){if(mp[i]!=-1){cout<<-1;return 0;}}
  cout<<ans;
}



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

typedef long long ll;

int main(){
  cout << setprecision(20);
  ll N, P; cin >> N >> P;
  map<ll,ll> m;
  for(int i = 0; i < N; i++){
    ll tmp; cin >> tmp;
    m[tmp%2]++;
  }
  
  ll ans;
  if(m[1] == 0){
    if(P == 1){
      ans = 0;
    } else { 
      ans = pow(2,N);
    }
  } else {
    ans = pow(2,N-1);
  }
  cout <<  ans << endl;
}

Measured memory_bytes: 4108
#include <iostream>
#include <vector>
#include <stdlib.h>

using namespace std;

int main() {
	int N;
	int left = 0, right = 0, ans;
	cin >> N;

	vector<int> W(N);
	for (int i = 0; i < N; i++)
	{
		cin >> W[i];
		right += W[i];
	}
	left = W[0];
	right -= W[0];
	ans = abs(right - left);
	for (int i = 1; i < N; i++) {
		left += W[i];
		right -= W[i];
		if (ans > abs(right - left))
			ans = abs(right - left);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
 
  int b=0,c1=0,c2=0,z=0;
  double x,y;
  
  scanf("%d %d",&c1,&c2);
 
  for(z=0;z <= c1;z++){
    b = c1 - z;
    if(2*z + 4*b == c2){
      printf("Yes");
      break;
    }
    else if(z == c1){
      printf("No"); 
    }  
  }
 return 0;
  
}

Measured memory_bytes: 1732
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string &s, char c){vector<string> v;int d=0,f=0;string t;for(char c:s){if(!d&&c==',')v.pb(t),t="";else t+=c;if(c=='\"'||c=='\'')f^=1;if(!f&&c=='(')++d;if(!f&&c==')')--d;}v.pb(t);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
	string s;
	cin>>s;
	cout<<s.substr(0,s.size()-8)<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            if (N == 1)
            {
                Console.WriteLine(0);
                return;
            }

            var NPrimeList = PrimeFactors(N).ToList<long>();
            var ans = 0;
            var eList = new List<long>();
            for (int i = 0; i < NPrimeList.Count; i+= NPrimeList.Count(n => n == NPrimeList[i]))
            {
                eList.Add(NPrimeList.Count(n => n == NPrimeList[i]));
            }
            for (int i = 0; i < eList.Count; i++)
            {
                var b = 1;
                while (true)
                {
                    eList[i] -= b;
                    b++;
                    if (eList[i] >= 0)
                    {
                        ans++;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            Console.WriteLine(ans);
        }

        static IEnumerable<long> PrimeFactors(long n)
        {
            long i = 2;
            long tmp = n;

            while (i * i <= n) 
            {
                if (tmp % i == 0)
                {
                    tmp /= i;
                    yield return i;
                }
                else
                {
                    i++;
                }
            }
            if (tmp != 1) yield return tmp;//最後の素数も返す
        }
    }
}


Measured memory_bytes: 18564
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func main() {
	sc := NewScanner()
	A, B := sc.nextInt(), sc.nextInt()
	if A == 1 {
		A = 14
	}
	if B == 1 {
		B = 14
	}
	if B < A {
		fmt.Println("Alice")
	} else if A < B {
		fmt.Println("Bob")
	} else {
		fmt.Println("Draw")
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<int>;
using vec2 = vector<vector<int>>;
 
int main(){
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if(a < b){
        if(a + v * t < b + w * t){
        cout << "NO" << endl;
        }
        else{
            cout << "YES" << endl;
    	}
    }
    else{
        if(a - v * t > b - w * t){
        	cout << "NO" << endl;
	    }
    	else{
    	    cout << "YES" << endl;
    	}
    }
 
}


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

void solve(long long N, std::vector<long long> a) {
  int ans = 0;
  for(int i = 0 ; i < N ; ){
    int j = i;
    while( j < N && a[j] == a[i] ) j++;
  	ans += (j - i) / 2;
    i = j;
  }
  cout << ans << endl;  
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  solve(N, std::move(a));
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define int long long

using namespace std;

int H, W, K;
char ccc[10][10];

signed main()
{
    cin >> H >> W >> K;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cin >> ccc[i][j];
        }
    }

    int ans = 0;
    for (int r = 0; r < (1 << H); r++)
    {
        for (int c = 0; c < (1 << W); c++)
        {
            int num = 0;
            for (int rr = 0; rr < H; rr++)
            {
                for (int cc = 0; cc < W; cc++)
                {
                    if (((r >> rr) % 2 == 1) || ((c >> cc) % 2 == 1))
                    {
                        continue;
                    }
                    if (ccc[rr][cc] == '#')
                        num++;
                }
            }
            if (num == K)
            {
                ans++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3232
n = int(input())
a = list(map(int, input().split()))
f = [0 for x in range(10**5 + 10)]
for i in a:
    f[i] += 1
    f[i + 1] += 1
    f[i - 1] += 1


print(max(enumerate(f), key=lambda x: x[1])[1])


Measured memory_bytes: 14092
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
ll a[105];
int main()
{
    ll n,i,j,k;
    scanf("%lld",&n);
    for(i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    ll ans=0;
    for(i=1;i<=n;i++)
        for(j=i+1;j<=n;j++)
            for(k=j+1;k<=n;k++)
    {
        if(a[i]==a[j]||a[i]==a[k]||a[j]==a[k])
            continue;
        if(a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i])
            ans++;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3816
import sys

a = w = t = r = 0
n = int(input())

for _ in range(n):
  s = sys.stdin.readline().strip()
  if s == "AC":
    a += 1
  elif s == "WA":
    w += 1
  elif s == "TLE":
    t += 1
  elif s == "RE":
    r += 1

print("AC x {}".format(a))
print("WA x {}".format(w))
print("TLE x {}".format(t))
print("RE x {}".format(r))

Measured memory_bytes: 9148
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N, A, B = get_ints

MOD= 10 ** 9  + 7

# 2 ** N - N - nCa - nCb

# mod m での aの逆元
def modinv(a, m)
  b = m; u = 1; v = 0

  while b != 0
    t = a / b
    a -= t * b
    c = a; a = b; b = c
    u -= t * v
    c = u; u = v; v = c
  end
  u %= m
  if u < 0
    u += m
  else
    u
  end
end

# nCa
ue = 1
shita = 1
A.times do |a|
  ue = ue * (N - a) % MOD
  shita = shita * (A - a) % MOD
end

nCa = ue * modinv(shita, MOD) % MOD

# nCb
ue = 1
shita = 1
B.times do |a|
  ue = ue * (N - a) % MOD
  shita = shita * (B - a) % MOD
end

nCb = ue * modinv(shita, MOD) % MOD

def exponential_with_mod(n, k, mod)
  return 1 if k == 0
  return n if k == 1

  if k % 2 == 1
    (n * (exponential_with_mod(n, k/2, mod) ** 2 % mod)) % mod
  else
    (exponential_with_mod(n, k/2, mod) ** 2) % mod
  end
end

# 2 ^ n
nn = exponential_with_mod(2, N, MOD)

ans = nn - 1 - nCa - nCb
while ans < 0
  ans += MOD
end

puts ans



Measured memory_bytes: 14244
from collections import deque

n,k=map(int,input().split())
visited=[False]*n
visited[0]=True
color=[0]*n
color[0]=k
mod=10**9+7

graph=[[] for i in range(n)]

for i in range(n-1):
    a,b=map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)


Q=deque()
Q.append((0))
ans=k

while Q:
  p=Q.popleft()
  cnt=0
  for i in graph[p]:
    if visited[i]==False:
        cnt+=1
        Q.append((i))
        visited[i]=True

  if p==0:
      for i in range(cnt):
          ans*=k-i-1
          ans%=mod

  else:
      for i in range(cnt):
          ans*=k-i-2
          ans%=mod


print(ans%mod)

Measured memory_bytes: 94232
#include<stdio.h>
#define N 100
#define INF (1<<21)
#define W 0
#define G 1
#define B 2
int n,m[N][N];
void in(){
  int i,j,k,c,u,v;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      m[i][j]=INF;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      m[u][v]=c;
    }
  }
}
void dijkstra(){
  int x,min,i,j;
  int c[N],d[N];
  for(i=0;i<n;i++){
    d[i]=INF;
    c[i]=W;
  }
  d[0]=0;
  c[0]=G;
  while(1){
    min=INF;
    x=-1;
    for(i=0;i<n;i++){
      if(min>d[i] && c[i]!=B){
        x=i;
        min=d[i];
      }
    }
    if(x==-1)break;
    c[x]=B;
    for(j=0;j<n;j++){
      if(c[j]!=B && m[x][j]!=INF){
        if(d[j]>d[x]+m[x][j]){
          d[j]=d[x]+m[x][j];
          c[j]=G;
        }
      }
    }
  }
  for(i=0;i<n;i++){
    if(d[i]==INF)printf("%d -1\n",i);
    else printf("%d %d\n",i,d[i]);
  }
}
int main(){
  in();
  dijkstra();
  return 0;
}



Measured memory_bytes: 2056
N = int(input())
A = list(map(int, input().split()))

result = 1
t = [0, 0, 0]
for i in range(N):
  a = A[i]
  f = -1
  k = 0
  for j in range(3):
    if t[j] == a:
      k += 1
      if f == -1:
        t[j] += 1
        f = j
  result = (result * k) % 1000000007
print(result)


Measured memory_bytes: 13964
#n=int(input())
a,b,c,d=map(int,input().split())
#t=int(input())
#al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
import math

lcm=(c//math.gcd(c,d))*d #最小公倍数

cnum=b//c-(a-1)//c
dnum=b//d-(a-1)//d
cdnum=b//lcm-(a-1)//lcm

ans=b-a+1-(cnum+dnum)+cdnum
print(ans)


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

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

  vector<string> w(n);
  bool flag = true;

  for(int i = 0; i < n; i++){
    cin >> w[i];

    if(flag && i != 0){
      if(w[i-1][w[i-1].length()-1] != w[i][0]) flag = false;

      for(int j = 0; j < i; j++){
        if(w[j] == w[i]){
          flag = false;
          break;
        }
      }
    }
  }

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;

}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int n,x,count5;
  
  while(scanf("%d",&n),n){
    count5=0;
    for(;n>0;n--){
      x=n;while(x%5==0){x=x/5;count5++;}
    }
    printf("%d\n",count5);
  }
  return 0;
}

Measured memory_bytes: 0