akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

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

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

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    ll res = 0;
    for(int i = 0; i < N; i++) cin >> a[i];
    for(int i = 1; i < N; i++){
        if(a[i] >= a[i-1]) continue;
        else{
            res += a[i-1] - a[i];
            a[i] = a[i-1];
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 4044
#include <algorithm>
#include <climits>
#include <cstring>
#include <inttypes.h>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <utility>
#include <vector>

using namespace std;

const int cap = 3000;
int N;
double p;
double dp[cap];

int main() {
    scanf("%d", &N);
    fill(dp, dp + N + 1, 0);
    dp[0] = 1;
    for (int i = 1; i <= N; ++i) {
        scanf(" %lf", &p);
        for (int j = i; j > 0; --j) {
            dp[j] = dp[j] * (1 - p) + dp[j - 1] * p;
        }
        dp[0] *= 1 - p;
    }
    double ans = accumulate(dp + N / 2 + 1, dp + N + 1, (double) 0);
    printf("%.10lf\n", ans);
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)

n,m=map(int,input().split())
d={}
dp={}
n=[]

for _ in range(m):
	x,y=map(int,input().split())
	n.append(x)
	try:
		d[x].append(y)
	except:
		d[x]=[y]

def lp(a):
	if a in dp:
		return dp[a]
	if a not in d:
		dp[a]=1
		return 1
	ans=0
	for i in d[a]:
		ans=max(ans,1+lp(i))
	dp[a]=ans
	return ans

p=0
for i in n:
	p=max(p,lp(i))
print(p-1)


Measured memory_bytes: 161624
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define ms(a,b) memset(a,b,sizeof a)
#define F(i,a,b) for (int i=(a);i<=(b);++i)
#define DF(i,a,b) for (int i=(a);i>=(b);--i)
#define int LL
using namespace std;
int read(){
	char ch=getchar(); int w=1,c=0;
	for(;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
	for(;isdigit(ch);ch=getchar()) c=(c<<1)+(c<<3)+(ch^48);
	return w*c;
}
const int M=1e5+10;
int nxt[M],head[M],cnt,w[M],c[M],to[M];
int pre[M],dis[M],edge[M],S,T,n;
bool in[M];
void add(int x,int y,int flow,int v){
	nxt[++cnt]=head[x]; head[x]=cnt; to[cnt]=y; c[cnt]=v; w[cnt]=flow;
}
void jb(int x,int y,int w,int v){
	add(x,y,w,v);
	add(y,x,0,-v);
}
bool spfa(){
	for (int i=S;i<=T;i++){
		dis[i]=-1e16;
		pre[i]=-1;
		edge[i]=0;
	}
	queue<int> q; q.push(S); in[S]=1; dis[S]=0;
	while (!q.empty()){
		int x=q.front(); q.pop(); in[x]=0;
		for (int i=head[x];~i;i=nxt[i]){
			int y=to[i];
			if (w[i] && dis[x]+c[i]>dis[y]){
				dis[y]=dis[x]+c[i];
				pre[y]=x;
				edge[y]=i;
				if (!in[y]) q.push(y),in[y]=1;
			}
		}
	}
	return pre[T]!=-1;
}
int cost,mx;
void maxflow(){
	int fl=1e9;
	for (int i=T;i!=S;i=pre[i]) fl=min(fl,w[edge[i]]);
	cost+=fl*dis[T]; mx+=fl;
	for (int i=T;i!=S;i=pre[i]) w[edge[i]]-=fl,w[edge[i]^1]+=fl;
}
signed main(){
	n=read(); S=0; T=2*n+5; cnt=-1; ms(head,-1);
	for (int i=1;i<=n;i++){
		int x=read(),y=read(),tt=read();
		jb(S,i,tt,0);
		jb(i,2*n+1,tt,x+y);
		jb(i,2*n+2,tt,x-y);
		jb(i,2*n+3,tt,-x+y);
		jb(i,2*n+4,tt,-x-y);
	}
	for (int i=n+1;i<=2*n;i++){
		int x=read(),y=read(),tt=read();
		jb(i,T,tt,0);
		jb(2*n+1,i,tt,-x-y);
		jb(2*n+2,i,tt,-x+y);
		jb(2*n+3,i,tt,x-y);
		jb(2*n+4,i,tt,x+y);
	}
	while (spfa()) maxflow();
	cout<<cost<<"\n";
	return 0;
}



Measured memory_bytes: 4480
fun main(arg: Array<String>) {
    val (N, M) = listOfInt()
    val G = Array<MutableList<Int>>(N) { mutableListOf<Int>() }
    repeat(M) {
        val (a, b) = listOfInt(-1)
        G[a].add(b); G[b].add(a)
    }
    for (n in 0 until N) G[n].sort()
    for (x in 1 until N - 1) {
        if (G[0].binarySearch(x) > -1 && G[x].binarySearch(N - 1) > -1) {
            return println("POSSIBLE")
        }
    }
    println("IMPOSSIBLE")
}
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(vararg deltas: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + deltas[index % deltas.size] }



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

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

  int n,k;cin>>n>>k;
  n -= k;

  if(n==0 || k==1){
    cout<<0<<endl;
  }else{
    cout<<n<<endl;
  }

  return 0;
}


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

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int a, b; cin >> a >> b;
	if(a <= 9 && b <= 9) cout << a * b << endl;
	else cout << -1 << endl;
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
string ss;
while(cin >> ss){
int j=0,k=0;
for(int i=1;i<ss.length()-1;i++){
if(ss[i]=='O'){
if(ss[i+1]=='I'){
if(ss[i-1]=='J')j++;
if(ss[i-1]=='I')k++;
}
}
}
cout << j << "\n" << k << "\n";
}
return 0;
}

Measured memory_bytes: 1192
n = int(input())
o = {""}
for i in range(n):
    a = len(o)
    op, ob = map(str, input().split())
    if op == "find":
        o.add(ob)
        if len(o) > a:
            print("no")
            o.discard(ob)
        else:
            print("yes")
    else:
        o.add(ob)


Measured memory_bytes: 31028
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#define  endl '\n'
#define all(s) s.begin(),s.end()
#define lowbit(x) (x&-x)
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mem(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define pb push_back
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1e9+7;
const double eps=1e-8;
const int inf=0x3f3f3f3f;
const int N=2e5+10;
int a[N],b[N],h[N],ans[N];
int main()
{
	ll x,m,q,k;
	cin>>x;
	map<ll,ll>mp;
	ll now=0;
	while(1){
		mp[now]=now*now*now*now*now;
		if(mp[now]>=2e18) break;
		now++;
	}
	for(ll i=0;i<now;i++){
		for(ll j=0;j<now;j++){
			if(mp[i]-mp[j]==x){
				cout<<i<<' '<<j;
				return 0;
			}
			if(mp[i]+mp[j]==x){
				cout<<i<<' '<<-j;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 3920
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int a[n+1][5],p=0;
    r(i,n+1){
      cin>>a[i][0]>>a[i][1]>>a[i][2]>>a[i][3];
      a[i][4]=a[i][1]*4+a[i][2]*9+a[i][3]*4;
    }
    r(i,n){
      if(a[i][1]<=a[n][0]&&a[i][2]<=a[n][1]&&a[i][3]<=a[n][2]&&a[i][4]<=a[n][3])
        {cout<<a[i][0]<<endl;p++;}
    }
    if(!p)cout<<"NA"<<endl;
  }
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-5;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const int64 mod = 1e9+7;

int main(void) {
	int64 N;
	cin >> N;
	vector<int64> A(N);
	REP(i, N) {
		cin >> A[i];
	}
	int64 res = 0;
	sort(all(A));
	int64 sum = A[0];
	FOR(i, 1, N) {
		if (A[i] > sum*2) res = i;
		sum += A[i];
	}
	cout << N-res << endl;
}


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

//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//#warning check size
const int N = 1 << 20;
vector<pair<int, bool>> G[N];
int d[N];

int bfs(int start, vector<int> finish)
{
	FILL(d, -1);
	deque<int> q;
	d[start] = 0;
	q.push_front(start);
	
	while(!q.empty())
	{
		int v = q.front();
		q.pop_front();
		
		for(auto i: G[v])
		{
			if (d[i.X] == -1 || d[i.X] > d[v] + i.Y)
			{
				d[i.X] = d[v] + i.Y;
				if (i.Y) q.push_back(i.X);
				else q.push_front(i.X);
			}
		}
	}
	
	int ans = INF;
	for(auto i: finish)
		if (d[i] != -1)
			setmin(ans, d[i]);
	if (ans == INF) ans = -1;
	return ans;
}

void add(int u, int v, bool w)
{
	G[u].PB({v, w});
	//cout << u << ' ' << v << ' ' << w << endl;
}

int n, m;
map<int, int> mp[N];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	cin >> n >> m;
	int ptr = n;
	FOR(i, 0, m)
	{
		int u, v, w;
		cin >> u >> v >> w;
		--u; --v;
		if (!mp[u].count(w))
		{
			add(u, ptr, 1);
			add(ptr, u, 0);
			mp[u][w] = ptr++;
		}
		
		if (!mp[v].count(w))
		{
			add(v, ptr, 1);
			add(ptr, v, 0);
			mp[v][w] = ptr++;
		}
		
		add(mp[u][w], mp[v][w], 0);
		add(mp[v][w], mp[u][w], 0);
	}
	
	cout << bfs(0, {n - 1}) << endl;
		
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 115456
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,maxt=0;
char s[105];
bool tf[26];
int main()
{
	scanf("%d %s",&n,s);
	for(int i=1;i<=n;i++)
	{
		int t=0;
		memset(tf,false,sizeof(tf));
		for(int j=0;j<i;j++)
		{
			if(!tf[s[j]-'a'])
				for(int k=i;k<=n;k++)
					if(s[j]==s[k])
					{
						tf[s[j]-'a']=true;
						t++;
						break;
					}
		}
		maxt=max(maxt,t);
	}
	printf("%d",maxt);
	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Solution sol = new Solution();
		sol.solve(in, out);
		out.close();
	}

	private static class Solution {
		private void solve(InputReader in, PrintWriter out) {
			if (in.n().charAt(0) < 96) out.println("A");
			else out.println("a");
		}
	}

	private static class InputReader {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		private InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		private String n() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		private int ni() {
			return Integer.parseInt(n());
		}
	}

}


Measured memory_bytes: 25620
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int a[101010];
int main()
{
	int n;
	long long ans=0;
	scanf("%d",&n);
	a[0]=0;
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	{
		if(a[i-1]&&a[i])
		{
			ans++;
			a[i]--;
		}
		ans+=(a[i]>>1);
		a[i]&=1;
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
  int H,W;
  cin >> H >> W;
  vector<vector<char>> a(H,vector<char>(W));
  vector<vector<bool>> token(H,vector<bool>(W,0));
  for(int i=0;i<H;i++){//input
    for(int j=0;j<W;j++){
      cin >> a.at(i).at(j);
    }
  }
  for(int i=0;i<H;i++){//行を探索
    int cnt =0;
    for(int j=0;j<W;j++){
      if(a.at(i).at(j)=='.') cnt++;
    }
    if(cnt==W){
      for(int j=0;j<W;j++) token.at(i).at(j) =1;
    }
  }
  
  for(int i=0;i<W;i++){
    int cnt=0;
    for(int j=0;j<H;j++){
      if(a.at(j).at(i)=='.') cnt++;
    }
    if(cnt==H){
      for(int j=0;j<H;j++) token.at(j).at(i) =1;
    }
  }
  
  for(int i=0;i<H;i++){
    int cnt=0;//cnt==W（行全部が空白の時の改行処理のため
    for(int j=0;j<W;j++){
      if(token.at(i).at(j)==1){
        cnt++;
        continue;
      }
      cout << a.at(i).at(j);        
    }
    if(cnt!=W) cout << endl;   	
  }
}




Measured memory_bytes: 256
from heapq import heapify, heappush, heappop


N, M = map(int, input().split())
lst_A = list(map(int, input().split()))


hq = []
# heapify(hq)
for a in lst_A:
    heappush(hq, [-a, 1])
for _ in range(M):
    b, c = map(int, input().split())
    heappush(hq, [-c, b])

ans = 0
while N > 0:
    c, b = heappop(hq)
    c *= -1
    if b < N:
        ans += c * b
        N -= b
    else:
        ans += c * N
        N = 0


print(ans)


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

int main()
{
ll num=0;
ll n ;
cin >> n ;
ll i=0;
cout << i << endl;
string s ;
cin >> s ;
char c=s[0];
if(c=='V')return 0;
ll st=0,ed=n-1;
i=(st+ed)/2 +1;

while(num<19){
  cout << i << endl;
  cin >> s ;
  if(s[0]=='V')break;
  char cc=c;
  if((i-st)%2==0){
    if(cc=='M')cc='F';
    else cc='M';
  }
  if(s[0]==cc){
    ed=i-1;
  }
  else{
    st=i;
    c=s[0];
  }
  i=(st+ed)/2 +1;
  num++;
}

return 0;
}


Measured memory_bytes: 852
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define     loop(n,i,a)     for(int i=a;i<n;i++)
#define     loopR(n,i,a)    for(int i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=2e6+10,oo=0x3f3f3f3f,MOD=998244353;
const double PI = acos(-1);

void solve(){
    int n;
    cin>>n;
    map<string,int>mp;
    string all[]={"AC","WA","TLE","RE"};
    loop(n,i,0){
        string x;
        cin>>x;
        mp[x]++;
    }
    loop(4,i,0)
        cout<<all[i]<<" x "<<mp[all[i]]<<Endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();
}

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

using namespace std;

vector<int> getSuffixArray(const auto& str, int alphabetSize){
	const int n = str.size();
	vector<pair<int, int>> vp(n);
	vector<int> rank(n), cnt(alphabetSize, 0);
	for(int i=0;i<n;i++) cnt[str[i]]++;
	for(int i=1;i<alphabetSize;i++) cnt[i] += cnt[i-1];
	for(int i=0;i<n;i++){
		rank[i] = vp[i].first = cnt[str[i]];
		vp[i].second = i;
	}
	sort(vp.begin(), vp.end());
	for(int h=1;h<n;h*=2){
		auto cur = vp.begin();
		while(cur != vp.end()){
			auto end = cur;
			int key = rank[cur->second];
			while(end != vp.end() && rank[end->second] == key){
				end->first = end->second + h < n ? rank[end->second + h] : -1;
				end++;
			}
			int s = distance(vp.begin(), cur), e = distance(vp.begin(), end);
			if(e - s > 1){
				sort(cur, end);
				rank[vp[e-1].second] = key;
				for(int i=e-2;i>=s;i--){
					rank[vp[i].second] = (vp[i].first == vp[i+1].first ? rank[vp[i+1].second] : key - (e-1-i));
				}
			}
			cur = end;
		}
	}
    vector<int> res(n);
	for(int i=0;i<n;i++) res[i] = vp[i].second;
    return res;
}

vector<int> getHeightArray(const vector<int> &SA, const auto &str){
	int n = SA.size();
	vector<int> rev(n);
	for(int i=0;i<n;i++) rev[SA[i]] = i;
    vector<int> res(n, 0);
	int prev = 0;
	for(int i=0;i<n;i++){
		int idx = rev[i];
		if(idx == n-1){ res[idx] = prev = 0; continue; }
		idx = SA[idx+1];
		int t = prev;
		while(max(i, idx)+t < n && str[i+t] == str[idx+t]) t++;
		res[rev[i]] = t;
		prev = max(0, t-1);
	}
    return res;
}

int main(){
    string S; cin >> S;
    const int N = S.size();
    auto sa = getSuffixArray(S, 256);
    auto h = getHeightArray(sa, S);
    long long res = N - sa[0];
    for(int i=0;i<N-1;i++){
        res += N - sa[i+1] - h[i];
    }
    cout << res << endl;
}

Measured memory_bytes: 11676
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;

int main(){
    int A, B;
    cin >> A >> B;
    int tmp = max(A + B, A - B);
    tmp = max(tmp, A * B);
    cout << tmp << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>

#define SENTINEL (1000000001)
#define putChar(c) ; *p = (c); ++p;

int c = 0;
int S[500000];
int L[250001];
int R[250001];
char str[5500010];
char *p = str;

static void Merge(int A[], int left, int mid, int right);
static void MergeSort(int A[], int left, int right);
static int getNum(void);
static void putNum(int n);

int main(void) {
	register int i;
	int n;
	
	fread(str, sizeof(char), 5500000, stdin);
	n = getNum();
	for (i = 0; i < n; ++i) {
		S[i] = getNum();
	}
	
	MergeSort(S, 0, n);
	
	--n;
	p = str;
	for (i = 0; i < n; ++i) {
		putNum(S[i]);
		putChar( ' ' );
	}
	putNum(S[i]);
	putChar( '\n' );
	
	putNum(c);
	putChar( '\0' );
	
	puts(str);

	return 0;
}

int getNum(void) {
	int n = 0;
	while ((*p >= '0') && (*p <= '9')) {
		n = n * 10 + (int)(*p - '0');
		++p;
	} 
	++p;
	return n;
}

void putNum(int n) {
	int d = n / 10;
	if (n < 10) {
		putChar( '0' + (char)n );
		return;
	}
	if (d) putNum(d);
	putChar( '0' + (char)(n % 10) );
}

void Merge(int A[], int left, int mid, int right) {
	int i, j, k;
	int n1 = mid - left;
	int n2 = right - mid;
	memcpy(L, A + left, n1 * sizeof(int));
	memcpy(R, A + mid, n2 * sizeof(int));
	L[n1] = R[n2] = SENTINEL;
	i = j = 0;
	for (k = left; k < right; ++k) {
		++c;
		if (L[i] <= R[j]) {
			A[k] = L[i];
			++i;
		} else {
			A[k] = R[j];
			++j;
		}
	}
}

void MergeSort(int A[], int left, int right) {
	int mid;
	if (left + 1 < right) {
		mid = (left + right) / 2;
		MergeSort(A, left, mid);
		MergeSort(A, mid, right);
		Merge(A, left, mid, right);
	}
}

Measured memory_bytes: 9216
#include <iostream>

using namespace std;

int main(){
    int n;
    while(cin >> n && n){
        int ret=0;
        for(int i=2;i<=n;i++){
            if(i%2==0){
                if(n%i != 0 && n*2%i ==0 && (double)n/i-i/2>0) ret++;
            }else{
                if(n%i == 0 && n/i - i/2 > 0) ret++;
            }
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 0
# 2019-11-13 01:43:55(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n = int(sys.stdin.readline().rstrip())
    v = [int(x) for x in sys.stdin.readline().split()]
    c = [int(x) for x in sys.stdin.readline().split()]

    total = 0
    for i in range(n):
        total += max(0, v[i] - c[i])
    
    print(total)



if __name__ == "__main__":
    main()


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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N,A,B;
    cin >> N >> A >> B;
    cout << min(A*N,B) << endl;

    return 0;
}

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

int main() {
  int n,m;
  cin >>n >>m;
  vector<int> h(n);
  rep(i,n) cin >>h[i];
  int num[n] = {0};
  rep(i,m){
    int a,b;
    cin >>a >>b;
    a--; 
    b--;
    if(h[a]>h[b]){
      num[a]++;
      num[b] -= 1e5;
    }
    else if(h[a]<h[b]){
      num[b]++;
      num[a] -= 1e5;
    }
    else {
      num[a] -= 1e5;
      num[b] -= 1e5;
    }
  }
  int cnt = 0;
  for(int i  = 0; i<n; i++){
    if(num[i]>=0) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 4024
n,x=map(int,input().split())
a=[1]
p=[1]
for i in range(n):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)
#print(a)

def f(N, X): # X <= 0 や X > a_N を許容し解説本文から簡略化
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1 + a[N-1]:
        return f(N-1, X-1)
    else:
        return p[N-1] + 1 + f(N-1, X-2-a[N-1])

print(f(n, x))

Measured memory_bytes: 38256
#include <iostream>

using namespace std;

int main(){
    int a,b,i,j;
    cin>>a>>b;
    int arr[13];
    arr[0]=2;
    arr[1]=3;
    arr[2]=4;
    arr[3]=5;
    arr[4]=6;
    arr[5]=7;
    arr[6]=8;
    arr[7]=9;
    arr[8]=10;
    arr[9]=11;
    arr[10]=12;
    arr[11]=13;
    arr[12]=14;
    for (i=0; i<=12;++i){
        if (arr[i]==a){
            break;
        }
        else if (arr[i]!=a){
            continue;
        }
    }
    for (j=0; j<=12; ++j){
        if (arr[j]==b){
            break;
        }
        else if (arr[j]!=b){
            continue;
        }
    }
    if (i>j){
        cout<<"Alice\n";
    }
    else if (i<j){
        cout<<"Bob\n";
    }
    else if (i==j){
        cout<<"Draw\n";
    }
    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int w,n,m,a[10],p[10];
bool f[10];
queue<int> s;
signed main(){
//	freopen("date.in","r",stdin);
//	freopen("date.out","w",stdout);
	scanf("%d%d",&w,&n);
	for(int i = 1; i <= n; i++){
		scanf("%d",&a[i]);
		f[a[i]] = 1;
	}
	for(int i = 0; i <= 9; i++)if(!f[i]) p[++m] = i;
	for(int i = 1; i <= m; i++)s.push(p[i]);
	while(1){
		int ps = s.front();
		s.pop();
		if(ps >= w){
			printf("%d",ps);
			return 0;
		}
		for(int i = 1; i <= m; i++){
			int fs = ps * 10 + p[i];
			s.push(fs);
		}
	}
}


Measured memory_bytes: 4040
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
typedef pair<int,pair<int, int>> P1;

using Graph = vector<vector<int>>;

int N;
int dfs(int N){
  if(N == 1) return 1;
  return dfs(N/2) * 2 + 1;
}

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  cin >> N;
  cout << dfs(N) << endl;

}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define LL long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)
#define YES "Yes"
#define NO "No"

using namespace std;

typedef pair<int, int> P;

class ADuplexPrinting {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        LL n;
        cin>>n;
        cout<<(LL)ceil(n/2.0);
    }
};

int main() {
	ADuplexPrinting solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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


int main() {
    vector<vector<int>> A(3, vector<int>(3));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> A[i][j];
        }
    }

    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int b;
        cin >> b;
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (b == A[j][k]) {
                    A[j][k] = -1;
                    break;
                }
            }
        }
    }

    for (int i = 0; i < 3; i++) {
        if (A[i][0] == -1 && A[i][1] == -1 && A[i][2] == -1) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    for (int i = 0; i < 3; i++) {
        if (A[0][i] == -1 && A[1][i] == -1 && A[2][i] == -1) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    if (A[0][0] == -1 && A[1][1] == -1 && A[2][2] == -1) {
        cout << "Yes" << endl;
        return 0;
    }

    if (A[2][0] == -1 && A[1][1] == -1 && A[0][2] == -1) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
stations = []
for i in range(N-1):
    stations.append(nl())

times = [0] * N
for i in range(N-1):
    C, S, F = stations[i]
    t = S + C
    for j in range(i+1, N-1):
        C, S, F = stations[j]
        w = t // F * F
        if t % F > 0:
            w += F
        w = max(S, w)
        t = w + C
    print(t)

print(0)



Measured memory_bytes: 3188
package main

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

// I/O
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) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

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 (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	sx, sy, tx, ty := sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()
	fmt.Fprint(wtr, strings.Repeat("U", ty-sy))
	fmt.Fprint(wtr, strings.Repeat("R", tx-sx))

	fmt.Fprint(wtr, strings.Repeat("D", ty-sy))
	fmt.Fprint(wtr, strings.Repeat("L", tx-sx))

	fmt.Fprint(wtr, "L")
	fmt.Fprint(wtr, strings.Repeat("U", ty-sy+1))
	fmt.Fprint(wtr, strings.Repeat("R", tx-sx+1))
	fmt.Fprint(wtr, "D")

	fmt.Fprint(wtr, "R")
	fmt.Fprint(wtr, strings.Repeat("D", ty-sy+1))
	fmt.Fprint(wtr, strings.Repeat("L", tx-sx+1))
	fmt.Fprint(wtr, "U")
	fmt.Fprintln(wtr)

	wtr.Flush()
}


Measured memory_bytes: 640
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,ab,x,y;
    cin >> a >> b >> ab >> x >> y;
    int ans = 0;
    if(x>y){
        swap(a,b);
        swap(x,y);
    }
    {
        int tmp = 0;
        tmp = a*x+b*y;
        ans = tmp;
    }
    {
        int tmp = 0;
        tmp = ab*x*2 + b*(y-x);
        ans = min(ans,tmp);
    }
    {
        int tmp = 0;
        tmp = ab*x*2 + ab*2*(y-x);
        ans = min(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import Control.Applicative ((<$>))
import Control.Monad (replicateM, unless)
import Data.Map (Map)
import qualified Data.Map as M

main :: IO ()
main = do
  n <- readLn
  unless (n == 0) $ do
    tbl <- M.fromList <$> map f <$> replicateM n (words <$> getLine)
    m <- readLn
    solve tbl <$> replicateM m (head <$> getLine) >>= putStrLn
    main
  where f [a, b] = (head a, head b)

solve :: Map Char Char -> String -> String
solve tbl = map f
  where f c = maybe c id $ M.lookup c tbl



Measured memory_bytes: 27168
while 1:
	try:
		N,M = map(int,raw_input().split())
		dp = [[0]*(M+1) for i in range(3)]
		bidols = [[raw_input()]+map(int,raw_input().split()) for i in range(N)]
		for bidol in bidols:
			C = bidol[1]
			if C > M:
				continue
			for i in range(3):
				dp[i][C] = max(dp[i][C],bidol[i+2])
				for j in range(M-C+1):
					if dp[i][j]:
						dp[i][j+C] = max(dp[i][j+C],dp[i][j]+bidol[i+2])
		print max(max(dp[0]),max(dp[1]),max(dp[2]))
	except:
		break

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

int main(){
  int n;
  cin >> n;
  int y = n%10;
  
  if(y == 3) cout << "bon" << endl;
  else if(y==0 or y==1 or y==6 or y==8) cout << "pon" << endl;
  else cout << "hon" << endl;
  
  return 0;
}

Measured memory_bytes: 3636
import java.util.*;
public class Main {
	public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
        if(a == 0){
        	System.out.println(1);
        }
        else if(b == 0){
        	System.out.println(2);
        }
        else if(c == 0){
        	System.out.println(3);
        }
        else if(d == 0){
        	System.out.println(4);
        }
        else if(e == 0){
        	System.out.println(5);
        }
        
    }
}

Measured memory_bytes: 35716
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }

    friend std::istream &operator>>(std::istream &in, mint &o) {
        ll a;
        in >> a;
        o = a;
        return in;
    }

    friend std::ostream &operator<<(std::ostream &out, const mint &o) {
        out << o.x;
        return out;
    }

};


int main() {
    ll n;
    cin >> n;
    vector<mint> dp(n + 1), sum(n + 1);
    dp[0] = 1;
    sum[1] = 1;
    dp[1] = 1;
    sum[2] = 2;
    for (ll i = 2; i < n; i++) {
        dp[i] = (dp[i - 1] + sum[i - 2]);
        sum[i + 1] = sum[i] + dp[i];
    }

    mint ans = 0;

    for (ll i = 0; i < n; i++) {
        if (i <= n - 3) ans += dp[i] * (n * (n - 2) + i + 3);
        else if (i == n - 2) ans += dp[i] * n * (n - 1);
        else if (i == n - 1) ans += dp[i] * n;
    }

    cout << ans << endl;
}



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

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define pb push_back
#define odd(x) ((x)&1)
#define even(x) (!odd(x))
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(auto i=0;i<n;++i)
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define TEST_CASE int tc;cin>>tc;while(tc--)

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

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define JD

/******************************************************************************************************************************/

int main()
{
    FASTIO

    #ifndef JD
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif

    int n,ans=0;
    cin>>n;
    vii v(n);
    rep(i,n) cin>>v[i];

    for(int i=0;i<n;++i){
        for(int j=i+1;j<n;++j){
            for(int k=j+1;k<n;++k){
                if(v[i]==v[j]||v[j]==v[k]||v[k]==v[i]) continue;
                if(v[i]+v[j]>v[k]&&v[i]+v[k]>v[j]&&v[j]+v[k]>v[i])
                    ++ans;
            }
        }
    }

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
using namespace std;
typedef long long LL;
//#define _USE_MATH_DEFINES

int main(void) {
	LL a, b, c, num = 1, sum = 0;
	cin >> a >> b;
	c = b - a;
	for (int i = 1; i < c; i++) {
		sum += num;
		num++;
	}
	cout << sum - a << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.List;
import java.util.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author teiwa
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        String AC_STRING = "AC";

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int Q = in.nextInt();
            String S = in.next();
            int[] startArray = new int[Q];
            int[] endArray = new int[Q];
            for (int i = 0; i < Q; i++) {
                startArray[i] = in.nextInt();
                endArray[i] = in.nextInt();
            }

            List<Integer> countSum = new ArrayList<>();
            for (int i = 0; i < AC_STRING.length() - 1; i++) {
                countSum.add(0);
            }
            // make pos list

            String target = S;
            int counter = 0;
            for (int j = AC_STRING.length() - 1; j < target.length(); j++) {
                if (target.substring(j - AC_STRING.length() + 1, j + 1).equals(AC_STRING)) {
                    counter++;
                }
                countSum.add(counter);
            }
            //System.out.println(countSum);
            // count
            for (int i = 0; i < Q; i++) {
                out.println(countSum.get(endArray[i] - 1) - countSum.get(startArray[i] - 1));
            }
        }

    }
}



Measured memory_bytes: 79480
using System;
 
namespace tes
{
    class Program
    {
        public static void Main()
        {
            String str = Console.ReadLine();
            String[] num = str.Split();
            for (int i = 0; i < num.Length; i++)
            {
                for (int j = i+1; j < num.Length; j++)
                {
                    if (int.Parse(num[i]) > int.Parse(num[j]))
                    {
                        String temp = num[i];
                        num[i] = num[j];
                        num[j] = temp;
                    }
                }
            }
 
            for (int i = 0; i < num.Length; i++)
            {
                if (i != 0)
                {
                    Console.Write(" " + num[i]);
                }
                else
                {
                    Console.Write("" + num[i]);
                }
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 5316
import java.util.*;
import java.util.Collections;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int min = Integer.MAX_VALUE;
    int cnt = 0;
    int N = sc.nextInt();
    for (int i = 0; i < N; i++) {
      cnt = 0;
      int A = sc.nextInt();
      while (A % 2 == 0) {
        cnt++;
        A /= 2;
      }
      min = Math.min(min, cnt);
    }
    System.out.println(min);
  }

  public static void primeFactorization(int num) {
    int Z = 0;
    for (int i = 2; num > i; i++) {
      while (num % i == 0) {
        System.out.println(i);
        num /= i;
        Z = num;
      }
    }
    System.out.println(Z);
  }

  public static boolean isPrime(int num) {
    if (num < 2)
      return false;
    else if (num == 2)
      return true;
    else if (num % 2 == 0)
      return false;

    for (int i = 3; i < num; i += 2) {
      if (num % i == 0) {
        return false;
      }
    }
    return true;
  }
}


Measured memory_bytes: 21844
#include<stdio.h>
int main()
{
int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
if(a==c && a!=b) printf("Yes");
else if(a==b && c!=b) printf("Yes");
else if(b==c && a!=c) printf("Yes");
else printf("No");
return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main() {
    string S; cin >> S;
    int a_cnt = 0, b_cnt = 0, c_cnt = 0;
    for (char c : S) {
        if (c == 'a') a_cnt++;
        else if (c == 'b') b_cnt++;
        else c_cnt++;
    }
    if (a_cnt == 1 && b_cnt == 1 && c_cnt == 1) printf("%s\n", "Yes");
    else printf("%s\n", "No");
}

Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>

using namespace std;

#define INF 40000000000000007

/*use prepaired combination*/
vector< pair<long long, long long > > A,B;

long long v[40][2];
int n;
long long w;

int main(){
  cin >> n >> w;
  for(int i = 0; i < n ; i++){
    cin >> v[i][1] >> v[i][0];//ここ注意。これで重さ順のソートが楽になる。
  }
  int a = min(20, n);
  int b = max(n-20, 0);
  A.push_back(make_pair(0,0));
  B.push_back(make_pair(0,0));
  for(int i = 0; i < a; i++){
    for(int j = 0; j < pow(2, i); j++){
      A.push_back(make_pair(A[j].first+v[i][0], A[j].second+v[i][1]));
    }
  }
  for(int i = 0; i < b; i++){
    for(int j = 0; j < pow(2, i); j++){
      B.push_back(make_pair(B[j].first+v[i+a][0], B[j].second+v[i+a][1]));
    }
  }
  sort(A.begin(), A.end());
  long long res = 0;
  int m = 1;
  for(int i = 1; i < 1 << a; i++){
    if(A[m-1].second < A[i].second){
      A[m++] = A[i];
    }
  }

  for(int i = 0; i < B.size(); i++){
    if(B[i].first <= w){
      const pair<long long, long long> r = make_pair(w - B[i].first, INF);
      auto tv = (lower_bound(A.begin() , A.begin()+m, r) - 1);
      long long t = tv->second;
      res = max(res, B[i].second + t);
    }
  }

  cout << res << endl;
}



Measured memory_bytes: 43992