Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
788_A. Functions again
Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is defined as...
2
7
import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.Arrays; import java.util.Scanner; public class Main{ public static long getAns(int[] s,int n){ long maxSum = 0; long thisSum = 0; for(int i = 1;i<n;i++){ thisSum+=s[i]; ...
JAVA
788_A. Functions again
Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is defined as...
2
7
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.OutputStream; import java.io.Writer; import java.util.InputMismatchException; import java.io.IOException; import java.io.File; import java.io.FileNotFoundException; import java.io.InputStream;...
JAVA
788_A. Functions again
Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is defined as...
2
7
import java.util.Scanner; import java.util.stream.IntStream; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n]; for (int i = 0; i < a.length; i++) { a[i] = sc.nextInt(); } System.out.println(solve(a)); sc.clo...
JAVA
788_A. Functions again
Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is defined as...
2
7
input() numbers = [int(x) for x in input().split()] diffs = [] sum_odd, sum_even = 0, 0 for x in range(len(numbers)-1): diffs.append(abs(numbers[x] - numbers[x+1])) _max = 0 for x in range(len(diffs)): aux = diffs[x] if x % 2 == 1: aux *= -1 sum_even += aux sum_odd -= aux if sum_even < 0: sum_even = 0 if sum_odd...
PYTHON3
788_A. Functions again
Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is defined as...
2
7
#include <bits/stdc++.h> const int N = 1000005; using namespace std; long long n, a[N]; long long b[N], c[N]; int main() { ios::sync_with_stdio(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } for (int i = 1; i < n; i++) { int t = abs(a[i] - a[i + 1]); if (i & 1) { b[i] = t; ...
CPP
788_A. Functions again
Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is defined as...
2
7
#include <bits/stdc++.h> using namespace std; const int maxn = 110000; int n; long long arr[maxn]; long long pre1[maxn], pre2[maxn]; long long dp1[maxn], dp2[maxn]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%lld", &arr[i]); for (int i = 1; i < n; i++) { pre1[i] = abs(arr[i] - arr[i + 1...
CPP
788_A. Functions again
Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is defined as...
2
7
import java.util.Arrays; import java.util.Scanner; public class FunctionsAgain { static long [][] dp; static long maxVal; static void max(int index, int [] mods) { //System.out.println("index:"+index+", len:"+mods.length); if(index >= mods.length ) return; if (dp[0][index+1] == ...
JAVA
788_A. Functions again
Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is defined as...
2
7
#include <bits/stdc++.h> using namespace std; int n; long long a[100005], t, ans, tot, sum, x[100005], y[100005]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) cin >> a[i]; t = -1; for (int i = 1; i <= n; i++) { t *= -1; x[i] = abs(a[i] - a[i + 1]) * t; } t = 1; for (int i = 1; i <= n...
CPP
788_A. Functions again
Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is defined as...
2
7
n = int(input()) a = [int(i) for i in input().split()] b = [abs(a[i] - a[i+1]) for i in range(n-1)] n -= 1 def fn(i0): f0 = 0 ans=0 for i in range(i0, n): if (i-i0)&1: f0 -= b[i] if f0 < 0: f0 = 0 else: f0 += b[i] ans = max(ans, f0) retu...
PYTHON3
788_A. Functions again
Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is defined as...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class C{ public static void main(String[] args) { FastScanner scan = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int n = scan.n...
JAVA
788_A. Functions again
Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is defined as...
2
7
#include <bits/stdc++.h> using namespace std; void Solve() { long long n; cin >> n; long long a[n + 1]; for (int i = 1; i <= n; i++) cin >> a[i]; long long b[n]; for (int i = 1; i < n; i++) b[i] = abs(a[i] - a[i + 1]); long long mx[n + 1], mn[n + 1]; mx[n] = 0; mn[n] = 0; long long ans = LLONG_MIN; ...
CPP
788_A. Functions again
Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is defined as...
2
7
//189301019.akshay import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.Random; import java.util.Arrays; import java.util.StringTokenizer; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.u...
JAVA
788_A. Functions again
Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is defined as...
2
7
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false), cin.tie(NULL); int n; while (cin >> n) { long long a[n]; for (int i = 0; i < n; i++) cin >> a[i]; if (n == 2) { cout << abs(a[0] - a[1]) << endl; continue; } long long ar1[n - 1], ar2[n - 2]; ...
CPP
788_A. Functions again
Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is defined as...
2
7
#------------------------template--------------------------# import os import sys from math import * from collections import * from fractions import * from bisect import * from heapq import* from io import BytesIO, IOBase def vsInput(): sys.stdin = open('input.txt', 'r') sys.stdout = open('output.txt', 'w') BUF...
PYTHON3
788_A. Functions again
Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is defined as...
2
7
n = int(input()) arr = list(map(int, input().split())) def function(n, arr): dp = {} for i in range(1, n): temp, dp[i] = abs(arr[i] - arr[i - 1]), {} if i == 1: dp[i][0], dp[i][1] = temp, 0 else: dp[i][0] = max(dp[i - 1]...
PYTHON3
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
import java.util.*; public class C{ final int MOD = (int)1e9 + 7; long get(int x, int y, int lim){ if (Math.min(x,y) < 0) return 0L; long[][][][] d = new long[32][2][2][2], sm = new long[32][2][2][2]; d[31][1][1][1] = 1; for (int w = 30; w >= 0; w--) for (int a = 0; a < 2; a++) for (int b = 0; b < ...
JAVA
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; void addmod(long long int &a, long long int b) { a += b; if (a >= 1000000007) a -= 1000000007; if (a < 0) a += 1000000007; } void multmod(long long int &a, long long int b) { a *= b; a %= 1000000007; } long long int solve(int x, int y, int k) { if (x < 0 || y < ...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int nx, ny, nz; bool g[32][2][2][2]; pair<int, int> f[32][2][2][2]; void add(pair<int, int> &x, pair<int, int> y) { x.first = (x.first + y.first) % mod; x.second = (x.second + y.second) % mod; } pair<int, int> F(int p, int x, int y, int z) { p...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const long long mo = 1e9 + 7; long long _; long long x1, kjhjk, x2, dfdfd, k; long long a[40], b[40], c[40]; long long dp1[40][2][2][2], dp2[40][2][2][2]; long long solve(long long x, long long y) { if (x < 0 || y < 0 || k < 0) return 0; long long i; memset(dp1, 0, si...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; inline long long read() { long long x = 0, f = 1; char a = getchar(); while (a < '0' || a > '9') { if (a == '-') f = -1; a = getchar(); } while (a >= '0' && a <= '9') x = x * 10 + a - '0', a = getchar(); return x * f; } int solve(int x, int y, int k, int...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const int MAX_N = 33; const long long MOD = 1000000007; long long dp[MAX_N][2][2][2]; long long numb[MAX_N][2][2][2]; int query; int X1, Y1, X2, Y2, k; vector<int> change(int r) { vector<int> res; for (int i = 0; i < 31; i++) { if ((long long)r & (1LL << (long long)...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; int f[32][2][2][2], g[32][2][2][2], q; inline int rd() { int x = 0; char ch = getchar(); for (; ch < '0' || ch > '9'; ch = getchar()) ; for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0'; return x; } inline void print(int x) { static char s...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
import java.io.*; import java.util.Arrays; import java.util.StringTokenizer; public class Solution { private static String inputFilename = "input.txt"; private static String outputFilename = "output.txt"; private BufferedReader in; private StringTokenizer line; private PrintWriter out; private...
JAVA
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; inline int M(int x) { return (x >= 1000000007) ? (x - 1000000007) : x; } inline int M1(int x) { return (x < 0) ? (x + 1000000007) : x; } int n, m, K, len; bool vis[32][2][2][2]; pair<int, int> f[32][2][2][2]; pair<int, int> dfs(int x, bool f1, bool f2, bool f3) { if (x > ...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const int INF = 1 << 30; const long long int MAX = 1e9 + 7; void array_show(int *array, int array_n, char middle = ' ') { for (int i = 0; i < array_n; i++) printf("%d%c", array[i], (i != array_n - 1 ? middle : '\n')); } void array_show(long long int *array, int array_...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const int maxn = 40; const long long mod = 1000000007; long long f[maxn][2][2][2]; long long sum[maxn][2][2][2]; long long solve(int a, int b, int k) { if (a < 0 || b < 0 || k < 0) return 0; memset(f, 0, sizeof(f)); memset(sum, 0, sizeof(sum)); for (int s1 = 0; s1 <...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; /** * @author Don Li */ public class FindACar { int N = 30; int MOD = (int) 1e9 + 7; int a, b, c; int[][][][] dp = new int[N + 1][2...
JAVA
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; int q; long long a, b, u, v, k; long long calc(long long u, long long v, long long k, long long o = 0) { if (u > v) swap(u, v); if (u < 1 || k <= 0) return 0; long long p = 1, res = 0; while (p * 2LL <= v) p *= 2LL; long long tmp = m...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; inline int read() { char c = getchar(); int p = 1, ret = 0; while ((c < '0') || (c > '9')) { if (c == '-') p = -1; c = getchar(); } while ((c >= '0') && (c <= '9')) ret = (ret << 1) + (ret << 3) + c - '0', c = getchar(); return ret * p; } int n; int ...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const int mo = 1000000007; int lx[55], ly[55], rx[55], ry[55]; int v[55], vis[55][2][2][2][2][2]; pair<int, int> f[55][2][2][2][2][2]; pair<int, int> F(int d, int v1, int v2, int v3, int v4, int v5) { if (d == -1) return pair<int, int>(0, 1); if (vis[d][v1][v2][v3][v4][...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const long long p = 1e9 + 7; long long read() { long long s = 0; char c = getchar(), lc = '+'; while (c < '0' || '9' < c) lc = c, c = getchar(); while ('0' <= c && c <= '9') s = s * 10 + c - '0', c = getchar(); return lc == '-' ? -s : s; } void write(long long x) ...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; int cond = 0, multi = 1, gcj = 0; const int MOD = (int)1e9 + 7; unordered_map<long long, array<long long, 2> > cache; array<long long, 2> dp(int r, int c, int k, int len) { if (r <= 0 || c <= 0 || k <= 0) return array<long long, 2>(); k = min(k, len); r = min(r, len);...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 0; char ch = getchar(); for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = 1; for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - 48; return f ? -x : x; } inline void write(long long...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5, mod = 1e9 + 7, M = 1e9 + 5; int inx1, iny1, inx2, iny2, k; bool dInc(int x, int y, int len) { int x2 = x + len - 1, y2 = y + len - 1; return (x2 < inx1 || x > inx2 || y2 < iny1 || y > iny2); } int getSum(unsigned long long x) { return ((x * (x + 1...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; using ld = long double; const int mod = 1000000007; struct Mod { public: int num; Mod() : Mod(0) { ; } Mod(long long int n) : num((n % mod + mod) % mod) { static_assert(mod < INT_MAX / 2, "mod is too big, please m...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; inline long long read() { long long s = 0, t = 1; char c = getchar(); while (!isdigit(c)) { if (c == '-') t = -1; c = getchar(); } while (isdigit(c)) s = s * 10 + c - 48, c = getchar(); return s * t; } const int N = 3e5 + 5, p = 1e9 + 7; inline void Max(...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
mod = 1000000007 def sum(x,y,k,add) : if k<add:return 0 up=x+add if up>k:up=k add=add+1 return y*(((add+up)*(up-add+1)//2)%mod)%mod def solve(x,y,k,add=0) : if x==0 or y==0:return 0 if x>y:x,y=y,x pw = 1 while (pw<<1)<=y:pw<<=1 if pw<=x:return (sum(pw,pw,k,add)+sum(pw,x+y-pw-pw,k...
PYTHON3
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; int q; long long int x1; long long int my1; long long int x2; long long int y2; long long int k; long long int stage[32]; long long int width[32]; long long int height[32]; long long int dp[32][2][4]; long long int num[32][2][4]; bool exist[32][2][4]; long long int calc(int...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; using namespace placeholders; template <class T> void mini(T &l, T r) { l = min(l, r); } template <class T> void maxi(T &l, T r) { l = max(l, r); } template <class TH> void _dbg(const char *sdbg, TH h) { cerr << sdbg << "=" << h << "\n"; } template <class TH, class......
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const int md = 1e9 + 7; void Rd(int &res) { res = 0; static char c; while (c = getchar(), c < 48) ; do res = (res << 1) + (res << 3) + (c ^ 48); while (c = getchar(), c > 47); } void Add(int &x, int y) { x += y; if (x >= md) x -= md; } int dp[2][2][2][2], ...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; void add(int &x, int y) { x += y; if (x >= mod) x -= mod; } int mult(int x, int y) { return (1ll * x * y) % mod; } int dp1[55][2][2][2]; int dp2[55][2][2][2]; int query(int x, int y, int k) { if (k < 0 || x < 0 || y < 0) return 0ll; memset(d...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; int dp[2][2][2], oldDp[2][2][2], cnt[2][2][2], oldCnt[2][2][2]; const int mod = 1e9 + 7; int add(int x, int y) { int ans = x + y; if (ans >= mod) ans -= mod; return ans; } int subtract(int x, int y) { if (x >= y) return x - y; return x - y + mod; } int mul(int x, ...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; int l, r, u, d, k; int bin(int a, int i) { return a & ((1 << i) - 1); } int sum(int k) { return 1LL * (1 + k) * k / 2 % MOD; } void add(int &a, int b) { if ((a += b) >= MOD) a -= MOD; } int dfs(int i, int a, int b, int k, int d = 0) { if (i < 0)...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; long long M = 1000000007; long long S(long long n, long long k) { long long mi = min(n, k); return (mi * (mi + 1) / 2) % M; } long long Q2(long long y, long long x, long long k, long long delta) { if (k - delta <= 0) return 0; if (x > y) swap(x, y); if (x == 0 || ...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; int mod_plus(int a, int b) { a += b; if (a >= 1000000007) a -= 1000000007; return a; } int mod_mul(long long a, long long b) { return (a * b) % 1000000007; } int pw2[55]; int dp[55][4][4][2], sum[55][4][4][2]; long long X1, X2, Y1, Y2, val; int solve(int bit, int xst,...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; inline long long read() { long long x = 0, f = 1; char c = getchar(); while ((c < '0' || c > '9') && (c != '-')) c = getchar(); if (c == '-') f = -1, c = getchar(); while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar(); return x * f; } const int mod =...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const int MAXN = 500010; const int mod = 1000000007; int k, a, b; int memo1[40][2][2][2]; int count(int i, bool limk, bool lima, bool limb) { if (k < 0 || a < 0 || b < 0) return 0; if (i == -1) return 1; int &ret = memo1[i][limk][lima][limb]; if (ret != -1) return r...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const int max_n = 3e5 + 5; const int mod = 1e9 + 7; int maska[35]; int maska2[35]; int rob2(int a, int b, int k) { if (b < a) return rob2(b, a, k); int ans = 0; for (int i = (0); i < (30); ++i) { if (!(a & (1 << i))) continue; for (int j = (0); j < (30); ++j) ...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; struct Typ { int sum, g; Typ(int a = 0, int b = 0) { sum = a, g = b; } }; Typ dp[35][2][2][2]; bool vis[35][2][2][2]; inline void add(int &a, int b) { a += b; if (a >= mod) a -= mod; } Typ dfs(int w, int px, int py, int pk, int ux, int uy, i...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const int M = 1e9 + 7; int q, dp[31][8], sum[30][8], k; void add(int &a, int b) { a += b; if (a >= M) a -= M; } void sub(int &a, int b) { a -= b; if (a < 0) a += M; } int find(int x, int y) { if (x < 0 || y < 0) return 0; int ret = 0; memset(dp, 0, sizeof dp);...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int q, k; int sum(int l, int r) { if (l > r) return 0; return (long long)(l + r) * (r - l + 1) / 2 % mod; } int solve(int x, int y, int h) { if (x <= 0 || y <= 0) return 0; int mx = max(x, y), t = 1, tmp = 0; if (y > x) swap(x, y); while...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; int q, i, f[40][2][2][2], g[40][2][2][2]; int read() { char c = getchar(); int w = 0; while (c < '0' || c > '9') c = getchar(); while (c <= '9' && c >= '0') { w = w * 10 + c - '0'; c = getchar(); } return w; } void add(int &x,...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> long long int n, m, k; long long int dp_cnt[35][2][2][2] = {}; long long int dp_sum[35][2][2][2] = {}; void reset_dp_cnt() { for (int i = 0; i < 35; i++) { dp_cnt[i][0][0][0] = -1; dp_cnt[i][0][0][1] = -1; dp_cnt[i][0][1][0] = -1; dp_cnt[i][0][1][1] = -1; dp_cnt[i][1][0][0...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 7; const int MAXN = 1e3 + 7; const int MOD = 1e9 + 7; int n; int dp[34][2][2][2]; int sum[34][2][2][2]; int x, y, k; int dfs(int pos, int limx, int limy, int limk, int &t) { if (pos == -1) return 1; int &st = sum[pos][limx][limy][limk]; if (~dp[p...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> string print_iterable(T1 begin_iter, T2 end_iter, int counter) { bool done_something = false; stringstream res; res << "["; for (; begin_iter != end_iter and counter; ++begin_iter) { done_something = true; counter--; r...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> const int mu = 1e9 + 7; void reduce(int &x) { x += x >> 31 & mu; } int m, x, y, xx, yy, k, dp[33][2][2][2], sum[33][2][2][2]; int DP(int x, int y, int k) { memset(dp, 0, sizeof(dp)); memset(sum, 0, sizeof(sum)); dp[31][1][1][1] = 1; if (x < 0 || y < 0) return 0; for (int i = 30; i >= ...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> void chkmin(T1 &x, T2 y) { if (x > y) x = y; } template <typename T1, typename T2> void chkmax(T1 &x, T2 y) { if (x < y) x = y; } namespace fastio { char rbuf[1 << 23], *p1 = rbuf, *p2 = rbuf, wbuf[1 << 23], *p3 = wbuf; inline char ge...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const int P = 1e9 + 7; int q; long long f[40][5][5][5], g[40][5][5][5]; inline long long calc(int x, int y, int n) { if (x < 0 || y < 0) return 0; long long ret = 0; for (int i = 0; i <= 1; i++) for (int j = 0; j <= 1; j++) for (int k = 0; k <= 1; k++) f[32]...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; int MOD = 1000 * 1000 * 1000 + 7; long long SUP = (long long)1024 * 1024 * 1024; int nbReqs; long long ax, ay, bx, by, k; long long getSomme(long long x = 0, long long y = 0, long long taille = SUP, long long deb = 0) { if (bx <= x || by <= y || x + tai...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int q, x_1, y_1, x_2, y_2, k, len, a[35], b[35], c[35]; pair<int, int> dp[35][2][2][2]; int Add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; } int Minus(int a, int b) { return a < b ? a - b + mod : a - b; } pair<int, int> operator+(pai...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const int K = 40; const long long md = 1e9 + 7; pair<long long, long long> f[K][2][2][2]; bool us[K][2][2][2]; bool X[K], Y[K], KK[K]; pair<long long, long long> calc_prefix(long long t, bool eq_x, bool eq_y, bool eq_k) { if (t == 0)...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const int mod = (int)1e9 + 7; pair<pair<int, int>, pair<int, int> > cut( pair<pair<int, int>, pair<int, int> > a, pair<pair<int, int>, pair<int, int> > b) { return pair<pair<int, int>, pair<int, int> >( pair<int, int>(max(a.first.first, b.first.first), ...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; long long qpow(long long x, long long y) { long long e = 1; while (y) { if (y % 2) e = (e * x) % 1000000007; x = x * x % 1000000007; y /= 2; } return e; } long long low(long long x) { for (long long i = 1; i <= x; i <<= 1) { if (i << 1 > x) return ...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; inline int readInt() { static int n, ch; n = 0, ch = getchar(); while (!isdigit(ch)) ch = getchar(); while (isdigit(ch)) n = n * 10 + ch - '0', ch = getchar(); return n; } const int MAX_N = 200 + 3, MOD = 1e9 + 7; int n; long long a[MAX_N][MAX_N]; int mex(int i, i...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> const int mod = 1000000007; int f[33][2][2][2], g[33][2][2][2]; int calc(int x, int y, int k) { for (int i = 0; i <= 31; i++) for (int sx = 0; sx < 2; sx++) for (int sy = 0; sy < 2; sy++) for (int sk = 0; sk < 2; sk++) { f[i][sx][sy][sk] = g[i][sx][sy][sk] = 0; ...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; inline int read() { int k = 0; char ch = getchar(); while (ch < '0' || ch > '9') ch = getchar(); while (ch <= '9' && ch >= '0') { k = k * 10 + ch - 48; ch = getchar(); } return k; } const int p = 1e9 + 7; inline int Jia(int x) { return x >= p ? x - p : x...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const int md = 1e9 + 7; long long f[40][2][2][2], sum[40][2][2][2]; int q, k, d[3][40], tmp[40]; void split(int x, int m) { for (int i = 1; i <= 31; i++) tmp[i] = (x >> (i - 1)) & 1; for (int i = 1; i <= 31; i++) d[m][i] = tmp[32 - i]; } long long work(int x, int y) { ...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; long long int cnt[33][3][3][3], dp[33][3][3][3]; pair<long long int, long long int> solve(long long int pos, long long int fx, long long int fy, long long int fk, long long int x, long long in...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; template <class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; } template <class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } mt19937 rng(chrono::steady_clock::now().time_since_epoch().cou...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> template <int MOD> struct Integral { int v_ = 0; template <typename T> Integral(T v) : v_(norm(v)) { static_assert(std::is_integral<T>::value, "input should be an integral."); } Integral() = default; ~Integral() = default; template <typename T> T norm(T v) const { if (v ...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> inline int in() { int k = 0; char ch = getchar(); bool p = 1; while (ch < '-') ch = getchar(); if (ch == '-') ch = getchar(), p = 0; while (ch > '-') k = k * 10 + ch - '0', ch = getchar(); return p ? k : -k; } const int N = 55, YL = 1e9 + 7; inline int MO(const int &x) { return x ...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; int q, f[50][2][2][2], g[50][2][2][2], a[50], b[50], c[50], al, bl, cl, ans; void upd(int &x, int y) { x = (x + y) % 1000000007; } int solve(int x, int y, int k) { memset(f, 0, sizeof(f)); memset(g, 0, sizeof(g)); al = bl = cl = 0; while (x) { a[++al] = x % 2; ...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const long long MODD = 1e9 + 7; int q; long long a, b, u, v, k; long long calc(long long u, long long v, long long k, long long o = 0) { if (u > v) swap(u, v); if (u < 1 || k <= 0) return 0; long long p = 1, res = 0; while (p * 2LL <= v) p *= 2LL; long long tmp = ...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; int c[31 + 1][2][2][2], s[31 + 1][2][2][2], T[2][2][2]; void Initialise() { T[0][0][0] = 0; T[0][0][1] = 1; T[0][1][0] = 0; T[0][1][1] = 0; T[1][0][0] = 1; T[1][0][1] = 1; T[1][1][0] = 0; T[1][1][1] = 1; } int Query(int n, int m, int k) { if (n < 0 || m < ...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; inline long long sum(long long x, long long y, long long off, long long k) { long long lo = off + 1; long long hi = min(k, off + x); if (hi < lo) return 0; long long ret = (lo * (hi - lo + 1) + (hi - lo) * (hi - lo + 1) / 2) % mod; (...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; long long p[32]; long long work(long long x, long long y, long long k, long long lazy) { if (x <= 0 || y <= 0) return 0; if (k <= 0) return 0; if (x > y) swap(x, y); int t = 0; while (p[t] <= y) t++; long long ans; if (y == p[t - 1]...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Arrays; import java.io.IOException; import java.io.UncheckedIOException; import java.io.Closeable; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.InputStream; /**...
JAVA
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int maxn = 33; void add(long long &a, long long b) { (a += b) %= mod; if (a < 0) a += mod; } int q; int A[maxn], acnt; int B[maxn], bcnt; int C[maxn], ccnt; bool vis[maxn][2][2][2]; struct node { long long cnt, sum; void clear() { cnt ...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const long long int mod = 1000000007; long long int k; inline long long int sum(long long int l, long long int r) { if (l > r) return 0; else return (l + r) * (r - l + 1) / 2 % mod; } long long int solve(long long int x, long long int y, long long int h) { if ...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; public class Div2_415E { public static void main(String[] args) throws IOException { BufferedR...
JAVA
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; struct par { long long cuantos, suma; } D[35][5][5][5], m; long long mr, mc, k; long long R[35], C[35], A[35]; bool Y[35][5][5][5]; long long P[35], modd = 1000000007; par dp(long long idx, bool yr, bool yc, bool ya) { if (Y[idx][yr][yc][ya]) return D[idx][yr][yc][ya]; ...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const int B = 27397, MOD = 1e9 + 7; const int B1 = 33941, MOD1 = 1e9 + 9; int q, r, s, k; int memo_cnt[32][2][2][2], memo_sum[32][2][2][2]; inline int add(int a, int b) { a += b; while (a < 0) a += MOD; return a % MOD; } inline int mul(const int &a, const int &b) { re...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const long long UNDEF = -1; const long long INF = 1e18; template <typename T> inline bool chkmax(T& aa, T bb) { return aa < bb ? aa = bb, true : false; } template <typename T> inline bool chkmin(T& aa, T bb) { return aa > bb ? aa = bb, true : false; } static char stdinB...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; long long la, ra, lb, rb, K; pair<long long, long long> dp[35][2][2][2]; pair<long long, long long> calc(int p, int f1, int f2, int pre, long long lim1, long long lim2) { if (p == -1) return pair<long long, lo...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const int M = 1e9 + 7; int q, dp[31][8], sum[30][8], k; void add(int &a, int b) { a += b; if (a >= M) a -= M; } void sub(int &a, int b) { a -= b; if (a < 0) a += M; } int find(int x, int y) { if (x < 0 || y < 0) return 0; int ret = 0; memset(dp, 0, sizeof dp);...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; long long ct = 0; long long l(long long x) { long long ans = 0, p = 1; while (2 * p <= x) { ans++; p *= 2; } return ans; } long long sm(long long p) { return ((p * (p + 1)) / 2) % 1000000007; } long long comp_less(long long x, long long y, long long k) { i...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; const int MOD = 1e9 + 7; ll binpow(ll a, ll p, int mod = MOD) { ll res = 1; while (p) { if (p & 1) { (res *= a) %= mod; } p >>= 1; (a *= a) %= mod; } return res; } ll gcd(ll a, ll b) { return b == 0...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const int P = 1e9 + 7; long long sum[35][2][2][2], cnt[35][2][2][2]; inline long long Calc(int _x, int _y, int _K) { if (_x == -1 || _y == -1) return 0; int x[35] = {0}, y[35] = {0}, K[35] = {0}, _p = 0; _p = -1; while (_x) x[++_p] = _x & 1, _x >>= 1; _p = -1; w...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int mxn = 10005; int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } ...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; inline long long add(long long x, long long y) { return x + y >= ((long long)1e9 + 7) ? x + y - ((long long)1e9 + 7) : x + y; } inline long long mns(long long x, long long y) { return x - y < 0 ? x - y + ((long long)1e9 + 7) : x - y; } struct data { long long sum, cnt...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; constexpr int64_t MOD = (int64_t)1e9 + 7LL; struct quad { int64_t x1, y1; int64_t x2, y2; bool contains(const quad& other) { return (x1 <= other.x1 && other.x2 <= x2) || (y1 <= other.y1 && other.y2 <= y2); } bool intersects(const quad& other) { ...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int UP(int x) { int l = 0, r = 32; int ans = 0; while (l <= r) { int mid = (l + r) >> 1; if (!(x >> mid)) { ans = mid; r = mid - 1; } else l = mid + 1; } return ans; } int qury(int x, int y, int k, int va) { ...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; long long k; int numx[35], numy[35], numk[35]; long long sum[35][2][2][2], num[35][2][2][2]; long long ask(long long x, long long y) { long long ans = 0; long long z = k; if (x < 0 || y < 0) return 0; memset(sum, 0, sizeof(sum)); memset(num, 0, sizeof(num)); for...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; /** * @author Don Li */ public class FindACar2 { int N = 31; int MOD = (int) 1e9 + 7; void solve() { int q = in.nextInt(); w...
JAVA
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; inline long long read() { long long x = 0, f = 1; char c = getchar(); while (!isdigit(c)) { if (c == '-') f = -1; c = getchar(); } while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); } return x * f; } long long T; long long ...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const long long maxn = 1e6 + 5; const long long mod = 1e9 + 7; const long long base = 3e18; pair<long long, long long> dp[33][2][2][2]; long long a[33]; long long b[33]; long long c[33]; pair<long long, long long> f(long long nw, long long x, long long y, ...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; long long sol(long long x, long long y, long long off, long long k) { if (x > y) swap(x, y); long long mod = 1000000007; long long res = 0; if (x == 0 && y == 0) { if (off <= k) return off; else return 0; } if (x < 0 || k < 0) return 0; if ...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; long long solve(long long u, long long v, long long k, long long o = 0) { if (u > v) swap(u, v); if (u < 1 || k < 1) return 0; long long p = 1, res = 0; while (p * 2 <= v) p *= 2; long long tmp = min(p, k); if (u <= p) { res = ((tmp * (tmp + 1) / 2 % 1000000...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; long long calc1(long long x, long long y, long long k) { if (k < 1 || y == 0 || x == 0) return 0; if (x > y) swap(x, y); int u = 63 - __builtin_clzll(y), v = 63 - __builtin_clzll(x); long long c = (1LL << u), d = (1LL << v); if (c > d) { if (k <= c) return k *...
CPP
809_C. Find a car
After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help. Form...
2
9
#include <bits/stdc++.h> using namespace std; const int Imx = 2147483647; const int mod = 1000000007; const long long Lbg = 2e18; inline long long getnum() { register long long r = 0; register bool ng = 0; register char c; c = getchar(); while (c != '-' && (c < '0' || c > '9')) c = getchar(); if (c == '-') ...
CPP