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

using namespace std;

int main()

{

         long long c=0,i,n,f=0,b=0;

         cin>>n;

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

        {

           b+=i;

           if((i%3)==0 || (i%5)==0) {f+=i;

           }

         }

 

         cout<<b-f<<endl;

}

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

int main(){

	long long int n,sum=0;

	scanf("%lld",&n);

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

		if(i%3 == 0 && i%5 ==0) continue;

		else if(i%3==0) continue;

		else if(i%5==0) continue;

		sum += i;

		}

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

 	return 0;

}
// Slower C++ solution:
// In the name of God



#include <bits/stdc++.h>



using namespace std;



int main() {

	ios_base::sync_with_stdio(false);

	cin.tie(0);



	int n;

	cin >> n;



	long long ans = 0;

	

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

		if(i % 3 == 0 || i % 5 == 0) continue;

		ans += i;

	}

	cout << ans;



	return 0;

}


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

int main(){

	long long int n,sum=0;

	scanf("%lld",&n);

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

		if(i%3 == 0 && i%5 ==0) continue;

		else if(i%3==0) continue;

		else if(i%5==0) continue;

		sum += i;

		}

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

 	return 0;

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

#include<iostream>

#include<cmath>

#include<algorithm>

#include<vector>

#include<map>

#include<set>

#include<stack>

#include<iterator>

#include<iomanip>

#include<string>

using namespace std;



long long int sum(long long int x)

{

    return x*(x+1)/2;

}



int main()

{

    long long int n;

    cin>>n;

    cout<<sum(n)+15*sum(n/15)-3*sum(n/3)-5*sum(n/5);

    return 0;

}


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

int main(){

	long long int n,sum=0;

	scanf("%lld",&n);

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

		if(i%3 == 0 && i%5 ==0) continue;

		else if(i%3==0) continue;

		else if(i%5==0) continue;

		sum += i;

		}

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

 	return 0;

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

#define ll long long int

using namespace std;

ll i, j , k , l , n,counter;

 bool ara3[200000];

 void seive()

 {

     for(i= 2; i<=100001; i++)

     {

         ara3[i]  = true;

     }

     ara3[1]  = false;

     for(i=2 ; i<=100001; i++)

     {

         for(j=2;i*j<=100001; j++)

         {

             if(ara3[i]==true)

             {

                 ara3[i*j] = false;

             }

         }

     }

 }

int main(void)

{

    seive();

     while(cin>>n)

     {

         counter = 0;

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

         {

             if(ara3[i]==true && ara3[j]==true)

             {

                 counter++;

             }



         }

         cout<<counter<<endl;

     }

     return 0;



}

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

#include<math.h>



using namespace std;



int IsPrime(int a,int b)

{

    int i,p=0,q=0;

    if(a==1||b==1)

    {

        return 0;

    }

    for(i=2;i<=sqrt(a);i++)

    {



        if(a%i==0)

            {

                p=1;

                break;

            }

    }



    for(i=2;i<=sqrt(b);i++)

    {



        if(b%i==0)

            {

                q=1;

                break;

            }



    }

    if(p!=1&&q!=1)

        return 1;

    else

        return 0;



}

int main()

{

    int a,b,i,c=0;

    while( cin>>a)

    {

        c=0;



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

    {

        if((b=IsPrime(i+1,a-i))==1)

            c++;



    }

    cout<<c<<endl;



}

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

#include<iostream>

#include<bitset>



#define MAX 10001



using namespace std;



bitset<MAX> b1;



void ComputePrimes(){

	b1.set();



	b1.reset(1);

	for(int i = 4; i <= 10000; ++i){

		for(int j = 2; j <= sqrt((double)i); ++j){

			if( i % j == 0 ){

				b1.reset( i );

				break;

			}

		}

	}

}



int main()

{

	ComputePrimes();



	while( true )

	{

		int N, P = 0;

		

		cin >> N;



		if( cin.eof() )

			break;



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

			if( b1[N - i + 1] == true && b1[ i ] == true )

				++P;

		}



		cout << P << '\n';

	}

	return 0;

}

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

#include<iostream>

#include<bitset>



#define MAX 10001



