solution stringlengths 11 983k | difficulty int64 0 21 | language stringclasses 2
values |
|---|---|---|
#include <bits/stdc++.h>
using namespace std;
char buf[1 << 21], *p1 = buf, *p2 = buf, obuf[1 << 23], *O = obuf;
inline int read() {
int x = 0, sign = 0;
char s = getchar();
while (!isdigit(s)) sign |= s == '-', s = getchar();
while (isdigit(s)) x = (x << 1) + (x << 3) + (s - '0'), s = getchar();
return sign ... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void trace(const char* name, T&& arg1) {
cout << name << " : " << arg1 << endl;
}
template <typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args) {
const char* comma = strchr(names + 1, ',');
cout.write(names, comm... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int t, n, i;
long long l, r;
void afis(int n, int i, int l, int r) {
int val = n - i;
for (int j = l; j <= r; j++) {
if (j & 1)
cout << val << ' ';
else
cout << val + (j / 2) << ' ';
}
return;
}
int main() {
cin >> t;
for (; t; t--) {
cin... | 10 | CPP |
n_tests = int(input())
for _ in range(n_tests):
n_vertices, l, r = list(map(int, input().split()))
index = 0
i_v = None
for i_v in range(1, n_vertices):
n_indexes_here = (n_vertices - i_v) * 2
if l <= index + n_indexes_here:
break
else:
index += (n_vertice... | 10 | PYTHON3 |
from types import GeneratorType
def bootstrap(f, stack=[]):
def wrappedfunc(*args, **kwargs):
if stack:
return f(*args, **kwargs)
else:
to = f(*args, **kwargs)
while True:
if type(to) is GeneratorType:
stack.append(to)
... | 10 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const long long mod = (long long)1e9 + 7;
int t;
long long n, L, R;
long long a[500500], p[500500];
void solve() {
cin >> n >> L >> R;
a[1] = 2 * n - 2;
for (int i = 2; i <= n - 1; ++i) a[i] = a[i - 1] - 2;
a[n] = 1;
for (int i = 1; i <= n; ++i) p[i] = p[i - 1] + ... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
if (b == 0) return a;
return gcd(b, a % b);
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int tcase;
cin >> tcase;
for (int tc = 1; tc <= tcase; tc++) {
long long ... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
;
long long t;
cin >> t;
while (t--) {
long long n, l, r;
cin >> n >> l >> r;
if (n == 1) {
cout << "1" << endl;
continue;
}
long long x = 2 * (n ... | 10 | CPP |
import sys
t=int(sys.stdin.readline())
for _ in range(t):
n,l,r=map(int,sys.stdin.readline().split())
prev=0
cur=0
start=1
if l==r and l==n*(n-1)+1:
print(1)
else:
ans=[]
while(True):
cur+=(n-start)*2
if l<=cur:
pos=l-prev
... | 10 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T abs(T t) {
return t < 0 ? -t : t;
}
const long long modn = 1000000007;
inline long long mod(long long x) { return x % modn; }
const int MAXN = 212345;
int n, m, k;
long long l, r;
int s[MAXN];
vector<int> ans;
long long stp;
void add(int x) ... | 10 | CPP |
T = int(input())
for _ in range(T):
n, left, right = map(int, input().split())
l = [0]*n
l[1] = 2*n-2
for i in range(2, n):
l[i] = l[i-1]-2
l[-1] += 1
left_n = -1
right_n = -1
acc = 0
for i in range(1, n):
if acc+1<=left:
left_n = i
... | 10 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
const long long MOD = 998244353;
long long gcd(long long a, long long b) {
if (a < b) {
s... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
long long res = 1;
a %= mod;
assert(b >= 0);
for (; b; b >>= 1) {
if (b & 1) res = res * a % mod;
a = a * a % mod;
}
return res;
}
long long gcd(long long a, long long b) { re... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
void upgrade() {
ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
}
int main() {
upgrade();
int tc;
cin >> tc;
while (tc--) {
long long n, l, r;
cin >> n >> l >> r;
long long add = 2 * n - 2, cnt = 0, h = 1;
while (add != 0 && cnt +... | 10 | CPP |
import math
# решена
def task_1343_c():
b = int(input())
array = [int(num) for num in input().split()]
maxPositive = 0
minNegative = -10000000000
res = 0
for i in range(b):
if array[i] < 0:
if i != 0 and array[i - 1] >= 0:
res += maxPositive
... | 10 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 5, K = 11, M = N * 4;
const long long MOD = 998244353, oo = 1e9, OO = 1e18, mod = MOD;
const double pi = acos(-1), eps = 1e-17;
long long di[] = {0, 0, 1, -1};
long long dj[] = {1, -1, 0, 0};
int32_t main() {
ios_base::sync_with_stdio(false);
c... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)1e6 + 100;
const int mod = (int)1e9 + 7;
void solve() {
long long n, l, r;
scanf("%lld%lld%lld", &n, &l, &r);
long long pos = -1, pre = 0;
for (auto i = (1); i <= (n); ++i) {
long long now = (n - i) * 2;
if (now == 0) now = 1;
if (p... | 10 | CPP |
from sys import stdin,stdout
from math import gcd,sqrt,factorial,pi,inf
from collections import deque,defaultdict
from bisect import bisect,bisect_left
from time import time
from itertools import permutations as per
input=stdin.readline
R=lambda:map(int,input().split())
I=lambda:int(input())
S=lambda:input().rstrip('\r... | 10 | PYTHON3 |
import sys
import heapq
def input():
return sys.stdin.readline().strip()
def iinput():
return int(input())
def rinput():
return map(int, input().split())
def rlinput():
return list(map(int, input().split()))
def YES(flag):
if flag:
return "YES"
return "NO"
def main():
def F(... | 10 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
ifstream fin("input.txt");
ofstream fout("output.txt");
long long fast_exp(long long base, long long exp) {
long long res = 1;
while (exp > 0) {
if (exp % 2 == 1) res = (res * base) % 1000000007;
base = (base * base) % 1000000007;
exp /=... | 10 | CPP |
import sys
def minp():
return sys.stdin.readline().strip()
def mint():
return int(minp())
def mints():
return map(int, minp().split())
def stupid(x, n):
k = (n-1)*2
r = 0
while x >= k:
x -= k
r += 1
k -= 2
return r
def findl(x, n):
l, r = 0, n
while r - l > 1:
c = (l + r) // 2
if (2*n - 1 - c)*c... | 10 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
ll l, r;
cin >> l >> r;
ll idx = 1;
bool done = false;
for (int start = 1; start <= n; start++) {
if (idx ... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long next() {
long long x;
cin >> x;
return x;
}
const int maxn = 2e5 + 2, intf = 1e9;
const long long inf = 2e18, mod = 1e9;
const long double eps = 1e-6;
long long n;
void _print(long long bucket_id, long long l, long long r) {
if (l > r) return;
if (bucket... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long t, n, i, j, k, x, y, z, l, r, mid, q, m, ans, s;
vector<int> v[200005];
long long bs(long long l, long long r, long long z) {
long long ans = -1;
while (l <= r) {
mid = (l + r) >> 1;
if ((n - 1 + n - mid) * (mid) >= z) {
ans = mid;
r = mid ... | 10 | CPP |
#!/usr/bin/env python
# coding: utf-8
# In[48]:
#from __future__ import print_function
#from sys import stdin
# In[52]:
cases = int( input() )
# In[53]:
def ecycle(n,l,r):
l-=1
cnt = r - l
p = n-1
start = 1
while(l >= 2*p and p>0):
l -= 2*p
p -= 1
start += 1
... | 10 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t, i, j;
long long n, l, r, pos;
cin >> t;
while (t--) {
cin >> n >> l >> r;
pos = 1;
for (i = 1; i < n && pos < l; i++) {
pos += 2 * (n - i);
if (pos > l) {
pos -= 2 * (n... | 10 | CPP |
def check(x,n,l):
val = 2*n*x-(x*x)-x
if val < l:
return True
return False
def solve(n,l,r,ans):
low = 1
high = n-1
x = 0
while low <= high:
mid = (low+high)//2
if check(mid,n,l):
x = mid
low = mid+1
else:
high = mid-1
... | 10 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
long long n, t, l, r, start, star, have;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> t;
while (t--) {
cin >> n >> l >> r;
have = 0;
star = start = n + 1;
for (long long i = 1; i <= n; i++)
if (2LL * n * i - i * ... | 10 | CPP |
t = int(input())
for _ in range(t):
n, l, r = map(int, input().split())
l -= 1
r -= 1
start_i = 1
pos = 0
while start_i < n:
cur_i_len = 2 * (n-start_i)
if pos + cur_i_len > l:
break
pos += cur_i_len
start_i += 1
wanted_len = r-l+1
... | 10 | PYTHON3 |
R = lambda:map(int, input().split())
t = int(input())
def block(b, pos, n):
if pos%2 == 0: return b
return b + (pos+1)//2
def binary(k, n):
left, right = 1, n+1
while left <= right:
m = (left + right)//2
if m*(m+1) >= k > m*(m-1): return m
if m*(m+1) < k: left = m + 1
... | 10 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long int t;
cin >> t;
while (t--) {
long long int n, l, r;
cin >> n >> l >> r;
long long int count = 0;
long long int i = 1;
while (i < n) {
if (count + (2 * (n - i... | 10 | CPP |
#include <bits/stdc++.h>
const double PI =
3.141592653589793238462643383279502884197169399375105820974944;
using namespace std;
long long ModExp(long long x, long long y, long long m) {
long long res = 1;
x = x % m;
while (y > 0) {
if (y & 1) res = (res * x) % m;
y = y >> 1;
x = (x * x) % m;
}
... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e17 + 9;
long long n, l, r;
void calc(long long ly, long long faltl, long long faltr) {
if (ly == n) {
r = 1;
} else if (faltl >= 2 * n - ly * 2) {
calc(ly + 1, faltl - 2 * n + ly * 2, faltr);
} else {
long long ind = ly + 1;
lon... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long int power_mod(long long int a, long long int x) {
if (x == 0) return 1;
long long int y = power_mod(a, x / 2);
long long int ans = (y * y) % 1000000007;
if (x % 2) ans = (ans * a) % 1000000007;
return ans;
}
long long int inv(long long int a) { return po... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
inline long long read() {
register char c = ' ';
register long long v = 0, x = 1;
while ((c < '0') || (c > '9')) {
if (c == '-') x = -1;
c = getchar();
}
while ((c >= '0') && (c <= '9')) {
v = (v << 1) + (v << 3) + (c ^ 48);
c = getchar();
}
re... | 10 | CPP |
for _ in range(int(input())):
n, left, right = tuple(map(int, input().split()))
maximal = n * (n - 1) + 1
if left == maximal:
print('1')
continue
if right == maximal:
end_1 = True
else:
end_1 = False
a = []
summa = 0
i = (n - 1) * 2
cnt = 0
while ... | 10 | PYTHON3 |
def main():
for j in range(int(input())):
n,l,r=map(int,input().split())
b=1
for i in range(1,n):
a=b
b+=2*(n-i)
if l < b:
break
x,y=i,(l-a)//2+i+1
b=(l-a)%2
for _ in range(r-l):# Imprimo solo la cantidad necesari... | 10 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int gcdExtended(int a, int b, int *x, int *y) {
if (a == 0) {
*x = 0, *y = 1;
return b;
}
int x1, y1;
int gcd = gcdExtended(b % a, a, &x1, &y1);
*x = y1 - (b / a) * x1;
*y = x1;
return gcd;
}
long long int modInverse(int a, int m) {
int x, y;
int g... | 10 | CPP |
#!/usr/bin/env python
from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
from __builtin__ import xrange as range
from future_builtins import ascii, filter, hex, map, oct, zip
def solve():
n, l, r = [int(s) for s in input().stri... | 10 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const int SIZE = 1e5 + 9;
long long arr[SIZE];
int main() {
int t;
cin >> t;
while (t--) {
long long n, l, r;
cin >> n >> l >> r;
long long x = 2 * (n - 1);
arr[1] = x;
for (int i = 2; i < n; i++) {
x -= 2;
arr[i] = arr[i - 1] + x;
... | 10 | CPP |
import sys
# 2 -> 1 2 1
# 3 -> 1 2 1 3 2 3 1
# 4 -> 1 2 1 3 1 4 2 3 2 4 3 4 1
# 5 -> 1 2 1 3 1 4 1 5 2 3 2 4 2 5 3 4 3 5 4 5 1
# for X(k, 1): first 2(k-1) are 1, i; then (k-1)(k-2) are X(k-1, 2) ; then 1
# 2(k-1), 2(k-2), 2(k-3) ...
def binsearch(i, n):
last = n*(n-1)
ip = n*(n-1) - i
#p... | 10 | PYTHON3 |
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n, l, r = map(int, input().split())
num = r - l + 1
init_num = 1
index = 0
for i in range(1, n):
init_num = i
if l <= (n - i) * 2:
index = l
l = 0
bre... | 10 | PYTHON3 |
# Legends Always Come Up with Solution
# Author: Manvir Singh
import os
import sys
from io import BytesIO, IOBase
from math import floor,sqrt
def main():
for _ in range(int(input())):
n,l,r=map(int,input().split())
if l== n*(n-1)+1:
print(1)
continue
i=1
cnt... | 10 | PYTHON3 |
t = int(input())
for i in range(t):
n, l, r = map(int, input().split())
if l == n * (n - 1) + 1:
print(1)
else:
x = 1
summa = x * 2 * n
rasn = x * (x + 1)
while summa - rasn < l:
summa += 2 * n
rasn = (rasn // x) * (x + 2)
x += 1
... | 10 | PYTHON3 |
from sys import stdin, gettrace
from math import sqrt
if not gettrace():
def input():
return next(stdin)[:-1]
# def input():
# return stdin.buffer.readline()
def main():
def solve():
n,l,r = map(int, input().split())
lv = int((2*n+1 - sqrt((2*n-1)**2 -4*(l-1)))/2)
lvs = -... | 10 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int T;
long long N;
long long L, R;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> T;
for (long long t = 0; t < T; t++) {
cin >> N >> L >> R;
if (L == N * (N - 1) + 1 && L == R) {
cout << "1\n";
continue;
}
long long ini = ... | 10 | CPP |
from sys import stdin
input = stdin.buffer.readline
for _ in range(int(input())):
n, l, r = map(int, input().split())
l -= 1
r -= 1
flag, tmp, s = 1, 0, 0
ans = []
x, y = n, n - 1
for i in range(1, n):
s += 2 * (n - i)
if l < s and flag:
x, tmp = i, (i > 1) * (s - 2 * (n - i))
l -= tmp
flag = 0
if... | 10 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y, long long md = 1000000007LL) {
long long res = 1;
x %= md;
while (y > 0) {
if (y & 1) res = (res * x) % md;
x *= x;
if (x >= md) x %= md;
y >>= 1;
}
return res;
}
signed main() {
ios_base::sync_with_stdio... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
using namespace std;
inline int qpow(int b, int e, int m = 998244353) {
int a = 1;
for (; e; e >>= 1, b = (long long)b * b % m)
if (e & 1) a = (long long)a * b % m;
return a;
}
int n, m, q, k;
int a[300005], b[300005], c[300005];
const int pp[11] = {2, 3, 5, 7, 11... | 10 | CPP |
t = int(input())
for y in range(t):
n,l,r = list(map(int,input().split()))
if(l == n*(n-1)+1):
print(1)
continue
ind = 1
ct = 1
while(1):
if(l < ct):
break
ct += (n-ind)*2
ind += 1
ind -= 1
if (ct-l)%2 == 0:
st = ind
print(st,end = " ")
l += 1
st = n+1
for i in range(ct-1,l-1,-2):
st -= 1... | 10 | PYTHON3 |
from sys import stdin, gettrace
def input():
return stdin.buffer.readline()
t = int(input())
for _ in range(t):
n, l, r = list(map(int, input().split()))
count = 0
i = 1
while count < l:
if i == n:
i = 1
count += (n - i) * 2
i += 1
i -= 1
count -= (n -... | 10 | PYTHON3 |
import math
import sys
A = 1
B = 1
C = 1
K = 0
def LFromI(I):
return I*I*A + I*B + C
def IFromL(L):
return math.floor((-B+math.sqrt(B*B - 4*A*(C-L)))/(2*A))
def Out(l, R):
curint = IFromL(l)
curpos = LFromI(curint)
while curpos <= R:
if curint == K:
print(1, end=' ')
... | 10 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
int t = 1;
cin >> t;
while (t--) {
long long n, l, r;
cin >> n >> l >> r;
bool f = 0;
if (r == (n * (n - 1) + 1)) {
r--;
f = 1;
}
long long ans1 = (n - 1) * 2;
long long sum = ans1, pos = ... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long int max(long long int a, long long int b) {
if (a >= b)
return a;
else
return b;
}
long long int min(long long int a, long long int b) {
if (a <= b)
return a;
else
return b;
}
void solve() {
long long int n, l, r;
cin >> n >> l >> r;
... | 10 | CPP |
from bisect import bisect_left
def get(x, n):
if x==n: return [1]
return [a for i in range(x+1,n+1) for a in [x,i]]
def solve():
n,l,r = map(int,input().split())
cum = [0]*(n+1)
for i in range(1,n):
cum[i] = cum[i-1] + 2*(n-i)
cum[n] = cum[n-1] + 1
xL = bisect_left(cum, l)
xR =... | 10 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
long long t, n, l, r;
void stampa(int x, int y) {
if (r == 0) return;
cout << x << " ";
r--;
if (x == n && y >= n) return;
int succ;
if (y > x) {
succ = x + (y == n);
} else {
if (x == n) {
succ = y + 1;
} else {
succ = x + 1;
}
}... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long n;
void prnt(long long a, long long b, long long cnt) {
if (cnt) printf("%d ", a);
if (cnt < 2) return;
printf("%d ", b);
if (b != n)
prnt(a, b + 1, cnt - 2);
else if (a != n - 1)
prnt(a + 1, a + 2, cnt - 2);
else if (cnt > 2)
printf("1");
... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
void file() {}
signed main() {
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
;
long long t;
cin >> t;
while (t--) {
long long n, l, r;
cin >> n >> l >> r;
vector<long long> a;
long long cnt = 0, flag = 0;
for (long long i = 1; i <= n &&... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int T, n;
long long l, r;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> T;
while (T > 0) {
--T;
cin >> n >> l >> r;
long long s = 0;
for (int i = 1; i <= n; ++i) {
long long t = s + 1ll * 2 * (n - i);
... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long arr[200005];
long long solve(long long x, long long n) {
long long ind = lower_bound(arr + 1, arr + n, x) - arr;
x -= arr[ind - 1];
if (x & 1) return ind;
return x / 2 + ind;
}
int main() {
long long t;
cin >> t;
while (t--) {
long long n, l, r;
... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const long long N = 500005;
const long long M = 1000000007;
int main() {
long long t;
cin >> t;
while (t--) {
long long n, l, r;
cin >> n >> l >> r;
vector<long long> v;
v.push_back(1);
for (long long i = 1; i < n; i++) {
v.push_back(2 * i);
... | 10 | CPP |
def solve():
n, l, r = [int(i) for i in input().split()]
seq = []
i = 1
while l <= r:
while l > 2 * n - 2:
if l == 3:
i = 1
break
l -= 2 * n - 2
r -= 2 * n - 2
n -= 1
i += 1
if l%2 =... | 10 | PYTHON3 |
t = int(input())
def query(i, n, x):
if (x % 2 == 1):
return i
else:
return (i + x // 2)
for _ in range(t):
n, l, r = map(int, input().split())
i = 1
s = 0
includeOne = False
if r == n * (n - 1) + 1:
includeOne = True
r -= 1
if l == n * (n - 1) + 1:... | 10 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const int MAXN = 0;
const int MAXK = 0;
void solve() {
long long n, l, r;
cin >> n >> l >> r;
long long sum = 0;
f... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
void fun(long long start, long long end, long long l, long long r) {
long long n = end - start + 1;
for (long long i = max(1ll, l); i <= min(2 * (n - 1), r); i++) {
if (i % 2 == 0) {
cout << start + i / 2 << " ";
} else {
cout << start << " ";
}
... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
void _print(long long int t) { cerr << t; }
void _print(int t) { cerr << t; }
void _print(string t) { cerr << t; }
void _print(char t) { cerr << t; }
void _print(long double t) { cerr << t; }
void _print(double t) { cerr << t; }
void _print(long long unsigned t) { cerr << t... | 10 | CPP |
for t in range(int(input())):
n,l,r=map(int,input().split())
b=1
for i in range(1,n):
a=b
b+=2*(n-i)
if l<b:
break
x,y=i,(l-a)//2+i+1
b=(l-a)%2
for _ in range(r-l):
if b:
print(y,end=" ")
y+=1
if y==n+1:
x+=1
y=x+1
else:
print(x,end=" ")
... | 10 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
void print_pattern(long long row, long long col, long long count,
long long elements) {
if (elements == 0) {
cout << 1 << " ";
return;
}
long long x = row;
long long next_x = row + 1;
long long j = 0;
bool flag = 1;
while (j < elemen... | 10 | CPP |
#import math
#from functools import lru_cache
#import heapq
#from collections import defaultdict
#from collections import Counter
#from sys import stdout
#from sys import setrecursionlimit
from sys import stdin
input = stdin.readline
for ti in range(int(input().strip())):
n, l, r = [int(x) for x in input().strip()... | 10 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
void clock_out() {
cerr << "\nTime Elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
}
void fileio() {
freopen("/home/dwai/Desktop/cp/input.txt", "r", stdin);
freopen("/home/dwai/Desktop/cp/output.txt", "w", stdout);
freopen... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long z = 998244353;
long long gcd(long long a, long long b) {
if (a == 0) return b;
if (b == 0) return a;
return gcd(b, a % b);
}
long long power(long long a, long long b) {
long long res = 1;
while (b) {
if (b & 1) {
res = (res * a) % z;
b--;... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)2e9;
const long long inf = (long long)2e18;
const long double eps = (long double)1e-8;
const long long mod = (long long)1e9 + 7;
const long long MAXN = (long long)1e5 + 1;
const long long MAXC = (long long)1e6 + 1;
const long long MAXE = (lo... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
ifstream fin("input.txt");
ofstream fout("output.txt");
long long fast_exp(long long base, long long exp) {
long long res = 1;
while (exp > 0) {
if (exp % 2 == 1) res = (res * base) % 1000000007;
base = (base * base) % 1000000007;
exp /=... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long n;
long long l, r;
long long i;
cin >> n >> l >> r;
long long temp = l;
long long b = 1;
while (temp > 2 * (n - b) && b < n) {
temp = temp - 2 * (n - b);
b++;
}
for (... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long t, i, n, cnt, od, l, r, ev, g;
cin >> t;
while (t--) {
cin >> n >> l >> r;
g = 0;
if (r == (n * (n - 1)) + 1) {
g = 500;
}
i = 0;
while (i <= n - 1) {
if (2 * n * (i) - (i) * (i + 1) < l) {
i++;
... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int mods = 998244353;
const int maxn = 1e5 + 10;
const int N = 1e5 + 10;
const int E = 2e5 + 10;
long long n, l, r;
long long k[maxn];
vector<int> ans;
int main() {
int T;
cin >> T;
while (T--) {
cin >> n >> l >> r;
k[1] = 1;
for (int i = 2; i <= (n)... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const int LM = 3e5 + 4;
ll N;
ll L, R;
ll part[LM];
int main() {
int T;
scanf("%d", &T);
while (T--) {
scanf("%lld%lld%lld", &N, &L, &R);
bool e = 0;
if (R == N * (N - 1) + 1) {
e = 1;
R--;
}
... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7, MAX = 1e5 + 5;
long long powN(long long a, long long p) {
if (p == 0) return 1;
long long z = powN(a, p / 2);
z = (z * z) % MOD;
if (p % 2) z = (z * a) % MOD;
return z;
}
vector<bool> is_prime(MAX + 1, true);
void Sieve() {
is_prime[0] =... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
struct Edge {
long long to, dis, next, cost;
} edge[24050];
long long num = -1;
bool vis[10010];
long long mincost;
long long pre[10010], head[10010], cost[10010], last[10010], flow[10010], n, k,
a[110], b[110], s, t, maxflow;
long long to[110];
void add(long long f, ... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
void read(int &val) {
int x = 0;
int bz = 1;
char c;
for (c = getchar(); (c < '0' || c > '9') && c != '-'; c = getchar())
;
if (c == '-') {
bz = -1;
c = getchar();
}
for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9;
int solve() {
int n, k;
cin >> n >> k;
vector<pair<pair<int, int>, int>> arr(n);
for (int i = 0; i < n; i++)
cin >> arr[i].first.second >> arr[i].first.first, arr[i].second = i + 1;
sort(arr.begin(), arr.end());
vector<int> a(n), b(n);
... | 12 | CPP |
#include <bits/stdc++.h>
template <typename T>
bool ckmax(T& a, T b) {
return a < b ? a = b, 1 : 0;
}
template <typename T>
bool ckmin(T& a, T b) {
return b < a ? a = b, 1 : 0;
}
const int MN = 80;
int N, K, T, dp[MN][MN], ans;
bool u[MN], pr[MN][MN];
struct minion {
public:
int a, b, id;
void in() { scanf("%d... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 80;
const int INF = 1000000009;
struct ban {
int i;
int a, b;
};
bool operator<(const ban& t1, const ban& t2) { return t1.b < t2.b; }
int n, k;
ban t[N];
int dp[N][N];
... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
int dp[76][76];
bool taken[76][76];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t, n, m;
cin >> t;
while (t--) {
cin >> n >> m;
vector<pair<pair<int, int>, int>> data(n);
for (int i = 0; i < n; ++i) {
cin >> data[i].first.second >>... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void r1(T &x) {
x = 0;
char c(getchar());
int f(1);
for (; c < '0' || c > '9'; c = getchar())
if (c == '-') f = -1;
for (; '0' <= c && c <= '9'; c = getchar()) x = (x * 10) + (c ^ 48);
x *= f;
}
template <typename T, typename... Args>
i... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
class Debugger {
public:
template <typename T>
Debugger &operator<<(const T &v) {
cerr << v;
return *this;
}
~Debugger() { cerr << endl; }
};
template <typename T1, typename T2>
inline ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
return os <<... | 12 | CPP |
#include <bits/stdc++.h>
#pragma GCC target("avx2,avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ull = unsigned long long;
using i128 = __int128_t;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln = '\n';
istrea... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
using li = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using matr = vector<vi>;
const int INF = 1e9 + 13;
vector<int> hungary(vector<vector<int>> a) {
int n = a.size() - 1;
int m = n;
vector<int> u(n + 1), v(m + 1), p(m + 1),... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
void read(long long &x) {
char ch = getchar();
x = 0;
while (!isdigit(ch)) ch = getchar();
while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
}
const long long N = 77;
long long n, k, f[N][N], g[N][N];
pair<long long, pair<long long, long long> > a[N];
vector... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
x = 0;
int f = 1;
char ch = getchar();
while (!isdigit(ch)) {
if (ch == '-') f = -1;
ch = getchar();
}
while (isdigit(ch)) {
x = x * 10 + ch - '0';
ch = getchar();
}
x *= f;
}
inline void write(int x) {... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
template <typename T, typename S>
inline void chkmin(T &a, const S &b) {
a = a < b ? a : b;
}
template <typename T, typename S>
inline void chkmax(T &a, const S &b) {
a = a > b ? a : b;
}
const int MAXN = 80;
struct Data {
int a, b, id;
} dat[MAXN];
int f[MAXN][MAXN],... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vc<vc<T>>;
template <class T>
void mkuni(vector<T>& v) {
sort(v.begin(), v.end());
v.erase(unique(v.begin(), v.end()), v.end());
}
template <class T>
void print(T x, int suc = 1) {
cout << x;
if... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
x = (x << 3) + (x << 1) + (c ^ 48);
c = getchar();
}
return f == 1 ? x : -x;
}
inline v... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
pair<pair<int, int>, int> ba[102];
int g[102][102], dp[102][102];
int ans[102];
vector<int> ansvec;
bool compba(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
if (a.first.first != b.first.first) return a.first.first < b.first.first;
return a.first.second < ... | 12 | CPP |
#include <bits/stdc++.h>
template <typename T>
bool ckmax(T& a, T b) {
return a < b ? a = b, 1 : 0;
}
template <typename T>
bool ckmin(T& a, T b) {
return b < a ? a = b, 1 : 0;
}
const int MN = 80;
int N, RK, T, dp[MN][MN], ans;
bool u[MN], pr[MN][MN];
struct minion {
public:
int a, b, id;
void in() { scanf("%... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
inline int add(int _a, int _b) {
if (_a < 0) {
_a += 1000000007;
}
if (_b < 0) {
_b += 1000000007;
}
if (_a + _b >= 1000000007) {
return _a + _b - 1000000007;
}
return _a + _b;
}
inline int mul(int _a, int _b) {
if (_a < 0) {
_a += 1000000007... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n, k;
cin >> n >> k;
vector<int> a(n), b(n);
for (int i = 0; i < n; ++i) {
cin >> a[i] >> b[i];
}
vector<vector<long long>> dp(n + 1, vector<long long>(k + 2, 0));
vector<vector<int>> p(n + 1, vector<int>(k + 2));
vector<int> id(n);
... | 12 | CPP |
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <typename T>
T sqr(T a) {
return a * a;
}
template <typename T>
int sign(T a) {
if (a == 0) return 0;
return (a > 0 ? 1 : -1);
}
template <typename T>
bool uax(T& a,... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
return os << "(" << x.first << "," << x.second << ")";
}
int main() {
int T;
scanf("%d", &T);
while (T--) {
int n, k;
scanf("%d%d", &n, &k);
vector<pair<pair<int, i... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
inline int read() {
register int t = 0;
register char v = getchar();
while (v < '0') v = getchar();
while (v >= '0') t = (t << 3) + (t << 1) + v - 48, v = getchar();
return t;
}
int f[76][76], n, m, t, v[76][76], ans[76], cnt, pos;
struct node {
int x, y, id;
... | 12 | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.