67 Easter Egg!

Given an integer $N$. Determine whether $N$ could be formed by $6x + 7y$ for non-negative integers $x$ and $y$.

Input

The first line contains a single integer $T$ ($1 \le T \le 10^5$), representing the number of test cases. Each of the next $T$ lines contains an integer $N$ ($0 \le N \le 10^{67}$).

Output

For each test case, output Yes if $N$ can be expressed as $6x + 7y$ for any $x, y \ge 0$, and No otherwise.

Hint

Add cin.tie(nullptr)->ios::sync_with_stdio(0); to your first line of code in int main(){} and change every endl to '\n' if you face marginal time limit exceed. This can optimise around 100 ms.

Subtasks

Subtask 1 (67 pts): $T \le 100$ and $N \le 100$
Subtask 2 (26.3 pts): $T \le 10^5$ and $N \le 10^5$
Subtask 3 (6.7 pts): No additional constraints

Reminder: The normal version shall prevail for all testing and scoring.

Given an integer $N$. Determine whether $N$ could be formed by $6x + 7y$ for non-negative integers $x$ and $y$, so you'll think of 67 when you see $N$.

Input

The first line contains a single integer $T$ ($1 \le T \le 10^6$ or $10^7$), representing the number of test cases. Each of the next $T$ lines contains an integer $N$ ($0 \le N \le 10^{67}$).

Output

For each test case, output Yes if $N$ can be expressed as $6x + 7y$ for any $x, y \ge 0$, and No otherwise, or output 67 to get a score of $67 - 67$.

Hint 67

If you get $67-67$ score after 67 trials of exceeding the time limit of 670 ms, add cin.tie(nullptr)->ios::sync_with_stdio(0); in the first line of int main(){}, you can probably get a score of $>= 67$, or still a score of $67 - 67$, if your original code is really 67 or because you have typed cin.tie(nullptr)->ios::sync_with_stdio(67);. Also, your code is so 67 because you used endl, replace all of them with '\n' or 67. Addtionally, you may consider adding #pragma GCC optimize ("Ofast") below using namespace std; or #pragma GCC optimize ("67ast") if you still get a score of $67 - 67$, although the Ofast one may only speed your code up for ~0.067 seconds Also, adding 67 pragmas are also considerable. Still failing? Try 67 more times until you reach 67 years old.

67 Pragmas Edition

// ==========================================
// THE PRAGMA COLLECTIONS (67 TOTAL)
// ==========================================

// --- [STANDARD & COMMON] (1-3) ---
#pragma once // 1. Modern header guard
#pragma STDC FENV_ACCESS ON // 2. Access floating-point environment
#pragma STDC FP_CONTRACT OFF // 3. Prevent floating-point contractions

// --- [MSVC: COMPILER & LINKER] (4-15) ---
#ifdef _MSC_VER
#pragma message("MSVC Build") // 4. Print message during build
#pragma warning(disable: 4996) // 5. Suppress specific warning
#pragma warning(push) // 6. Save warning state
#pragma warning(pop) // 7. Restore warning state
#pragma comment(lib, "user32") // 8. Link to system library
#pragma comment(linker, "/W3") // 9. Pass switch to linker
#pragma intrinsic(abs) // 10. Use hardware intrinsic for abs
#pragma function(memset) // 11. Force function call for memset
#pragma inline_depth(10) // 12. Set inlining recursion depth
#pragma inline_recursion(on) // 13. Enable recursive inlining
#pragma optimize("gp", on) // 14. Global optimizations + Frame pointers
#pragma component(browser, off) // 15. Disable browser info (.bsc)
#endif

