https://www.acmicpc.net/problem/10833
#include <iostream> using namespace std; int main() { int n,a,b; cin>>n; int sum=0; for(int i=0;i<n;i++){ cin>>a>>b; sum+=b%a; } cout<<sum; }