1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include<bits/stdc++.h>
using namespace std;
#define int long long

void solve() {
	string a, b, c; cin >> a >> b >> c;
	int n = a.length();
	int cnt = 0, ans = 0, pre = -1, ok = 0;
	for(int i = 0; i < n; i++) {
		int s = (a[i] - '0') + (b[i] - '0');
		int need = -1, give = -1;
		if(s % 10 == c[i] - '0') { need = 0; give = s / 10; }
		else if((s + 1) % 10 == c[i] - '0') { need = 1; give = (s + 1) / 10; }
		if(need == -1) { ok = 0; cnt = 0; continue; }
		if(!ok || pre != give) cnt = 0;
		if(give == 0) cnt++;
		if(need == 0) ans += cnt;
		ok = 1; pre = need;
	} cout << ans << '\n';
}

signed main() {
	ios::sync_with_stdio(false);
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	// For Problem with file IO
	// #ifndef CPH
	//   freopen(".in", "r", stdin);
	//   freopen(".out", "w", stdout);
	// #endif
	int t = 1;
	// cin >> t;
	while(t--) {
		solve();
	}
	return 0;
}