Source Code
//never give up.... just cry when you have to do 🌵🙂 
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) v.size()
#define mem(dp) memset(dp, 0 , sizeof dp)
long double pi = acos(-1);
void FILe() { freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); }
void FAST() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); }
int main()
{
	//freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
	FAST();
	string s;
	cin >> s;
	ll q, l, r;
	cin >> q;
	while (q--)
	{
		cin >> l >> r;
		l--;//, r--;
		bitset<200005>bs(s.substr(l, r - l));
		cout << bs.to_ullong()%10 << "\n";
	}
	return 0;
}

Copy
Binarithm Doaa_Saad
GNU G++17
5 ms
704 KB
Runtime Error