codeforces 1118E
枚举 C N 2 C_N^2 CN2 每一队可以计算两次,注意N只有2e5 所以不会T
#include<bits/stdc++.h>
using namespace std;
#define fst first
#define sec second
#define sci(num) scanf("%d",&num)
#define scl(num) scanf("%lld",&num)
#define mem(a,b) memset(a,b,sizeof a)
#define cpy(a,b) memcopy(a,b,sizeof b)
typedef long long LL;
typedef pair<int,int> P;
const int MAX_N = 1e5 + 100;
const int MAX_M = 310;
LL N,K;
int main() {
ios::sync_with_stdio(false); cin.tie(0);
cout.tie(0);
cin >> N >> K;
if (K * (K - 1) < N) {
cout << "NO" << endl;
return 0;
}
cout << "YES" << endl;
for (int i = 1;i <= K && N;i++) {
for (int j = i + 1;j <= K && N;j++) {
cout << i << " " << j << endl;
--N;
if (N) {
cout << j << " " << i << endl;
--N;
}
}
}
return 0;
}