Language: C++

#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
//#define ll long long
#define P pair<ll,ll>

int k;
deque<P>bfs;
bool v[200000];

int main(){
	cin>>k;
	bfs.push_back(mp(1,1));

	rep(i,1000000000){
		P tmp=bfs.front();
		bfs.pop_front();
		//cout<<tmp.first<<" "<<tmp.second<<endl;
		if(v[tmp.second])continue;
		v[tmp.second]=1;
		bfs.push_back(mp(tmp.first+1,(tmp.second+1%k)));
		bfs.push_front(mp(tmp.first,(tmp.second*10)%k));

		if(tmp.second%k==0){
				cout<<tmp.first<<endl;
				return 0;
		}
	}
	return 0;
}

Compiler output:
a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
   16 | #define ll __int64
      |            ^~~~~~~
a.cc:18:16: note: in expansion of macro 'll'
   18 | #define P pair<ll,ll>
      |                ^~
a.cc:21:7: note: in expansion of macro 'P'
   21 | deque<P>bfs;
      |       ^
a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
   16 | #define ll __int64
      |            ^~~~~~~
a.cc:18:19: note: in expansion of macro 'll'
   18 | #define P pair<ll,ll>
      |                   ^~
a.cc:21:7: note: in expansion of macro 'P'
   21 | deque<P>bfs;
      |       ^
a.cc:18:21: error: template argument 1 is invalid
   18 | #define P pair<ll,ll>
      |                     ^
a.cc:21:7: note: in expansion of macro 'P'
   21 | deque<P>bfs;
      |       ^
a.cc:18:21: error: template argument 2 is invalid
   18 | #define P pair<ll,ll>
      |                     ^
a.cc:21:7: note: in expansion of macro 'P'
   21 | deque<P>bfs;
      |       ^
a.cc:21:8: error: template argument 1 is invalid
   21 | deque<P>bfs;
      |        ^
a.cc:21:8: error: template argument 2 is invalid
a.cc: In function 'int main()':
a.cc:26:13: error: request for member 'push_back' in 'bfs', which is of non-class type 'int'
   26 |         bfs.push_back(mp(1,1));
      |             ^~~~~~~~~
a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
   16 | #define ll __int64
      |            ^~~~~~~
a.cc:18:16: note: in expansion of macro 'll'
   18 | #define P pair<ll,ll>
      |                ^~
a.cc:29:17: note: in expansion of macro 'P'
   29 |                 P tmp=bfs.front();
      |                 ^
a.cc:18:21: error: template argument 1 is invalid
   18 | #define P pair<ll,ll>
      |                     ^
a.cc:29:17: note: in expansion of macro 'P'
   29 |                 P tmp=bfs.front();
      |                 ^
a.cc:29:27: error: request for member 'front' in 'bfs', which is of non-class type 'int'
   29 |                 P tmp=bfs.front();
      |                           ^~~~~
a.cc:30:21: error: request for member 'pop_front' in 'bfs', which is of non-class type 'int'
   30 |                 bfs.pop_front();
      |                     ^~~~~~~~~
a.cc:32:26: error: request for member 'second' in 'tmp', which is of non-class type 'int'
   32 |                 if(v[tmp.second])continue;
      |                          ^~~~~~
a.cc:33:23: error: request for member 'second' in 'tmp', which is of non-class type 'int'
   33 |                 v[tmp.second]=1;
      |                       ^~~~~~
a.cc:34:21: error: request for member 'push_back' in 'bfs', which is of non-class type 'int'
   34 |                 bfs.push_back(mp(tmp.first+1,(tmp.second+1%k)));
      |                     ^~~~~~~~~
a.cc:34:38: error: request for member 'first' in 'tmp', which is of non-class type 'int'
   34 |                 bfs.push_back(mp(tmp.first+1,(tmp.second+1%k)));
      |                                      ^~~~~
a.cc:34:51: error: request for member 'second' in 'tmp', which is of non-class type 'int'
   34 |                 bfs.push_back(mp(tmp.first+1,(tmp.second+1%k)));
      |                                                   ^~~~~~
a.cc:35:21: error: request for member 'push_front' in 'bfs', which is of non-class type 'int'
   35 |                 bfs.push_front(mp(tmp.first,(tmp.second*10)%k));
      |                     ^~~~~~~~~~
a.cc:35:39: error: request for member 'first' in 'tmp', which is of non-class type 'int'
   35 |                 bfs.push_front(mp(tmp.first,(tmp.second*10)%k));
      |                                       ^~~~~
a.cc:35:50: error: request for member 'second' in 'tmp', which is of non-class type 'int'
   35 |                 bfs.push_front(mp(tmp.first,(tmp.second*10)%k));
      |                                                  ^~~~~~
a.cc:37:24: error: request for member 'second' in 'tmp', which is of non-class type 'int'
   37 |                 if(tmp.second%k==0){
      |                        ^~~~~~
a.cc:38:43: error: request for member 'first' in 'tmp', which is of non-class type 'int'
   38 |                                 cout<<tmp.first<<endl;
      |                                           ^~~~~