stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

string s[200005];

int main()

{

    ios::sync_with_stdio(false);

    int n;

    cin>>n;

    for(int i=0;i<n;i++)

    {

        cin>>s[i];

    }

    sort(s,s+n);

    string s1="";

    long long ans=0;

    for(int i=0;i<n;i++)

    {

        if(s1!=s[i])

        {

            ans++;

            s1=s[i];

        }

    }

    cout<<ans;

}


// Faster C++ solution for the same problem (measured speedup: 8.234905889027214x):
#include<set>

#include<string>

#include<iostream>

using namespace std;



int main() {

	set<string> good;

	int n = 0;

	string str;

	cin >> n;

	for (int i = 0; i < n; i++) {

		cin >> str;

		good.insert(str);

	}

	cout << good.size() << endl;

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

string s[200005];

int main()

{

    ios::sync_with_stdio(false);

    int n;

    cin>>n;

    for(int i=0;i<n;i++)

    {

        cin>>s[i];

    }

    sort(s,s+n);

    string s1="";

    long long ans=0;

    for(int i=0;i<n;i++)

    {

        if(s1!=s[i])

        {

            ans++;

            s1=s[i];

        }

    }

    cout<<ans;

}


// Faster C++ solution for the same problem (measured speedup: 8.234859250372137x):
#include <iostream>

#include <string>

#include <set>



using namespace std;



int main(){

    int n = 0;

    set<string>fruit;

    cin >> n;

    for(int i = 0; i < n; i++){

        string s;

        cin >> s;

        

        fruit.insert(s);

    }

    cout << fruit.size() << endl;

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

string s[200005];

int main()

{

    ios::sync_with_stdio(false);

    int n;

    cin>>n;

    for(int i=0;i<n;i++)

    {

        cin>>s[i];

    }

    sort(s,s+n);

    string s1="";

    long long ans=0;

    for(int i=0;i<n;i++)

    {

        if(s1!=s[i])

        {

            ans++;

            s1=s[i];

        }

    }

    cout<<ans;

}


// Faster C++ solution for the same problem (measured speedup: 8.231489385566848x):
#include<cstdio>

#include<iostream>

#include<cstdlib>

#include<iomanip>

#include<fstream>

#include<vector>

#include<set>

using namespace  std;

int main()

{

	char in[11] ;

	set <string>a;

	int time = 0;

	cin >> time;

	string str;

	

	while (time>0)

	{

		cin >> in;

		a.insert(in);

		time--;

	}

	int b=a.size();

	cout << b << endl;





	

	

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

string s[200005];

int main()

{

    ios::sync_with_stdio(false);

    int n;

    cin>>n;

    for(int i=0;i<n;i++)

    {

        cin>>s[i];

    }

    sort(s,s+n);

    string s1="";

    long long ans=0;

    for(int i=0;i<n;i++)

    {

        if(s1!=s[i])

        {

            ans++;

            s1=s[i];

        }

    }

    cout<<ans;

}


// Faster C++ solution for the same problem (measured speedup: 8.123079942932417x):
//

//	Created by shamim_nik

//



#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

using namespace std;



typedef long long ll;

typedef tree<int,null_type,less<int>,rb_tree_tag,

		tree_order_statistics_node_update> indexed_set;



#define br printf("\n")

#define pi acos(-1)



int main () {

	ios::sync_with_stdio(0);

	cin.tie(0);



//	freopen("input.txt", "r", stdin);

//	freopen("output.txt", "w", stdout);



	int t;

	cin >> t;

	map<string, int> doc;

	while(t--) {

		string str;

		 cin >> str;

		 doc[str]++;

	 }

	 cout << doc.size() << endl;

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

string s[200005];

int main()

{

    ios::sync_with_stdio(false);

    int n;

    cin>>n;

    for(int i=0;i<n;i++)

    {

        cin>>s[i];

    }

    sort(s,s+n);

    string s1="";

    long long ans=0;

    for(int i=0;i<n;i++)

    {

        if(s1!=s[i])

        {

            ans++;

            s1=s[i];

        }

    }

    cout<<ans;

}


// Faster C++ solution for the same problem (measured speedup: 8.128940729544517x):
#include <bits/stdc++.h>

using namespace std;



int N;

string str;

map<string, int> m;



int main() {

    

    ios_base::sync_with_stdio(false);

    cin >> N;

    while(N--) {

        cin >> str;

        m[str]++;

    }

    cout << m.size();

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

string s[200005];

int main()

{

    ios::sync_with_stdio(false);

    int n;

    cin>>n;

    for(int i=0;i<n;i++)

    {

        cin>>s[i];

    }

    sort(s,s+n);

    string s1="";

    long long ans=0;

    for(int i=0;i<n;i++)

    {

        if(s1!=s[i])

        {

            ans++;

            s1=s[i];

        }

    }

    cout<<ans;

}


// Faster C++ solution for the same problem (measured speedup: 8.231848461384834x):
#include <bits/stdc++.h>

#include <cmath>

using namespace std;

typedef long long ll;



ll tc, bil, r;





int main(){

	scanf("%lld", &tc);

	map<string, int> m;

	ll jaw = 0;

	for(int k = 1; k<= tc; k++){

		string s;

		cin >> s;

		if(m[s] == 0){

			jaw++;

			m[s]++;

		}

	}

	printf("%lld\n",jaw);

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

string s[200005];

int main()

{

    ios::sync_with_stdio(false);

    int n;

    cin>>n;

    for(int i=0;i<n;i++)

    {

        cin>>s[i];

    }

    sort(s,s+n);

    string s1="";

    long long ans=0;

    for(int i=0;i<n;i++)

    {

        if(s1!=s[i])

        {

            ans++;

            s1=s[i];

        }

    }

    cout<<ans;

}


// Faster C++ solution for the same problem (measured speedup: 8.238480990068627x):
#include<bits/stdc++.h>

using namespace std ;



int main() {

	int  n;

	cin >> n;

	string str;

	map<string,bool>m;



	for(int i=1;i<=n;i++){

		cin >> str ;

		m[str]=1;

	}

		cout <<m.size() << '\n' ;

	}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

string s[200005];

int main()

{

    ios::sync_with_stdio(false);

    int n;

    cin>>n;

    for(int i=0;i<n;i++)

    {

        cin>>s[i];

    }

    sort(s,s+n);

    string s1="";

    long long ans=0;

    for(int i=0;i<n;i++)

    {

        if(s1!=s[i])

        {

            ans++;

            s1=s[i];

        }

    }

    cout<<ans;

}


// Faster C++ solution for the same problem (measured speedup: 8.21647217821611x):
#include<bits/stdc++.h>

#define mp make_pair

#define pb push_back

typedef long long ll;

using namespace std;

map<string,bool> k;

int main()

{

	ios_base::sync_with_stdio();

	cin.tie(0);cout.tie(0);

	ll n;

	string s;

	cin >> n;

	ll ans=0;

	while(n--){

		cin >> s;

		if(!k[s]){

			ans++;

			k[s]=true;

		}

	}

	cout << ans << endl;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<string>

using namespace std;

int n,i,s;

string a[200001];

int main(){

	cin>>n;

	for(i=0;i<n;i++) cin>>a[i];

	sort(a,a+n);

	s=1;

	for(i=1;i<n;i++){

		if(a[i]!=a[i-1]) s++;

	}

	cout<<s<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 8.093748496277138x):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;



map<string,bool> mp;

int main()

{

	ios::sync_with_stdio(false);

	int n,ans=0;

	cin>>n;

	for(int i=1;i<=n;i++)

	{

		string a;

		cin>>a;

		if(!mp[a]) ans++,mp[a]=true;

	}

	cout<<ans<<endl;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<string>

using namespace std;

int n,i,s;

string a[200001];

int main(){

	cin>>n;

	for(i=0;i<n;i++) cin>>a[i];

	sort(a,a+n);

	s=1;

	for(i=1;i<n;i++){

		if(a[i]!=a[i-1]) s++;

	}

	cout<<s<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 8.207648908447823x):
#include<bits/stdc++.h>

using namespace std;

int main()

{

    set<string>a;



    int i,j,n,p,q,r,k,y,l;

    string b;

    cin>>n;

    for(i=0;i<n;i++)

    { cin>>b;

     a.insert(b);

    }

    cout<<a.size()<<endl;

return 0;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<string>

using namespace std;

int n,i,s;

string a[200001];

int main(){

	cin>>n;

	for(i=0;i<n;i++) cin>>a[i];

	sort(a,a+n);

	s=1;

	for(i=1;i<n;i++){

		if(a[i]!=a[i-1]) s++;

	}

	cout<<s<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 8.159759080732178x):
#include<iostream>

#include<string>

#include<set>

using namespace std;



int main() {

	set<string> s;

	int n;

	string temp;

	cin >> n;

	cin.ignore();

	for (int i = 0; i < n; i++) {

		getline(cin, temp);

		s.insert(temp);

	}

	cout << s.size() << endl;



	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<string>

using namespace std;

int n,i,s;

string a[200001];

int main(){

	cin>>n;

	for(i=0;i<n;i++) cin>>a[i];

	sort(a,a+n);

	s=1;

	for(i=1;i<n;i++){

		if(a[i]!=a[i-1]) s++;

	}

	cout<<s<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 8.208448219757601x):
#include<iostream>

using namespace std;

#include<string>

#include<set>





int main() {

	int n = 0;

	set<string> st;

	cin >> n;

	while (n--) {

		string str;

		cin >> str;

		st.insert(str);

	}

	cout << st.size() << endl;

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<string>

using namespace std;

int n,i,s;

string a[200001];

int main(){

	cin>>n;

	for(i=0;i<n;i++) cin>>a[i];

	sort(a,a+n);

	s=1;

	for(i=1;i<n;i++){

		if(a[i]!=a[i-1]) s++;

	}

	cout<<s<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 8.208728835652723x):
#include<iostream>

#include<set>

#include<string>

using namespace std;





int main() {

	int n = 0;

	cin >> n;

	set<string> s;

	for (int i = 0; i < n; i++) {

		char str[100] = "";

		cin >> str;

		s.insert(str);

	}

	cout << s.size() << endl;

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<string>

using namespace std;

int n,i,s;

string a[200001];

int main(){

	cin>>n;

	for(i=0;i<n;i++) cin>>a[i];

	sort(a,a+n);

	s=1;

	for(i=1;i<n;i++){

		if(a[i]!=a[i-1]) s++;

	}

	cout<<s<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 8.207648908447823x):
#include <iostream>

#include <set>

using namespace std;



int main()

{

	set<string> s;

	string str;

	int n;

	cin>>n;

	for(int i=0;i<n;i++)

	{

		cin>>str;

	    s.insert(str);

    }

    cout<<s.size()<<endl;

	

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<string>

using namespace std;

int n,i,s;

string a[200001];

int main(){

	cin>>n;

	for(i=0;i<n;i++) cin>>a[i];

	sort(a,a+n);

	s=1;

	for(i=1;i<n;i++){

		if(a[i]!=a[i-1]) s++;

	}

	cout<<s<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 8.217824270411638x):
#include<iostream>

#include<set>

#include<string>

using namespace std;

int main()

{

	set<string>st;

	int n = 0;

	cin >> n;

	

	for (int i = 0; i < n; i++)

	{

		string s;

		cin >> s;



		st.insert(s);

	}

	cout << st.size() << '\n';



	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<string>

using namespace std;

int n,i,s;

string a[200001];

int main(){

	cin>>n;

	for(i=0;i<n;i++) cin>>a[i];

	sort(a,a+n);

	s=1;

	for(i=1;i<n;i++){

		if(a[i]!=a[i-1]) s++;

	}

	cout<<s<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 8.223054833341296x):
#include <iostream>

#include <algorithm>

#include <set>

#include <string>

#pragma warning (disable:4996)

using namespace std;





int main() {

	set<string> s;

	int n;

	string a;

	cin >> n;

	for (int i = 0; i < n; i++) {

		cin >> a;

		s.insert(a);

	}

	cout << s.size();



}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<string>

using namespace std;

int n,i,s;

string a[200001];

int main(){

	cin>>n;

	for(i=0;i<n;i++) cin>>a[i];

	sort(a,a+n);

	s=1;

	for(i=1;i<n;i++){

		if(a[i]!=a[i-1]) s++;

	}

	cout<<s<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 8.2152446225801x):
#include<iostream>

#include<vector>

#include<algorithm>

using namespace std;



int main()

{

    vector<string> names;

      string buffer;

    long n, i;

    int flag=0,ctr=0;

    cin >> n;

    for (i = 0; i < n; i++)

    {

        cin >> buffer;

        names.push_back(buffer);

    }

    sort(names.begin(), names.end());

    for(i=0;i<n-1;i++)

    {



        if(names[i]==names[i+1])

        {

            flag=1;



        }

        else

            ctr++;



    }



    if(flag == 1)

        cout << ctr+1;

    else

        cout << ctr+1;



}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<string>

using namespace std;

int n,i,s;

string a[200001];

int main(){

	cin>>n;

	for(i=0;i<n;i++) cin>>a[i];

	sort(a,a+n);

	s=1;

	for(i=1;i<n;i++){

		if(a[i]!=a[i-1]) s++;

	}

	cout<<s<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 8.203304722181612x):
#include<bits/stdc++.h>

using namespace std;



int main(){

	int N;

	cin >> N;

	int Size = ceil(sqrt(N));

	vector<string> table[Size];

	int sum = 0;

	while(N-- > 0){

        string S;

        cin >> S;



        int temp = 0;

        for(int a = 0; a < S.size(); a++){

            temp += S[a] - 'a' + 1;

            temp *= 26;

            temp %= Size;

        }



        int found = false;

        for(int a = 0; a < table[temp].size(); a++){

            if(S.compare(table[temp][a]) == 0){

                found = true;

                break;

            }

        }



        if(!found){

            sum++;

            table[temp].push_back(S);

        }

	}



	cout << sum << endl;

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <unordered_map>

#include <iterator>

#include <algorithm>

#include <string>

#include <functional>

#include <vector>



using namespace std;



int main(void)

{

  int n;

  cin >> n;

  vector<size_t> v(20000);

  int sum = 0;



  unordered_map<size_t, int> um;

  for (int i = 0; i < n; i++) {

    string str;

    cin >> str;

    size_t hs = hash<string>()(str);

    auto itr = lower_bound(v.begin(), v.end(), hs);



    if (itr == v.end()) {

      v.push_back(hs);

      sum++;

    } else if (*itr != hs) {

     v.insert(itr, hs);

      sum++;

    } else {

    }

  }

  cout << sum << endl;



  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.4737197085544622x):
#include <iostream>

#include <vector>

#include <string>

#include <algorithm>

#include <stdlib.h>

#include <map>



using namespace std;



int main (void)

{

  int n;

  cin >> n;

  map<string, int> m;

  for (int i = 0; i < n; i++) {

    string s; cin >> s;

    m[s]++;

  }



  cout << m.size() << endl;

  return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

int N;

string a[200001];

map<string, int> mp;

int ans = 0;



int main(){

    cin >> N;

    for(int i=0;i<N;i++){

        cin >> a[i];

        mp[a[i]] = 1;

    }

    for(auto i = mp.begin(); i != mp.end(); ++i){

        ans += i->second;

    }

    cout << ans << endl;

    return 0;  

}

// Faster C++ solution for the same problem (measured speedup: 8.200742727382014x):
#include <bits/stdc++.h>

using namespace std;

int N;

string str;

map<string, int> mp;

int ans = 0;



int main(){

    cin >> N;

    for(int i=0;i<N;i++){

        cin >> str;

        mp[str] = 1;

    }

    for(auto i = mp.begin(); i != mp.end(); ++i){

        ans += i->second;

    }

    cout << ans << endl;

    return 0;  

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

int N;

string a[200001];

map<string, int> mp;

int ans = 0;



int main(){

    cin >> N;

    for(int i=0;i<N;i++){

        cin >> a[i];

        mp[a[i]] = 1;

    }

    for(auto i = mp.begin(); i != mp.end(); ++i){

        ans += i->second;

    }

    cout << ans << endl;

    return 0;  

}

// Faster C++ solution for the same problem (measured speedup: 8.203930404659378x):
#include <bits/stdc++.h>

using namespace std;

int N, ans = 0;

string str;

map<string, int> mp;



int main(){

    cin >> N;

    for(int i=0;i<N;i++){ cin >> str; mp[str] = 1;}

    for(auto i = mp.begin(); i != mp.end(); ++i) ans += i->second;

    cout << ans << endl;

    return 0;  

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

int N;

string a[200001];

map<string, int> mp;

int ans = 0;



int main(){

    cin >> N;

    for(int i=0;i<N;i++){

        cin >> a[i];

        mp[a[i]] = 1;

    }

    for(auto i = mp.begin(); i != mp.end(); ++i){

        ans += i->second;

    }

    cout << ans << endl;

    return 0;  

}

// Faster C++ solution for the same problem (measured speedup: 8.20094793520226x):
#include <bits/stdc++.h>

using namespace std;

int N, ans = 0;

string str;

map<string, int> mp;



int main(){

    cin >> N;

    while(N--){ cin >> str; mp[str] = 1;}

    for(auto i = mp.begin(); i != mp.end(); ++i) ans += i->second;

    cout << ans << endl;

    return 0;  

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

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

#define Rep(i,n) for(int i=1;i<=n;i++)

const ll MOD = 1000000007;

long long modinv(long long a, long long m=MOD) {

    long long b = m, u = 1, v = 0;

    while (b) {

        long long t = a / b;

        a -= t * b; swap(a, b);

        u -= t * v; swap(u, v);

    }

    u %= m; 

    if (u < 0) u += m;

    return u;

    /*MODの割り算の際に

    a/＝b;

    を

    a *= modinv(b,MOD);

    とする。

        */

}

const int MAXN = 200001;

string S[MAXN];



int main(){

    int N;cin >> N;

    rep(i,N)cin >> S[i];

    map<string,int> ma;

    ll ans = 0;

    rep(i,N){

        if(ma[S[i]]>0){

            ma[S[i]]++;

        }

        else {

            ma[S[i]] = 1;

            ans ++;

        }

    }



    cout <<ans << endl;

    







    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 8.222299772668267x):
#include <iostream>

#include <set>

using namespace std;

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



int main(){

    int N;cin >> N;

    set<string> se;

    rep(i,N){

        string s;cin >> s;

        se.insert(s);

    }

    cout << se.size() << endl;

    return 0;

}
// Slower C++ solution:
#include <stdio.h>

#include <algorithm>

using namespace std;

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

#define INF (1<<28)



int n, m, a[64], b[64], c[64];

int dp[64][64][64];



int f(int k, int x, int y) {

    int ans = c[k];

    rep (i, x+1) rep (j, y+1) if (1 <= i+j && i+j <= 8) {

        ans = max(ans, a[k]*i + b[k]*j);

    }

    return ans;

}



int main() {

    scanf("%d%d", &n, &m);

    rep (i, n) scanf("%d%d%d", a+i, b+i, c+i);

    rep (i, 64) rep (j, 64) rep (k, 64) dp[i][j][k] = -INF;

    dp[0][0][0] = 0;

    rep (k, n) rep (x, m+1) rep (i, x+1) if (dp[k][x][i] > -INF) {

        rep (j, m-x+1) {

            dp[k+1][x+j][j] = max(dp[k+1][x+j][j], dp[k][x][i]+f(k, j, i));

        }

    }

    int ans = -INF;

    rep (x, m+1) rep (i, 64) ans = max(ans, dp[n][x][i]);

    printf("%d\n", ans);

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.600419543467563x):
#include <stdio.h>

#include <algorithm>

using namespace std;

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

#define INF (1<<28)



int n, m, a[64], b[64], c[64];

int f[64][10][10], dp[64][64][10];



int main() {

    scanf("%d%d", &n, &m);

    rep (i, n) scanf("%d%d%d", a+i, b+i, c+i);

    rep (k, 64) rep (x, 10) rep (y, 10) {

        f[k][x][y] = c[k];

        rep (i, x+1) rep (j, y+1) if (1 <= i+j && i+j <= 8) {

            f[k][x][y] = max(f[k][x][y], a[k]*j + b[k]*i);

        }

    }

    rep (i, 64) rep (j, 64) rep (k, 10) dp[i][j][k] = -INF;

    dp[0][0][0] = 0;

    rep (k, n) rep (x, m+1) rep (i, min(8, x)+1) if (dp[k][x][i] > -INF) {

        rep (j, min(8, m-x)+1) {

            dp[k+1][x+j][j] = max(dp[k+1][x+j][j], dp[k][x][i]+f[k][i][j]);

        }

    }

    int ans = -INF;

    rep (x, m+1) rep (i, 10) ans = max(ans, dp[n][x][i]);

    printf("%d\n", ans);

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <cstring>

#include <algorithm>

#include <cmath>

using namespace std;

double inf=1000000000000000000;

struct Cir{

	double x,y,r;

}e[1005];

double a[1005][1005],d[1005];

int n,vis[1005];

double xs,ys,xt,yt;

double min(double x,double y){

	return x<y?x:y;

}

double max(double x,double y){

	return x>y?x:y;

}

double dis(double xa,double ya,double xb,double yb){

	return sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));

}

double dij(int n,int S,int T){

	int mini;

    for(int i=1;i<=n;i++) d[i]=inf,vis[i]=0;

    d[S]=0,d[0]=inf+1;

    while(!vis[T]){

    	mini=0;

        for(int i=1;i<=n;i++) if(!vis[i]&&d[mini]>d[i]) mini=i;

        vis[mini]=1;

        for(int i=1;i<=n;i++) if(!vis[i]) d[i]=min(d[i],d[mini]+a[mini][i]);

    }

    return d[mini];

}

int main(){

    scanf("%lf%lf%lf%lf",&xs,&ys,&xt,&yt);

    scanf("%d",&n);

    for(int i=1;i<=n;i++) scanf("%lf%lf%lf",&e[i].x,&e[i].y,&e[i].r);

    for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++){

          double r1=e[i].r,r2=e[j].r;

          a[i][j]=a[j][i]=max(0.0,dis(e[i].x,e[i].y,e[j].x,e[j].y)-r1-r2); 

    }

    for(int i=1;i<=n;i++){

        a[n+1][i]=a[i][n+1]=max(0.0,dis(xs,ys,e[i].x,e[i].y)-e[i].r);

        a[n+2][i]=a[i][n+2]=max(0.0,dis(xt,yt,e[i].x,e[i].y)-e[i].r);

        a[i][i]=0;

    }

    a[n+1][n+1]=a[n+2][n+2]=0;

    a[n+1][n+2]=a[n+2][n+1]=dis(xs,ys,xt,yt);

    printf("%.10lf\n",dij(n+2,n+1,n+2));

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.463937082301426x):
#include<cstdio>

#include<cmath>

#include<cstring>

#include<algorithm>

using namespace std;

double f[1005][1005],dis[1005],a[1005][3];

bool b[1005];

int main()

{

	int i,j,k,n;

	double xi,xs,ys,xt,yt;

	scanf("%lf%lf%lf%lf",&xs,&ys,&xt,&yt);

	scanf("%d",&n);

	a[0][0]=xs;a[0][1]=ys;a[0][2]=0;

	a[n+1][0]=xt;a[n+1][1]=yt;a[n+1][2]=0;

	for(i=1;i<=n;i++)

		scanf("%lf%lf%lf",&a[i][0],&a[i][1],&a[i][2]);

	n++;

	for(i=0;i<=n;i++)

		for(j=i+1;j<=n;j++)

			f[i][j]=f[j][i]=max(0.0,sqrt((a[i][0]-a[j][0])*(a[i][0]-a[j][0])+(a[i][1]-a[j][1])*(a[i][1]-a[j][1]))-(a[i][2]+a[j][2]));

	for(i=0;i<=1003;i++) dis[i]=1e18;

	dis[0]=0; 

	for(i=0;i<n;i++){ 

		xi=1e18;

		k=0; 

		for(j=0;j<=n;j++){

            if(b[j]==0&&dis[j]<xi){

				xi=dis[j]; 

				k=j; 

			} 

        }

		b[k]=1; 

		for(j=0;j<=n;j++)

			dis[j]=min(dis[j],dis[k]+f[k][j]);

	}

	printf("%.9lf",dis[n]);

}