Problem:
Score : 100 points

Problem Statement

You went shopping to buy cakes and donuts with X yen (the currency of Japan).

First, you bought one cake for A yen at a cake shop.
Then, you bought as many donuts as possible for B yen each, at a donut shop.

How much do you have left after shopping?

Constraints

1 \leq A, B \leq 1 000

A + B \leq X \leq 10 000

X, A and B are integers.

Input

Input is given from Standard Input in the following format:

X
A
B

Output

Print the amount you have left after shopping.

Sample Input 1

1234
150
100

Sample Output 1

84

You have 1234 - 150 = 1084 yen left after buying a cake.
With this amount, you can buy 10 donuts, after which you have 84 yen left.

Sample Input 2

1000
108
108

Sample Output 2

28

Sample Input 3

579
123
456

Sample Output 3

0

Sample Input 4

7477
549
593

Sample Output 4

405

Solution in C++14 (GCC 5.4.1) (judge verdict: Runtime Error)

//#if !defined(YCM) && 1
//#define _FORTIFY_SOURCE 0
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx")
////#pragma GCC optimize ("O3")
////#pragma GCC target ("sse4")
//#include <stdio.h>
//#endif
#include <unistd.h>
//#pragma GCC diagnostic ignored "-Wunused-result"
//#pragma GCC diagnostic ignored "-Wunused-function"
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define clr(a) memset(a,0,sizeof(a))
#define clr_(a) memset(a,-1,sizeof(a))
#define pb(a) push_back(a)
#define pii pair<int,int>
#define eps 1e-9
#define inf INT_MAX
#define pi acos(-1.0)
#define ff first
#define ss second
#define INF (ll)1e18
#define m_p make_pair
#define all(v) v.begin(),v.end()
int fx[]={0,0,-1,1,-1,1,1,-1};
int fy[]={1,-1,0,0,1,1,-1,-1};
ll lcm(ll a,ll b){return (a/__gcd(a,b))*b;}
ll bigmod(ll a,ll p,ll mod){ll ans=1;while(p){if(p&1)ans=ans*a%mod;a=a*a%mod;p>>=1;}return ans;}
ll power(ll x,ll n){if(n==0)return 1;else if(n%2==0){ll y=power(x,n/2);return y*y;}else return x*power(x,n-1);}

#ifdef shaft
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " is " << 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) << " is " << arg1 <<endl;
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif
const int N=(int)1e6+5;
const int mod=(int)1e9+7;
int n,m;
#define NODE 200001
#define WHITE 0
#define GRAY 1
#define BLACK 2
int vis[NODE];
int flagCycle;
vector<pii>adj[NODE];
int col[NODE],indeg[NODE];
int disc[NODE], low[NODE];
int head=1,visit[NODE];
int globalCnt = 0;
vector<int> tarjan,sscnum,sccshrink[NODE];

int cycle[NODE];
int dfs ( int s ) {
    vis[s] = GRAY;
    disc[s] = low[s] = globalCnt++;
    tarjan.push_back(s);

    for ( int i = 0; i < adj[s].size(); i++ ) {
        int t = adj[s][i].ff;

        if ( vis[t] == WHITE ) { ///This is tree edge
            dfs ( t );
          low[s] = min ( low[s], low[t] );
        }
        else if ( vis[t] == GRAY ) { ///This is back edge
            ///Cycle detected
            flagCycle = true;
            low[s] = min ( low[s], low[t] );
        }
    }

    if ( disc[s] == low[s] ) {
        while ( 1 ) {
            int lastNode = tarjan.back();

            cycle[lastNode] = head;

            tarjan.pop_back();
            vis[lastNode] = BLACK;
            if ( lastNode == s ) break;
        }
        head++;
    }

}
void dijkstra( int s ) {

    priority_queue<pii> pq;

    pq.push( make_pair(-0,s) );

    while ( !pq.empty() ) {

        int s = pq.top().second;
        int cost = pq.top().first * -1;
        pq.pop();
        for ( int i = 0; i < adj[s].size(); i++ ) {
            int t = adj[s][i].first;
            int e = adj[s][i].second;
            if(cost+e > 1000000000)
                flagCycle = true;
            if ( cost + e < vis[t] ) {
                if(vis[t] != 1000000001)
                    flagCycle = true;
                vis[t] = cost + e;
                pq.push ( make_pair ( -vis[t], t ) );
            }
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(100); cout.tie(nullptr); cin.tie(nullptr);
    #ifdef shaft
        //freopen("in.txt","r",stdin);
        //freopen("out.txt","w",stdout);
    #endif ///shaft
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int u, v, w;
        cin >> u >> v >> w;
        adj[u].pb(m_p(v,w));
        indeg[v] ++;
    }
    for(int i = 1; i <= n; i++){
        if(flagCycle == false){
            dfs(i);
        }
    }
   // debug(flagCycle);
    for ( int i = 0; i <= n; i++ ) vis[i] = 1000000001;
    for(int i = 1; i <= n; i++){
        if(flagCycle == false){
           // debug(i);
            dijkstra(i);
        }
    }
    string res;
    if(!flagCycle)
        res = "Yes";
    else
        res = "No";
    cout << res << endl;
    return 0;
}