#include <iostream>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include<bits/stdc++.h>
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// #define getrand(l, r) uniform_int_distribution<long long>(l, r)(rng)
using namespace std;
const int N = 100000;
// Function to generate a random number between low and high inclusive
int randInt(int low, int high) {
return low + rand() % (high - low + 1);
}
void generateTestCase(int fileIndex, int maxT, int maxN, int maxK, int maxQ) {
// Open the output file
ofstream outFile("out" + to_string(fileIndex) + ".txt");
// Generate the number of test cases (t)
int t = randInt(1, maxT);
outFile << t << endl;
int totalQ = 0;
for (int i = 1; i < t; i++) {
// Generate n, k, and q
int n = randInt(1, maxN);
int k = randInt(1, maxK);
// int q;
int q = randInt(1, min(maxQ, max(N / (t - i + 1),2))); // Ensure sum(q) ≤ 2 * 10^5
while(q + totalQ > N){
q = randInt(1, min(N-totalQ, max(N / (t - i + 1),1))); // Ensure sum(q) ≤ 2 * 10^5
// cout<<"LOOP"<<endl;
// cout<<q<<endl;
// cout<<totalQ<<endl;
}
totalQ += q;
// cout<<totalQ<<endl;
// totalQ += q;
// Output n, k, and q for this test case
outFile << n << " " << k << " " << q << endl;
// Generate q queries
for (int j = 0; j < q; j++) {
// Generate n1, n2, k1, k2
int n1 = randInt(1, n);
int n2 = randInt(n1, n); // Ensure n1 ≤ n2
int k1 = randInt(1, k);
int k2 = randInt(k1, k); // Ensure k1 ≤ k2
// Output the query
outFile << n1 << " " << k1 << " " << n2 << " " << k2 << endl;
}
// Check if totalQ exceeds the limit and break if needed
if (totalQ >= 2*N) {
cout<<"break due to exeeding N"<<endl;
break;
}
}
// Close the file
outFile.close();
}
int main() {
srand(time(0)); // Seed for randomness
int numFiles = 5; // Number of output files
int maxT = 10000; // Maximum number of test cases per file (t)
int maxN = 1000; // Maximum value of n
int maxK = 1000; // Maximum value of k
int maxQ = 1000; // Maximum number of queries over all test cases
// Generate test files
// for (int i = 1; i <= numFiles; i++) {
// generateTestCase(i, maxT, maxN, maxK, maxQ);
// }
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ogICAgICAgIC8vIEdlbmVyYXRlIG4sIGssIGFuZCBxCiAgICAgICAgaW50IG4gPSByYW5kSW50KDEsIG1heE4pOwogICAgICAgIGludCBrID0gcmFuZEludCgxLCBtYXhLKTsKICAgICAgICAvLyBpbnQgcTsKICAgICAgICBpbnQgcSA9IHJhbmRJbnQoMSwgbWluKG1heFEsIG1heChOIC8gKHQgLSBpICsgMSksMikpKTsgLy8gRW5zdXJlIHN1bShxKSDiiaQgMiAqIDEwXjUKICAgICAgICB3aGlsZShxICsgdG90YWxRID4gTil7CgogICAgICAgICAgICBxID0gcmFuZEludCgxLCBtaW4oTi10b3RhbFEsIG1heChOIC8gKHQgLSBpICsgMSksMSkpKTsgLy8gRW5zdXJlIHN1bShxKSDiiaQgMiAqIDEwXjUKICAgICAgICAgICAgLy8gY291dDw8IkxPT1AiPDxlbmRsOwogICAgICAgICAgICAvLyBjb3V0PDxxPDxlbmRsOwogICAgICAgICAgICAvLyBjb3V0PDx0b3RhbFE8PGVuZGw7CiAgICAgICAgfQogICAgICAgIHRvdGFsUSArPSBxOwogICAgICAgIC8vIGNvdXQ8PHRvdGFsUTw8ZW5kbDsKICAgICAgICAvLyB0b3RhbFEgKz0gcTsKCiAgICAgICAgLy8gT3V0cHV0IG4sIGssIGFuZCBxIGZvciB0aGlzIHRlc3QgY2FzZQogICAgICAgIG91dEZpbGUgPDwgbiA8PCAiICIgPDwgayA8PCAiICIgPDwgcSA8PCBlbmRsOwoKICAgICAgICAvLyBHZW5lcmF0ZSBxIHF1ZXJpZXMKICAgICAgICBmb3IgKGludCBqID0gMDsgaiA8IHE7IGorKykgewogICAgICAgICAgICAvLyBHZW5lcmF0ZSBuMSwgbjIsIGsxLCBrMgogICAgICAgICAgICBpbnQgbjEgPSByYW5kSW50KDEsIG4pOwogICAgICAgICAgICBpbnQgbjIgPSByYW5kSW50KG4xLCBuKTsgLy8gRW5zdXJlIG4xIOKJpCBuMgogICAgICAgICAgICBpbnQgazEgPSByYW5kSW50KDEsI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