using namespace std;



int bComposite[MAX];



void ComputePrimes(){

	bComposite[1] = 1;

	for(int i = 4; i <= 10000; ++i){

		if( bComposite[ i ] == 0 ){

			for(int j = 2; j <= sqrt((double)i); ++j){

				if( i % j == 0 ){

					bComposite[ i ] = 1;

					break;

				}

			}

		}

		if( bComposite[ i ] == 0 ){

			for(unsigned int j = 2; i * j <= 10000; ++j){

				bComposite[ i * j ] = 1;

			}

		}

	}

}



int main()

{

	ComputePrimes();



	while( true )

	{

		int N, P = 0;

		

		cin >> N;



		if( cin.eof() )

			break;



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

			if( !bComposite[N - i + 1] && !bComposite[ i ] )

				++P;

		}



		cout << P << '\n';

	}

	return 0;

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

using namespace std;

const int maxn=200005;

typedef long long ll;

int n,m;

char s[maxn];

int main()

{

	scanf("%s",s+1);

	n=strlen(s+1);

	ll ans=0,cnt=0;

	for(int i=n;i>=1;i--)

	{

		if(s[i]=='A')

			ans+=cnt;

		else if(s[i]=='C')

		{

			if(s[i-1]=='B')cnt++;

			else cnt=0;

		}

		else

		{

			if(s[i+1]=='C');

			else cnt=0;

		}

	}

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

	return 0;

}


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

#include<cstring>

using namespace std;



char s[200002];

int z[200001];

int main(){

	scanf("%s",s+1);

	int n=strlen(s+1);

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

		if(s[i]=='A')z[++z[0]]=1;

		else if(i<n&&s[i]=='B'&&s[i+1]=='C')

			z[++z[0]]=2,i++;

		else z[++z[0]]=3;

	long long ans=0;

	for(int i=1;i<=z[0];i++){

		if(z[i]==3)continue;

		int j=i;

		while(j<=z[0]&&z[j]!=3)j++;

		int w=0;

		for(int k=i;k<=j;k++)

			if(z[k]==2)ans+=k-i-w,w++;

		i=j;

	}

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

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



using int64 = long long;



const int MAX_N = int(2e5) + 10;



int n;

bool is[MAX_N];

char s[MAX_N];



int main() {

	scanf("%s", s + 1);

	n = strlen(s + 1);

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

		if (s[i] == 'C' && s[i - 1] != 'B') {

			is[i] = true;

		}

		if (s[i] == 'B' && s[i + 1] != 'C') {

			is[i] = true;

		}

	}



	int64 ans = 0LL;

	for (int l = 1, r; l <= n; l = r + 1) {

		while (is[l]) ++l;

		if (l > n) break;

		r = l;

		while (r < n && !is[r + 1]) ++r;

		int cnt = 0;

		int64 del = 0LL;

		for (int i = l; i <= r; ++i) {

			if (s[i] == 'A') ++cnt;

			else if (s[i] == 'B' && s[i + 1] == 'C') {

				++i;

				del += cnt;

			}

		}

		ans += del;

	}



	std::cout << ans << std::endl;

}

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

#include<cstring>

using namespace std;



char s[200002];

int z[200001];

int main(){

	scanf("%s",s+1);

	int n=strlen(s+1);

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

		if(s[i]=='A')z[++z[0]]=1;

		else if(i<n&&s[i]=='B'&&s[i+1]=='C')

			z[++z[0]]=2,i++;

		else z[++z[0]]=3;

	long long ans=0;

	for(int i=1;i<=z[0];i++){

		if(z[i]==3)continue;

		int j=i;

		while(j<=z[0]&&z[j]!=3)j++;

		int w=0;

		for(int k=i;k<=j;k++)

			if(z[k]==2)ans+=k-i-w,w++;

		i=j;

	}

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

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

using namespace std;



typedef long long lint;

typedef long double louble;



template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}

template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}



namespace ae86

{

	const int bufl = 1<<15;

	

	char buf[bufl],*s=buf,*t=buf;

	

	inline int fetch()

	{

		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}

