fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define fast_io ios::sync_with_stdio(0); cin.tie(0)
  4. #define int long long
  5.  
  6. void solve(){
  7. int n,m;
  8. cin >> n >> m;
  9.  
  10. cout << n + m - 1 << "\n";
  11.  
  12. int i = 1, j = 1;
  13. cout << i << " " << j << "\n";
  14.  
  15. while(i < n && j < m){
  16. j++;
  17. cout << i << " " << j << "\n";
  18. i++;
  19. cout << i << " " << j << "\n";
  20. }
  21.  
  22. while(i < n){
  23. i++;
  24. cout << i << " " << j << "\n";
  25. }
  26.  
  27. while(j < m){
  28. j++;
  29. cout << i << " " << j << "\n";
  30. }
  31. }
  32.  
  33. int32_t main(){
  34. fast_io;
  35. solve();
  36. return 0;
  37. }
  38.  
Success #stdin #stdout 0s 5320KB
stdin
2 2
stdout
3
1 1
1 2
2 2