akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i< (n);i++)
using namespace std;

int main() {
  int a,b;
  cin>>a>>b;
  if((a+b)%2==0){
    int k=(a+b)/2;
    cout<<k<<endl;
  }
  else cout<<"IMPOSSIBLE"<<endl;
  
}

Measured memory_bytes: 256
# AGC025A - Digits Sum
def main():
    n = int(input())
    ans = float("inf")
    for i in range(1, n // 2 + 1):
        j = n - i
        ds = sum(map(int, str(i))) + sum(map(int, str(j)))  # digits sum
        ans = min(ans, ds)
    print(ans)


if __name__ == "__main__":
    main()

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if ((A+B) > (C+D)) {
    cout << "Left" << endl;
  }
  else if ((A+B) < (C+D)) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
using System;

namespace Sample1
{
    class Program
    {
        static void Main(string[] args)
        {
            int a;
            int b;
            string op;
            string input;
            while (true)
            {
                input = Console.ReadLine();
                a = int.Parse(input.Split(' ')[0]);
                b = int.Parse(input.Split(' ')[2]);
                op = input.Split(' ')[1];
                if (op == "+")
                {
                    Console.WriteLine(a + b);
                }
                else if (op == "-")
                {
                    Console.WriteLine(a - b);
                }
                else if (op == "*")
                {
                    Console.WriteLine(a * b);
                }
                else if (op == "/")
                {
                    Console.WriteLine(a / b);
                }
                else
                {
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 9172
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>

using namespace std;

int main(){
	string s,t,u;
	cin >> s >> t >> u;
	cout << s[0] << t[0] << u[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
using namespace std;
int s[200010];
vector <int> v[200010];
int main()
{

    int n,m;
    cin>>n>>m;
    int a,b;
    for(int i=0;i<m;i++)
    {
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    queue<int> q;
    s[1]=0;
    q.push(1);
    while(!q.empty())
    {
        int a=q.front();
        q.pop();
        for(int i=0;i<v[a].size();i++)
        {
            if(s[v[a][i]]==0&&v[a][i]!=1)
            {
                q.push(v[a][i]);
                s[v[a][i]]=a;
            }
        }
    }
    int x=1;
    for(int i=2;i<=n;i++)
    {
        if(s[i]==0)
        {
            x=0;
            break;
        }
    }
    if(x)
    {
        cout << "Yes" << endl;
        for(int i=2;i<=n;i++)
        {
            cout<<s[i]<<endl;
        }
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 12848
N, X, Y = map(int, input().split())

d = {}
for i in range(1, N):
    for j in range(i+1, N+1):
        mi_n = min(abs(j-i), abs(X-i)+1+abs(j-Y))
        if mi_n not in d:
            d[mi_n] = 1
        else:
            d[mi_n] += 1

for idx in range(1, N):
    if idx not in d:
        print('0')
    else:
        print(d[idx])


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

const int MOD = 1e5;

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    ll sum = 0;
    sum += min(a, k);
    k -= a + b;
    if (k > 0) {
        sum -= min(c, k);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>

char field[10][10];
int H,W;

int main(){
   std::cin>>H>>W;
   int cnt=0;
   for(int i=0;i<H;++i){
       for(int j=0;j<W;++j){
           std::cin>>field[i][j];
           if(field[i][j]=='#')cnt++;
       }
   }
   if(cnt==H+W-1)std::cout<<"Possible"<<std::endl;
   else std::cout<<"Impossible"<<std::endl;
   return 0;
}

Measured memory_bytes: 256
from collections import deque
while 1:
    N = int(input())
    if N == 0:
        break

    G = [[] for i in range(N)]
    for i in range(N-1):
        a, b, t = map(int, input().split())
        a -= 1; b -= 1
        G[a].append((b, t))
        G[b].append((a, t))
    D = [-1]*N; P = [0]*N
    que = deque([0])
    D[0] = 0
    while que:
        v = que.popleft()
        c = D[v]
        for w, d in G[v]:
            if D[w] != -1:
                continue
            D[w] = c + d
            P[w] = d
            que.append(w)
    ans = 0
    m = 0
    for i in range(N):
        if not i or len(G[i]) > 1:
            ans += P[i]*2
            m = max(m, D[i])
    ans -= m
    print(ans)



Measured memory_bytes: 6016
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin>>s;
  in n=sz(s);
  in df=0;
  forv(i,s)
    df-=(s[i]=='p');
  df+=n/2;
  cout<<df<<endl;
  return 0;
}


Measured memory_bytes: 512
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

total_a = sum(a)
for i in range(n):
    a[i] -= b[i]
    
    if a[i] <= 0:
        a[i + 1] = max(0, a[i + 1] + a[i])
        a[i] = 0

print(total_a - sum(a))

Measured memory_bytes: 18624
//
// Created by moono on 2018/10/27.
//

#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;



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


    for (int i = 0; i < S.size(); i+=2) {
        cout << S[i];
    }
    cout << endl;


    return 0;
}

Measured memory_bytes: 764
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    a = LI()

    money = 1000
    mn, mx = a[0], a[0]
    up = True

    for price in a:
        if mx <= price:
            up = True
            mx = price
        else:
            if up:
                money = money//mn * mx + money%mn
            up = False
            mn, mx = price, price

    money = money//mn * mx + money%mn
    
    print(money)
            

main()


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

using namespace std;
using T = long long;

//RMQに答えるSegmentTree
//必要に応じて書き換える．
const T INF = (1LL<<31) - 1LL;
struct SegmentTree {
private:
    int n;
    vector<T> node;
public:
    SegmentTree(vector<T> vect){
        int sz = vect.size();
        n = 1; for(;n<sz;) n*= 2;
        node.resize(2*n-1,INF);

        for(int i=0; i<sz ; i++) node[i+n-1] = vect[i];
        for(int i=n-2; i>=0 ; i--) node[i] = min(node[2*i+1], node[2*i+2]);//ここをうまく書き換える
    }

    void update(int x, T val){
        x += (n-1);

        node[x] = val;
        while(x > 0){
            x = (x-1) / 2;
            node[x] = min(node[2*x+1], node[2*x+2]);
        }
    }
    T getmin(int a, int b, int k=0, int l=0, int r= -1) {
        if(r<0) r=n;
        if(r <= a || b <= l) return INF;
        if(a<=l && r<=b ) return node[k];

        T vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        T vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl,vr);
    }
};
int main () {
    int n,q;
    cin >> n >> q;
    vector<T> vect(n, INF);
    SegmentTree bit(vect);
    int c,x,y;

    for(int i=0; i<q ; i++){
        cin >> c;
        if( c==0 ){
            cin >> x >> y;
            bit.update(x,y);
        }else{
            cin >> x >> y;
            y++;
            cout << bit.getmin(x,y) << endl;
        }
    } 

    return 0;
}



Measured memory_bytes: 6568
s = input()
C = False
c_index = None
F = False
f_index = None

for i in range(len(s)):
    if s[i] == "C":
        C = True
        c_index = i
    if s[i] == "F":
        F = True
        f_index = i

if C == True and F == True:
    if c_index < f_index:
        print("Yes")
    else:
        print("No")
else:
    print("No")


Measured memory_bytes: 3064
#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>;

const int INF = 100100100;

int main() {
  int n; ll k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  vector<int> s; //訪れた町を入れてく
  vector<int> ord(n+1,-1); //何番目に訪れたかを記録
  int c = 1, l = 0; //cは周期、lは周期じゃない部分の長さ
  {
    int v = 1; //街の番号
    while(ord[v] == -1){ //訪れてないなら回す
      ord[v] = s.size();
      s.push_back(v);
      v = a[v-1];
    }
    c = s.size() - ord[v]; //ord[v]に入れようとした数-ord[v]
    l = ord[v];
  }

  if(k < l) cout << s[k] << endl;
  else{
    k -= l; //周期じゃない部分の長さを引くのを忘れるな
    k %= c;
    cout << s[l+k] << endl; //l+kにするのを忘れるな
  }
  return 0;
}

Measured memory_bytes: 5756
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n;
	cin >> n;
	ll arr[1000000];
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	ll ans = 0;
	for (int i =0; i<n-1; i++)
	{
		if (arr[i] > arr[i + 1])
		{
			ans += arr[i] - arr[i + 1];
			arr[i + 1] = arr[i];
		}
	}
	cout << ans;
}

Measured memory_bytes: 5192
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int GRID = 3;
  int CMAX = 100;
  int C[GRID][GRID];
  int c;
  int sub[GRID];
  REP(i,GRID)REP(j,GRID){
      cin >> c;
      C[i][j] = c;
  }
  REP(a0,CMAX+1)REP(a1,CMAX+1)REP(a2,CMAX+1){
      bool flag = true;
      REP(j,3){
        sub[j] = C[0][j] - a0;
        if(sub[j] + a1 != C[1][j])flag = false;
        if(sub[j] + a2 != C[2][j])flag = false;
      }
      if (flag){
          cout << "Yes" << endl;
          return 0;
      }

  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef pair<int, int> pii;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
void SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


class B {
	int n, a, b;
	int ans{ 0 };
public:
	B()
	{
		cin >> n >> a >> b;
	}

	bool check(int x)
	{
		int sum{ 0 };

		while (x)
		{
			sum += x % 10;
			x /= 10;
		}

		if (sum < a || sum > b)
			return false;
		return true;

	}

	void solve()
	{

		REP1C(i, n)
		{
			if (check(i))
				ans += i;
		}

		cout << ans << endl;

	}
};


int main()
{
	B solution;
	solution.solve();

	return 0;
}

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

using namespace std;
typedef long long LL;

int dp[3010][3010];

int main() {
    string s, t;
    cin>>s>>t;
    memset(dp,0,sizeof(dp));
    for (int i=t.size()-1;i>=0;i--) {
        if (t[i]==s[s.size()-1]) dp[s.size()-1][i]=1;
        if (i+1<t.size()) dp[s.size()-1][i]=max(dp[s.size()-1][i], dp[s.size()-1][i+1]);
    }
    for (int i=s.size()-1;i>=0;i--) {
        if (s[i]==t[t.size()-1]) dp[i][t.size()-1]=1;
        if (i+1<s.size()) dp[i][t.size()-1]=max(dp[i][t.size()-1], dp[i+1][t.size()-1]);
    }
    for (int i=s.size()-2;i>=0;i--)
        for (int j=t.size()-2;j>=0;j--) {
            if (s[i]==t[j]) dp[i][j]=max(dp[i][j], dp[i+1][j+1]+1);
            dp[i][j]=max(dp[i][j], dp[i+1][j]);
            dp[i][j]=max(dp[i][j], dp[i][j+1]);
        }
    int i=0, j=0;
    while (i<s.size() && j<t.size()) {
        if (s[i]==t[j]) {
            cout<<s[i];
            i++;
            j++;
        } else {
            if (dp[i+1][j]==dp[i][j]) i++;
            else j++;
        }
    }
    cout<<endl;
}

Measured memory_bytes: 35712
/*  CREATED BY
    STREAM_CIPHER
    19-sep-2020
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define debug1(a) cout<<#a<<"="<<(a)<<"\n"
#define debug2(a,b) cout<<#a<<"="<<(a)<<","<<#b<<"="<<(b)<<"\n"
#define debug3(a,b,c) cout<<#a<<"="<<(a)<<","<<#b<<"="<<(b)<<","<<#c<<"="<<(c)<<"\n"
#define fix_precision(n) cout<<fixed<<setprecision(n)
#define all(a) a.begin(),a.end()
const double pi=acos(-1.0);
int inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int mx=5*1000000;//5*64M bit ->5*8M byte ->40MB size for long long int (64 bit)
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    #endif
        int n;
        cin>>n;
        vector<pair<int,int>>a(n);
        vector<int>aa(n);
        for(int i=0;i<n;i++)
        {
            cin>>a[i].first>>a[i].second;
            if(a[i].first==a[i].second)
                aa[i]=1;
            else
                aa[i]=0;
        }
        for(int i=0;i<n-2;i++)
        {
            if(aa[i]==aa[i+1]&&aa[i+1]==aa[i+2]&&aa[i]==1)
            {
                cout<<"Yes\n";
                return 0;
            }
        }
        cout<<"No\n";
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  set<int> S;
  vector<vector<int>> G(N);
  for(int i=0; i<M; i++){
    int a, b, c;
    cin >> a >> b >> c;
    G.at(a-1).push_back(b-1);
    G.at(b-1).push_back(a-1);
    S.insert(a-1);
    S.insert(b-1);
  }
  
  int ans = N - S.size();
  queue<int> Q;
  while(S.size()){
    int x = *begin(S);
    Q.push(x);
    ans++;
    while(Q.size()){
      int y = Q.front();
      Q.pop();
      S.erase(y);
      for(int i=0; i<G.at(y).size(); i++){
        if(S.count(G.at(y).at(i))){
          S.erase(G.at(y).at(i));
          Q.push(G.at(y).at(i));
        }
      }
    }
  }
  cout << ans << endl; 
}

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

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

    long long int H[N];
    int tower[N];
    for (int i = 0; i < N; i++) {
        cin >> H[i];
        tower[i] = 1;
    }
    for (int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        if (H[A-1] > H[B-1]) {
            // tower[A-1] = 0;
            tower[B-1] = 0;
        } else if (H[A-1] < H[B-1]) {
            // tower[B-1] = 0;
            tower[A-1] = 0;
        } 
        else if(H[A-1] ==  H[B-1]) {
            tower[A-1] = 0;
            tower[B-1] = 0;
        }
    }

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        /*
        if (!tower[i]) {
            cnt++;
        }
        */
       cnt += tower[i];
    }
    printf("%d\n", cnt);

    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = 1e9+7;
const int INF = 1e9;



int main() {
	cin.sync_with_stdio(false);
	string s;
	cin >> s;
	rep(i, s.size() - 8) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define SaveTime ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define mx *max_element
#define mi *min_element
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const int INF = 1e18L;
int ncr(int n,int r){if(n<r)return 0;int p=1,k=1;if(n-r<r)r=n-r;if(r!=0){while(r){p*=n;k*=r;int g=__gcd(p, k);p/=g;k/=g;n--;r--;}}else p=1;return p;}
#define pi acos(-1)
int ar[N];
int tree[2*N];
int dp[N];
int bit[N];
signed main(){
 	// #ifndef ONLINE_JUDGE
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// #endif
	SaveTime;
	int T=1;
	// cin >> T;
	while(T--){
		double x ;
		cin >> x;
		double y= ceil(x/2);
		cout << fixed << setprecision(10) << y/x << endl;
	
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstring>
#include <iostream>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

int search(int A[],int n, int key){
    int i=0;
    A[n]=key;
    while(A[i]!=key){
        i++;
    }
    return i!=n;
}

int main() {
    int n, q,count=0;
    scanf("%d", &n);
    int s[n+1];
    for(int i = 0; i < n; i++) {
        scanf("%d", &s[i]);
    }
    scanf("%d", &q);
    int t[q];
    for(int i = 0; i < q; i++) {
        scanf("%d", &t[i]);
    }

    for(int i = 0; i<q ; i++) {
        count +=  search(s,n+1,t[i]); 
    }
    cout << count << endl;
}


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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;

    multiset<unsigned long, greater<>> s;
    unsigned long ans{0};
    for(unsigned long i = 0, A; i < N; ++i){
        cin >> A;
        auto it = s.upper_bound(A);
        if(it != s.end()){
            s.erase(it);
        }else{
            ++ans;
        }
        s.insert(A);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

N=intput()
if N==1:
    print(0)
    exit()
if N==2:
    print(2)
    exit()
ans=powmod(10,N,MOD)-2*powmod(9,N,MOD)+powmod(8,N,MOD)
ans%=MOD
print(ans)

Measured memory_bytes: 69640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#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++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG
const int inf=1e9+7;

int main(){
    int n;cin>>n;
    vin a(n);
    rep(i,n)cin>>a[i];
    int ans=0;
    rep(i,n){
        while(a[i]%2==0){
            a[i]/=2;
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  map<string,int> mp;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    mp[s]++;
  }
  cout<<"AC x "<<mp["AC"]<<endl;
  cout<<"WA x "<<mp["WA"]<<endl;
  cout<<"TLE x "<<mp["TLE"]<<endl;
  cout<<"RE x "<<mp["RE"]<<endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main(void){
    int i,j,k,l;
    int left[4]={0},right[4]={0};
    double data_l,data_r;
    
    while(cin>>data_l>>data_r){
        if(data_l>=1.1){
            left[0]++;
        }
        else if(data_l<1.1&&data_l>=0.6){
            left[1]++;
        }
        else if(data_l<0.6&&data_l>=0.2){
            left[2]++;
        }
        else if(data_l<0.2){
            left[3]++;
        }
        if(data_r>=1.1){
            right[0]++;
        }
        else if(data_r<1.1&&data_r>=0.6){
            right[1]++;
        }
        else if(data_r<0.6&&data_r>=0.2){
            right[2]++;
        }
        else if(data_r<0.2){
            right[3]++;
        }
    }
    for(i=0;i<4;i++){
        cout<<left[i]<<" "<<right[i]<<endl;
    }
    return(0);
}

Measured memory_bytes: 1224
#include<iostream>
#include<cstdio>
#include<cstdlib>
 
using namespace std;
 
#define rep(i, n) for (int i = 0; i < int(n); ++i)
 
string a[11];
int score[11];
 
int main() {
  srand('~');
  int n;
  cin >> n;
  rep (i, n) cin >> a[i];
  rep (i, n) rep (j, n) if (a[i][j] == '-') ++score[i];
  rep (i, n) rep (j, n) if (a[i][j] == 'o') score[i] += 3;
  int sum = 0;
  rep (i, n) sum += score[i];
  rep (i, n) {
    if (score[i] == 3 * n - 2) {
      sum = score[i];
      rep (j, n) score[j] = 0;
      score[i] = sum;
    }
  }
  rep (i, 1000) {
    int r = rand() % sum;
    rep (i, n) {
      r -= score[i];
      if (r <= 0) {
	printf("%d\n", i + 1); fflush(stdout);
	break;
      }
    }
    int judge_ai_hand;
    scanf("%d", &judge_ai_hand);
  }
  return 0;
}

Measured memory_bytes: 1332
import math
pi = math.pi
cos = math.cos
sin = math.sin
sqrt = math.sqrt

def main():
  a, b, h, m = map(int, input().split())

  short_rad = pi * h / 6 + pi * m / 360
  long_rad = pi * m / 30

  # print(short_rad)
  # print(long_rad)

  short_coordinate = [a * cos(short_rad), a * sin(short_rad)]
  long_coordinate = [b * cos(long_rad), b * sin(long_rad)]

  # print(short_coordinate)
  # print(long_coordinate)

  distance = sqrt((short_coordinate[0] - long_coordinate[0])**2 + (short_coordinate[1] - long_coordinate[1])**2)

  print(distance)

if __name__ == '__main__':
  main()

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

signed main(){
	int a,b;
	cin>>a>>b;
	int c=1,cnt=0;
	while(c<b){
		c+=a-1;
		cnt++;
		//cout<<c<<endl;
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 256
Option Infer On
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim dic = New Dictionary(Of Char, Boolean)
        Dim S = NextString()
        Dim ans = "yes"

        For Each v As Char In S
            If dic.ContainsKey(v) Then
                ans = "no"
            End If
            dic(v) = True
        Next

        WriteLine(ans)
    End Sub

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 22096
package main

import "fmt"

func main() {
    var N, r, l int
    var c byte
    var s []byte
    fmt.Scanf("%d\n", &N)
    for i := 0; i < N; i++ {
        fmt.Scanf("%c", &c)
        if c == '(' {
            r++
        } else if r > 0 {
            r--
        } else {
            l++
        }
        s = append(s, c)
    }
    for i := 0; i < l; i++ {
        fmt.Printf("%c", '(')
    }
    fmt.Printf("%s", s)
    for i := 0; i < r; i++ {
        fmt.Printf("%c", ')')
    }
    fmt.Printf("\n")
}

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

int main() {
  int m, f, r;

  while (1) {
    cin >> m >> f >> r;

    if ((m == -1) && (f == -1) && (r == -1)) {
      break;
    }

    if ((m == -1) || (f == -1)) {
      cout << "F" << endl;
    } else if ((m + f) >= 80) {
      cout << "A" << endl;
    } else if ((m + f) >= 65) {
      cout << "B" << endl;
    } else if ((m + f) >= 50) {
      cout << "C" << endl;
    } else if ((m + f) >= 30) {
      if (r >= 50) {
        cout << "C" << endl;
      } else {
        cout << "D" << endl;
      }
    } else {
      cout << "F" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll MOD = 1e9 + 7;

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

    ll n, k;
    cin >> n >> k;
    ll res = 0;
    for (ll j = k; j <= n + 1; j++) {
        ll mi = j * (j - 1) / 2, ma = j * (2 * n - j + 1) / 2;
        res += (MOD + ma - mi + 1) % MOD;
        res %= MOD;
    }
    cout << res << endl;
    return 0;
}

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

const int MAXN = 2e5 + 10;

int a[MAXN];
long long sum[MAXN];

// interval tree
int cnt[MAXN<<2];

inline void pushup (int rt) {
    cnt[rt] = cnt[rt<<1] + cnt[rt<<1|1];
}

void upd (int l, int r, int val, int st, int en, int rt) {
    if (l <= st && en <= r) {
    	cnt[rt] += val;
        return;
    }

    int md = (st+en)>>1;
    if (l <= md) upd(l,r,val,st,md,rt<<1);
    if (md < r) upd(l,r,val,md+1,en,rt<<1|1);
    pushup(rt);
}

long long query (int l, int r, int st, int en, int rt) {
    if (l <= st && en <= r) {
        return cnt[rt];
    }

    long long ret = 0;
    int md = (st+en)>>1;
    if (l <= md) ret += query(l,r,st,md,rt<<1);
    if (md < r) ret += query(l,r,md+1,en,rt<<1|1);
    return ret;
}

int bs (long long val, int st, int en) {
	while (st != en) {
		int md = (st + en) >> 1;
		if (val <= sum[md]) en = md;
		else st = md + 1;
	}
	return st;
}

int main (void) {
	int n, k;
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		sum[i] = sum[i-1] + a[i] - k;
	}
	sort(sum,sum+n+1);
	int m = unique(sum,sum+n+1) - (sum+1);

	long long SUM = 0, ans = 0;
	for (int i = 0; i <= n; i++) {
		int pos = bs(SUM,0,m);
		upd(pos,pos,1,0,m,1);
		ans += query(0,pos,0,m,1) - 1;
		SUM += a[i+1] - k;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
// ユークリッドの互除法で最大公約数を求める
ll gcd(ll a,ll b){
  if(b==0) return a;
  return gcd(b,a%b);
}
// 最小公倍数
ll lcm(ll a,ll b){
  return a*b/gcd(a,b);
}

int main()
{
  ll n,m;cin >> n >> m;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];

  ll a0 = a[0];
  int cnts = 0;
  while(a0 % 2 == 0) {
    cnts++;
    a0 /= 2;
  }
  rep1(i,n-1) {
    ll ai = a[i];
    int cnt = 0;
    while(ai % 2 == 0) {
      cnt++;
      ai /= 2;
    }
    if(cnt != cnts) {
      cout << 0 << "\n";
      return 0;
    }
  }

  ll g = a[0] / 2;;

  rep1(i,n-1) {
    g = lcm(g, a[i]/2);
    if(g > m) {
      cout << 0 << "\n";
      return 0;
    }
  }
  
  ll res = ( m/g + 1 ) / 2;
  cout << res << "\n";
  
  
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string.h>
using namespace std;
char s[100010];
int main()
{
	int i,j,l,x=0;
	cin>>s;
	l=strlen(s);
	for(i=0;i<l-1;i++)
		if(s[i]!=s[i+1])
			x++;
	cout<<x<<endl;
}

Measured memory_bytes: 384
void main()
{
    long n = rdElem;
    long[] a = rdRow;

    long[] ball;
    foreach_reverse (i, x; a)
    {
        if (x)
        {
            long[] factor = factors(i+1);
            foreach (f; factor)
            {
                a[f-1] = !a[f-1];
            }
            ball ~= i + 1;
        }
    }

    long m = ball.length;
    m.writeln;
    if (m)
    {
        foreach (i, x; ball)
        {
            x.write;
            if (i == m - 1) writeln;
            else " ".writeln;
        }
    }
}

long[] factors(long x)
{
    long[] result;
    for (long i = 1; i * i <= x; ++i)
    {
        if (x % i == 0)
        {
            result ~= i;
            if (i * i != x) result ~= x / i;
        }
    }
    return result;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 10392
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<LINE<<")"<<endl;
#define vdeb(x) {cout<<#x<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<" (L"<<LINE<<")"<<endl;}
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;

class UnionFind
{   
public:
    static const int N_MAX = 1000000;
    int par[N_MAX];
    int n;
    
    UnionFind(int n)
        : n{n}
    {
        for (int i = 0; i < n; ++i) {
            par[i] = i;
        }
    }

    void init()
    {
        for (int i = 0; i < n; ++i) {
            par[i] = i;
        }
    }
    
    int root(int x)
    {
        if (par[x] == x) {
            return x;
        }
        return par[x] = root(par[x]);
    }
    
    bool same(int x, int y)
    {
        return root(x) == root(y);
    }
    
    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) {
            return;
        }
        par[ry] = root(x);
        return;
    }
    
    int groups()
    {
        int cnt = 0;
        for (int i = 0; i < n; ++i) {
            if (root(i) == i)
            ++cnt;
        }
        return cnt;
    }
};


int main()
{
    ll N, M;
    cin >> N >> M;
    UnionFind uf(N+1);
    ll a, b;
    vll A(M), B(M);
    rep(i, 0, M) {
        cin >> a >> b;
        --a; --b;
        A[i] = a;
        B[i] = b;
    }  

    ll ans = 0;
    rep(i, 0, M) {
        uf.init();
        rep(j, 0, M) {
            if (i == j) continue;
            uf.unite(A[j], B[j]);
        }
        if (! uf.same(A[i], B[i])) {
            ++ans;
        }
    }

    cout << ans << endl;
}


/*
int main()
{
    ll N, M;
    cin >> N >> M;
    UnionFind uf(N);
    ll a, b;
    rep(i, 0, M) {
        cin >> a >> b;
        --a; --b;
        uf.unite(a, b);
    }
    rep(i, 0, N) {
        cout << uf.par[i] << endl;
    }
}
*/

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>


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

ll dp[10010][2][100];
const int mod = 1e9+7;

int main(){
    string s;
    int d;
    cin >> s >> d ;
    int n = s.size();
    dp[0][0][0] = 1;
    
    rep(i,n){
        rep(j,2){
            rep(k,d){
                int x = j ? 9 : s[i] - '0';
                for(int num = 0; num <= x; num++){
                    dp[i+1][j || num < x ][(k+num) % d] += dp[i][j][k];
                    dp[i+1][j || num < x ][(k+num) % d] %= mod;
                }
            }
        }
    }
    ll ans = (dp[n][0][0] + dp[n][1][0]) % mod;
    ans = (ans + mod - 1) % mod;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  double ans = 0.0;
  auto E = [&](int x) { return (double)(x + 1) / 2; };
  rep(i, k) ans += E(p[i]);
  double now = ans;
  for(int i = 0; i + k < n; i++) {
    now += E(p[i + k]) - E(p[i]);
    ans = max(ans, now);
  }
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    if (a>=13) {
        cout<<b<<endl;
    } else if (a>5) {
        cout<<b/2<<endl;
    } else {
        cout<<0<<endl;
    }
}


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

int main(void){
  int N, X; cin >> N >> X;
  vector<int> m(N);
  int ans = 0;
  for(auto& _m: m){
    cin >> _m;
    ans++;
    X -= _m;
  }

  auto cost = *min_element(m.begin(), m.end());

  ans += X/cost;

  cout << ans << endl;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#pragma endregion

void solve() {
    ll k;
    cin >> k;
    cout << 50 << "\n";
    vector<ll> res(50);
    for (int i=0; i<50; i++) {
        res.at(i) = i;
    }
    for (int i=0; i<k%50; i++) {
        for (int j=0; j<50; j++) {
            if (j == i) res.at(j) += 50;
            else res.at(j)--;
        }
    }
    for (int i=0; i<50; i++) {
        cout << res.at(i) + k/50;
        if (i == 49) cout << "\n";
        else cout << " ";
    }
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);
$a = explode(' ', trim(fgets(STDIN)));
$count = array_count_values($a);

for ($i = 1; $i <= $n; $i++) {
    if (!isset($count[$i])) {
        echo "0\n";
        continue;
    }

    echo "{$count[$i]}\n";
}


Measured memory_bytes: 37752
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;
const long long INFL = 1LL<<60;


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

  int n, k; cin >> n >> k;
  vector<ll> v(n);
  rep(i, n) cin >> v[i];

  ll ans = 0;

  for (int l = 0; l <= n; l++) {
    for (int r = 0; r <= n-l; r++) {
      if (l + r > k) continue;
      auto itr = v.begin();
      auto ritr = v.rbegin();
      vector<ll> a;

      rep(i, l) {
        a.push_back(*itr);
        itr++;
      }
      rep(i, r) {
        a.push_back(*ritr);
        ritr++;
      }

      sort(ALL(a), greater<ll>());

      rep(i, k - l - r) {
        if (!a.empty() && a.back() < 0) a.pop_back();
      }

      chmax(ans, SUM(a));
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * A - Payment
 * お店で N 円の商品を買います。
 * 1000 円札のみを使って支払いを行う時、お釣りはいくらになりますか？
 * ただし、必要最小限の枚数の 1000 円札で支払いを行うものとします。
 */
public class Main {

    public static void main(String[] args) {

        // 入力値
        Scanner sc = new Scanner( System.in );
        int n = sc.nextInt();   // 商品の値段

        // 100の位で切り上げ
        int ceilN =  ( int ) ( Math.ceil( ( double ) n / 1000 ) ) * 1000;

        System.out.println( ceilN - n );

        sc.close();
    }
}

Measured memory_bytes: 35924
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<int> X(N);
    REP(i, 0, N) cin >> X[i];

    int ans = 1 << 30;
    REP(i, 1, 100) {
        int h = 0;
        REP(j, 0, N) {
            h += pow(X[j] - i, 2);
        }
        ans = min(ans, h);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
print(s[::2])

Measured memory_bytes: 39536
using System;
using System.Collections;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Threading.Tasks;

class Program
{
	//Main
	static void Main(string[] args)
	{
		//出力準備（AutoFlushを切る）
		var sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
		Console.SetOut(sw);
		//解答
		Solve();
		//出力終了
		Console.Out.Flush();
	}

	static void Solve()
	{
		//読み込む
		int N = int.Parse(Console.ReadLine());
		long[] Ln = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

		long ans = 0;

		//全探索
		for(int i=0; i<N-2; i++){
			for(int j=i+1; j<N-1; j++){
				if(Ln[i] == Ln[j]){
					continue;
				}
				for(int k=j+1; k<N; k++){
					if(Ln[i] == Ln[k] || Ln[j] == Ln[k]){
						continue;
					}
					
					//成立条件
					if(Ln[i] + Ln[j] > Ln[k] && Ln[j] + Ln[k] > Ln[i] && Ln[k] + Ln[i] > Ln[j]){
						ans ++;
					}
				}
			}
		}

		Console.WriteLine(ans);

	}
}



Measured memory_bytes: 19184
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>
// #include <atcoder/all>


using namespace std;
// using namespace atcoder;
using ll = long long;
using ull = unsigned long long;

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


#define REP(i, n) for(ll i = 0; i < n; i++)























int main(){
    int x;
    cin >> x;
    cout << !x << endl;
}


Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;

ll fnc(ll a, ll b, ll c){
    if(a%2 !=0 || b%2 !=0 || c%2 !=0){
        return 0;
    }
    if(a==b && b==c && a==c){
        return -1;
    }
    return fnc((b+c)/2, (a+c)/2, (b+a)/2)+1;
}


int main() {
    ll a,b,c;
    cin>>a>>b>>c;
    cout << fnc(a, b, c) << endl;
    return 0;
}


Measured memory_bytes: 3632
n, m = map(int, input().split())
H = list(map(int, input().split()))
T = [1 for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    if H[a-1] < H[b-1]:
        T[a-1] = 0
    elif H[a-1] > H[b-1]:
        T[b-1] = 0
    else:
        T[a-1] = 0
        T[b-1] = 0
print(T.count(1))


Measured memory_bytes: 20124
/*                    */
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
lint gcd(lint a, lint b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
lint lcm(lint a, lint b) { return a * b / my::gcd(a, b); }
}  // namespace my
/*                    */

int main() {
  lint a, b, c, k;
  cin >> a >> b >> c >> k;
  lint ans = 0;
  if (k < a)
    ans += k;
  else {
    ans += a;
    k -= a;
    k -= b;
    if (k > 0) {
      ans -= k;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3588
#include<stdio.h>

int main(void){
  int i;
  char a[3];
  for(i=0;i<3;i++){
    a[i] = getchar();
  }
  
  for(i=0;i<3;i++){
    if(a[i]=='1'){
      a[i] = '9';
    }else if(a[i]=='9'){
      a[i] = '1';
    }
  }
    
  printf("%s\n",a);
    
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <vector>
#include <numeric>

using namespace std;

string replaceOtherStr(string &replacedStr, string from, string to) {
    const unsigned int pos = replacedStr.find(from);
    const int len = from.length();

    if (pos == string::npos || from.empty()) {
        return replacedStr;
    }

    return replacedStr.replace(pos, len, to);
}


int main() {

    string S;
    cin >> S;

    // 先頭が大文字のA
    if (S.substr(0, 1) != "A") {
        cout << "WA" << endl;
        return 0;
    }

    // 先頭から3文字と末尾から2文字の間にCが一個
    int counter = 0;
    for (int i = 2; i < S.size() - 1; ++i) {
        if (S.substr(i, 1) == "C") {
            ++counter;
        }
    }

    if (counter != 1) {
        cout << "WA" << endl;
        return 0;
    }
    
    // 全部小文字であることを判定
    S = replaceOtherStr(S, "A", "a");
    S = replaceOtherStr(S, "C", "c");

    for (int i = 0; i < S.size(); ++i) {
        char c = S[i];
        if (isupper(c)) {
            cout << "WA" << endl;
            return 0;
        }
    }
    cout << "AC" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

    int S;
    int h=0, m=0, s;

    cin >> S;

    while(S >= 3600){
        S -= 3600;
        h++;
    }
    
    while(S >= 60){
        S -= 60;
        m++;
    }
    
    s = S;

    cout << h << ":" << m << ":" << s << endl;

    return 0;

}


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

#define REPI(i, n) for(int i = 0; i < n; i++)

using ll = long long;
using namespace std;

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

    ll n, t, former, ans = 0; cin >> n >> t >> former;

    REPI(i, n - 1){
        int x; cin >> x;
        ans += min(t, x - former);
        former = x;
    }cout << ans + t;
}


Measured memory_bytes: 256
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n; cin >> n;

    ll ans = LINF;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ll x = i - 1;
            ll y = n / i - 1;
            chmin(ans, x + y);
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256