		return *s++;

	}

	

	inline int ty()

	{

		int a=0,b=1,c=fetch();

		while(!isdigit(c))b^=c=='-',c=fetch();

		while(isdigit(c))a=a*10+c-48,c=fetch();

		return b?a:-a;

	}



	inline int ts(char *s)

	{

		int a=0,c=fetch();

		while(c<=32 && c!=EOF)c=fetch();

		while(c>32 && c!=EOF)s[a++]=c,c=fetch();

		s[a]=0;

		return a;

	}

}

using ae86::ty;

using ae86::ts;



const int _ = 200007;



int n;char s[_];



int main()

{

	n=ts(s+1);



	lint ans=0;int cnta=0;

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

	{

		if(s[i]=='A')cnta++,i++;

		else if(s[i]=='B' && s[i+1]=='C')ans+=cnta,i+=2;

		else cnta=0,i++;

	}

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



	return 0;

}


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

using namespace std;



const int _ = 200007;



char s[_];



int main()

{

	fread(s,1,_,stdin);

	

	long long ans=0,cnta=0;

	for(int i=0;s[i];i++)

	{

		if(s[i]=='A')cnta++;

		else if(s[i]=='B' && s[i+1]=='C')ans+=cnta,i++;

		else cnta=0;

	}

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



	return 0;

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

#include<algorithm>

#include<vector>

#include<queue>

#include<list>

#include<set>

#include<string>

using namespace std;

int gcd(int a, int b) {

	int c = a % b;

	while (c != 0) {

		a = b;

		b = c;

		c = a % b;

	}

	return b;

}

struct UnionFind {

	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2



	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化

		for (int i = 0; i < N; i++) par[i] = i;

	}



	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}

		if (par[x] == x) return x;

		return par[x] = root(par[x]);

	}



	void unite(int x, int y) { // xとyの木を併合

		int rx = root(x); //xの根をrx

		int ry = root(y); //yの根をry

		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま

		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける

	}



	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す

		int rx = root(x);

		int ry = root(y);

		return rx == ry;

	}

};

typedef long long ll;



const ll M = 1000000007;



vector<ll> fac(300001); //n!(mod M)

vector<ll> ifac(300001); //k!^{M-2} (mod M)



ll mpow(ll x, ll n) {

	ll ans = 1;

	while (n != 0) {

		if (n & 1) ans = ans * x % M;

		x = x * x % M;

		n = n >> 1;

	}

	return ans;

}

ll comb(ll a, ll b) {

	if (a == 0 && b == 0)return 1;

	if (a < b || a < 0)return 0;

	ll tmp = ifac[a - b] * ifac[b] % M;

	return tmp * fac[a] % M;

}

// mod. m での a の逆元 a^{-1} を計算する

long long modinv(long long a) {

	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;

}

int main() {

	ll i, ans=0, count = 0;

	char s[222222];

	cin >> s;

	if (s[0] == 'A')

		count++;

	for (i = 1; s[i] != '\0'; i++) {

		if (s[i] == 'A')

			count++;

		if (s[i] == 'B') {

			if (s[i - 1] != 'A'||s[i+1]!='C')

				count = 0;

		}

		if (s[i] == 'C') {

			if (s[i - 1] == 'B') {

				ans += count;

				s[i] = 'A';

			}

			else

				count = 0;

		}

	}

	cout << ans << endl;

}

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

using namespace std;



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

#define ll long long