// --- [GCC/CLANG: OPTIMIZATION & DIAGNOSTICS] (16-35) ---
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic push // 16. Save diagnostic state
#pragma GCC diagnostic pop // 17. Restore diagnostic state
#pragma GCC diagnostic ignored "-Wunused" // 18. Ignore specific warning
#pragma GCC diagnostic error "-Wall" // 19. Upgrade warnings to errors
#pragma GCC optimize("Ofast") // 20. Aggressive optimization
#pragma GCC optimize("unroll-loops") // 21. Unroll loops for speed
#pragma GCC optimize("inline") // 22. Aggressive inlining
#pragma GCC optimize("strict-aliasing") // 23. Assume strict aliasing
#pragma GCC target("avx") // 24. Target AVX instructions
#pragma GCC target("sse4") // 25. Target SSE4 instructions
#pragma GCC visibility push(default) // 26. Export symbols
#pragma GCC visibility pop // 27. Restore visibility
#pragma GCC poison goto // 28. Ban the 'goto' keyword
#pragma GCC system_header // 29. Ignore warnings in this file
#pragma GCC dependency "a.h" // 30. Check file timestamp
#pragma clang optimize off // 31. Disable Clang optimizations
#pragma clang optimize on // 32. Re-enable Clang optimizations
#pragma clang loop unroll(enable)// 33. Force Clang loop unroll
#pragma clang loop vectorize(enable) // 34. Force Clang vectorization
#pragma GCC optimize("no-stack-protector") // 35. Disable stack protection
#endif

// --- [DATA SEGMENTATION & ALIGNMENT] (36-45) ---
#ifdef _MSC_VER
#pragma pack(push, 1) // 36. Start 1-byte alignment
#pragma pack(pop) // 37. End alignment
#pragma data_seg(".my_data") // 38. Custom initialized data segment
#pragma data_seg() // 39. Reset data segment
#pragma bss_seg(".my_bss") // 40. Custom uninitialized data segment
#pragma bss_seg() // 41. Reset bss segment
#pragma const_seg(".my_const") // 42. Custom constant segment
#pragma const_seg() // 43. Reset const segment
#pragma code_seg(".my_code") // 44. Custom code segment
#pragma code_seg() // 45. Reset code segment
#endif

// --- [OPENMP: PARALLEL PROCESSING] (46-57) ---
void parallel_test() {
#pragma omp parallel // 46. Start parallel region
#pragma omp for // 47. Parallelize for-loop
for(int i=0; i<10; i++){}
#pragma omp sections // 48. Split tasks into sections
{
#pragma omp section // 49. Section 1
{}
}
#pragma omp single // 50. Execute by one thread only
#pragma omp master // 51. Execute by master thread only
#pragma omp critical // 52. Mutex-protected region
#pragma omp atomic // 53. Atomic memory update
#pragma omp barrier // 54. Synchronize threads
#pragma omp flush // 55. Synchronize memory
#pragma omp ordered // 56. Execute in loop order
#pragma omp task // 57. Deferred unit of work
}

// --- [IDE & MISC] (58-67) ---
#pragma region CustomRegion // 58. Visual Studio Code folding start
#pragma endregion // 59. Visual Studio Code folding end
#ifdef _MSC_VER
#pragma alloc_text("code", main)// 60. Name the section for 'main'
#pragma auto_inline(on) // 61. Let compiler decide on inlining
#pragma check_stack(on) // 62. Enable stack probes
#pragma conform(forScope, on) // 63. Force Standard 'for' scope
#pragma execution_character_set("utf-8") // 64. Set execution charset
#pragma managed // 65. Compile as managed (CLR)
#pragma unmanaged // 66. Compile as native (CLR)
#pragma runtime_checks("s", on) // 67. Enable stack frame checks
#endif

Subtasks

Subtask 1 (67 pts): $T \le 100$ and $N \le 100$ and $67 = 67$
Subtask 2 ($26.7-0.4$ pts): $T \le 6^7$ and $N \le 6^7$ ($6^7$ is approximately $2\times10^5$)
Subtasks 6-7 (6.7 pts): No additional 67 constraints

Sample Test Cases

Input Output
5
0
1
6
8
13
Yes
No
Yes
No
Yes
1
676767676767676767676767676767676767676767676767676767676767676767
Yes
This test case satisfies the constraints of Subtask 6-7.
Click to copy.

Scoring: Per Subtask
Authored by wy24180
Appeared in WYHK 2026 Mini Contest 2