int main(){

    string s;

    cin>>s;

    int n=s.size();

    rep(i,n-1){

        if(s[i]=='B'&&s[i+1]=='C') s[i]='K',s[i+1]='D';

    }

    reverse(s.begin(),s.end());

    ll k=0,cnt=0;

    rep(i,n){

        if(s[i]=='K') k++;

        else if(s[i]=='A') cnt+=k;

        else if(s[i]!='D') k=0;

    }

    cout<<cnt<<endl;

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

#include <sstream>

#include <vector>



using namespace std;



int main()

{

    string times;

    int x=0;

    int n;

    vector <int> number;

getline(cin,times);

stringstream s(times);

while(s>>n)

    number.push_back(n);



x=(60*(number[2]-number[0])+(number[3]-number[1]))-number[4];



    cout<<x<<endl;





    return 0;

}


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



int main(){

	int jamb;

	int menitb;

	int jamt;

	int menitt;

	int belajar;

	int rumus;

	scanf("%d %d %d %d %d", &jamb,&menitb,&jamt,&menitt,&belajar);

	rumus=((jamt*60)+menitt)-((jamb*60)+menitb)-belajar;

	printf("%d", rumus);

	

	

	return 0;

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

using namespace std;



int main() {

	

	ios::sync_with_stdio(0);

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

	

	int h1, m1, h2, m2, k; cin >> h1 >> m1 >> h2 >> m2 >> k;

	int a = h1 * 60 + m1, b = h2 * 60 + m2;

	int ans = b - a;

	if (ans < 0) ans += 24 * 60;

	ans -= k;

	cout << ans << "\n";

	

	return 0;

}


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



int main(){

	int jamb;

	int menitb;

	int jamt;

	int menitt;

	int belajar;

	int rumus;

	scanf("%d %d %d %d %d", &jamb,&menitb,&jamt,&menitt,&belajar);

	rumus=((jamt*60)+menitt)-((jamb*60)+menitb)-belajar;

	printf("%d", rumus);

	

	

	return 0;

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

#include <sstream>

#include <vector>



using namespace std;



int main()

{

    string times;

    int x=0;

    int n;

    vector <int> number;

getline(cin,times);

stringstream s(times);

while(s>>n)

    number.push_back(n);



x=(60*(number[2]-number[0])+(number[3]-number[1]))-number[4];



    cout<<x<<endl;





    return 0;

}


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



int main(){

    

	int h1, h2, m1, m2, k;

	scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);

	int rangem;

	int rangeh;

	

	if(m2<m1){

		m2+=60;

		h2-=1;

		rangem = m2-m1;

	}

	else{

		rangem = m2 - m1;

	}

	

	rangeh = h2-h1;

	int total = rangeh*60 + rangem;

	

	printf("%d\n", total - k);

	

    return 0;

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

using namespace std;



int main() {

	

	ios::sync_with_stdio(0);

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

	

	int h1, m1, h2, m2, k; cin >> h1 >> m1 >> h2 >> m2 >> k;

	int a = h1 * 60 + m1, b = h2 * 60 + m2;

	int ans = b - a;

	if (ans < 0) ans += 24 * 60;

	ans -= k;

	cout << ans << "\n";

	

	return 0;

}


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



int main(){

    

	int h1, h2, m1, m2, k;

	scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);

	int rangem;

	int rangeh;

	

	if(m2<m1){

		m2+=60;

		h2-=1;

		rangem = m2-m1;

	}

	else{

		rangem = m2 - m1;

	}

	

	rangeh = h2-h1;

	int total = rangeh*60 + rangem;

	

	printf("%d\n", total - k);

	

    return 0;

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

#include <sstream>

#include <vector>



using namespace std;



int main()

{

    string times;

    int x=0;

    int n;

    vector <int> number;

getline(cin,times);

stringstream s(times);

while(s>>n)

    number.push_back(n);



x=(60*(number[2]-number[0])+(number[3]-number[1]))-number[4];



    cout<<x<<endl;





    return 0;

}


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



int main() {

    int h1, m1, h2, m2, k;

    scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);

    h1 *= 60;

    h2 *= 60;

    h1 += m1;

    h2 += m2;

    int diff = h2 - h1;

    if (k == h2) {

        printf("0");

        return 0;

    }

    printf("%d", diff - k);

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

using namespace std;



int main() {

	

	ios::sync_with_stdio(0);

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

	

	int h1, m1, h2, m2, k; cin >> h1 >> m1 >> h2 >> m2 >> k;

	int a = h1 * 60 + m1, b = h2 * 60 + m2;

	int ans = b - a;

	if (ans < 0) ans += 24 * 60;

	ans -= k;

	cout << ans << "\n";

	

	return 0;

}


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



int main() {

    int h1, m1, h2, m2, k;

    scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);

    h1 *= 60;

    h2 *= 60;

    h1 += m1;

    h2 += m2;

    int diff = h2 - h1;

    if (k == h2) {

        printf("0");

        return 0;

    }

    printf("%d", diff - k);

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

#include <sstream>

#include <vector>



using namespace std;



int main()

{

    string times;

    int x=0;

    int n;

    vector <int> number;

getline(cin,times);

stringstream s(times);

while(s>>n)

    number.push_back(n);



x=(60*(number[2]-number[0])+(number[3]-number[1]))-number[4];



    cout<<x<<endl;





    return 0;

}


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



int main()

{

	int h1, m1, h2, m2, k;

	scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);

	

	int hr = h2 - h1;

	int min = m2 - m1;

	int res = hr * 60 + min - k;

	printf("%d", res);		

	

	return 0;

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

using namespace std;



int main() {

	

	ios::sync_with_stdio(0);

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

	

	int h1, m1, h2, m2, k; cin >> h1 >> m1 >> h2 >> m2 >> k;

	int a = h1 * 60 + m1, b = h2 * 60 + m2;

	int ans = b - a;

	if (ans < 0) ans += 24 * 60;

	ans -= k;

	cout << ans << "\n";

	

	return 0;

}


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



int main()

{

	int h1, m1, h2, m2, k;

	scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);

	

	int hr = h2 - h1;

	int min = m2 - m1;

	int res = hr * 60 + min - k;

	printf("%d", res);		

	

	return 0;

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

#include <sstream>

#include <vector>



using namespace std;



int main()

{

    string times;

    int x=0;

    int n;

    vector <int> number;

getline(cin,times);

stringstream s(times);

while(s>>n)

    number.push_back(n);



x=(60*(number[2]-number[0])+(number[3]-number[1]))-number[4];



    cout<<x<<endl;





    return 0;

}


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



int main(){

	int a, b, c, d;

	int K;

	scanf("%d %d %d %d %d", &a, &b, &c, &d, &K);

	int diff1 = c - a;

	int diff2 = d - b;

	int min = (diff1 * 60) + diff2;

	printf("%d", min - K);

	

	

	

	return 0;

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

using namespace std;



int main() {

	

	ios::sync_with_stdio(0);

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

	

	int h1, m1, h2, m2, k; cin >> h1 >> m1 >> h2 >> m2 >> k;

	int a = h1 * 60 + m1, b = h2 * 60 + m2;

	int ans = b - a;

	if (ans < 0) ans += 24 * 60;

	ans -= k;

	cout << ans << "\n";

	

	return 0;

}


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



int main(){

	int a, b, c, d;

	int K;

	scanf("%d %d %d %d %d", &a, &b, &c, &d, &K);

	int diff1 = c - a;

	int diff2 = d - b;

	int min = (diff1 * 60) + diff2;

	printf("%d", min - K);

	

	

	

	return 0;

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

#include <sstream>

#include <vector>



using namespace std;



int main()

{

    string times;

    int x=0;

    int n;

    vector <int> number;

getline(cin,times);

stringstream s(times);

while(s>>n)

    number.push_back(n);



x=(60*(number[2]-number[0])+(number[3]-number[1]))-number[4];



    cout<<x<<endl;





    return 0;

}


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

int main()

{

    int hour_1;

    int hour_2;

    int min_1;

    int min_2;

    int k;

    scanf("%d %d %d %d %d", &hour_1, &min_1, &hour_2, &min_2, &k);

    int total_hour = hour_2 - hour_1;

    int total_minute = min_2 - min_1;

    int duration = (total_hour * 60) + total_minute - k;

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

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

using namespace std;



int main() {

	

	ios::sync_with_stdio(0);

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

	

	int h1, m1, h2, m2, k; cin >> h1 >> m1 >> h2 >> m2 >> k;

	int a = h1 * 60 + m1, b = h2 * 60 + m2;

	int ans = b - a;

	if (ans < 0) ans += 24 * 60;

	ans -= k;

	cout << ans << "\n";

	

	return 0;

}


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

int main()

{

    int hour_1;

    int hour_2;

    int min_1;

    int min_2;

    int k;

    scanf("%d %d %d %d %d", &hour_1, &min_1, &hour_2, &min_2, &k);

    int total_hour = hour_2 - hour_1;

    int total_minute = min_2 - min_1;

    int duration = (total_hour * 60) + total_minute - k;

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

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

#include <sstream>

#include <vector>



using namespace std;



int main()

{

    string times;

    int x=0;

    int n;

    vector <int> number;

getline(cin,times);

stringstream s(times);

while(s>>n)

    number.push_back(n);



x=(60*(number[2]-number[0])+(number[3]-number[1]))-number[4];



    cout<<x<<endl;





    return 0;

}


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

#include <string.h>

#define ll long long int



int main(){

	int h1, m1, h2, m2, k;

	scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);

	//h1 m1, bangun

	//h2 m2 tidur

	//k menit

	//study brp banyak

	//10 0 15 0 30

	//270

	int bangun =  (h2*60 + m2) -(h1*60 + m1)- k;

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

	

	

	return 0;

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

using namespace std;



int main() {

	

	ios::sync_with_stdio(0);

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

	

	int h1, m1, h2, m2, k; cin >> h1 >> m1 >> h2 >> m2 >> k;

	int a = h1 * 60 + m1, b = h2 * 60 + m2;

	int ans = b - a;

	if (ans < 0) ans += 24 * 60;

	ans -= k;

	cout << ans << "\n";

	

	return 0;

}


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

#include <string.h>

#define ll long long int



int main(){

	int h1, m1, h2, m2, k;

	scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);

	//h1 m1, bangun

	//h2 m2 tidur

	//k menit

	//study brp banyak

	//10 0 15 0 30

	//270

	int bangun =  (h2*60 + m2) -(h1*60 + m1)- k;

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

	

	

	return 0;

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

using namespace std;



int main (){

	int h1, m1, h2, m2, k;

	scanf("%d%d%d%d%d", &h1, &m1, &h2, &m2, &k);

	printf("%d\n", (h2 * 60 + m2) - (h1 * 60 + m1) - k);

	return 0;

}


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



int main(){

	int a,b,x,y,kurang;

	scanf("%d %d %d %d %d", &a,&b,&x,&y,&kurang);

	int temp=((x*60)+y)-((a*60)+b);

	printf("%d\n", temp-kurang);

	return 0;

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

using namespace std;



int main (){

	int h1, m1, h2, m2, k;

	scanf("%d%d%d%d%d", &h1, &m1, &h2, &m2, &k);

	printf("%d\n", (h2 * 60 + m2) - (h1 * 60 + m1) - k);

	return 0;

}


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







int main()

{

	int H1, H2, M1, M2, k, tH, tM;

	scanf("%d %d %d %d %d", &H1, &M1, &H2, &M2, &k);

	tH = H2 - H1;

	tM = M2 - M1;

	tH = ((tH * 60) + tM) - k ;

	

	printf("%d", tH);

	return 0;

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

using namespace std;



int main (){

	int h1, m1, h2, m2, k;

	scanf("%d%d%d%d%d", &h1, &m1, &h2, &m2, &k);

	printf("%d\n", (h2 * 60 + m2) - (h1 * 60 + m1) - k);

	return 0;

}


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

#include<string.h>



// helpful functions

#define fl(i,n) for(long long i = 0; i < n; i++)

#define fls(i,a,b) for(long long i = a; i <= b; i ++)

#define afl(i,a,n) int a[n]; for(int i = 0; i < n; i++) scanf("%d", &ar[i])



// printers

#define iprint(x) printf("%d\n", x)

#define lprint(x) printf("%lld\n", x)

#define fprint(x,n) printf("%.nf\n", x)

#define dprint(x,n) printf("%.nlf\n", x)

#define sprint(x) printf("%s\n", x)



// scanners

#define iscan(x) scanf("%d", &x)

#define lcan(x) scanf("%lld", &x)

#define fscan(x) scanf("%f", &x)

#define dscan(x) scanf("%lf", &x)

#define scan(x) scanf("%s", x)

#define qs(x) long long x; scanf("%lld", &x)



int main()

{

	qs(h1); qs(m1); qs(h2); qs(m2); qs(k);

	iprint((h2-h1)*60 + (m2-m1) - k);

	return 0;

}