buggy_code stringlengths 11 625k | fixed_code stringlengths 17 625k | bug_type stringlengths 2 4.45k | language int64 0 8 | token_count int64 5 200k |
|---|---|---|---|---|
n,m,q=map(int,input().split(" "))
arr=[list(map(int, input().split(" "))) for i in range(q)]
ans=0
for i1 in range(1,m+1):
for i2 in range(i1,m+1):
for i3 in range(i2, m+1):
for i4 in range(i3, m+1):
for i5 in range(i4, m+1):
for i6 in range(i5, m+1):
for i7 in range(i6, m+1):
for i8 in rang... | n,m,q=map(int,input().split(" "))
arr=[list(map(int, input().split(" "))) for i in range(q)]
ans=0
for i1 in range(1,m+1):
for i2 in range(i1,m+1):
for i3 in range(i2, m+1):
for i4 in range(i3, m+1):
for i5 in range(i4, m+1):
for i6 in range(i5, m+1):
for i7 in range(i6, m+1):
for i8 in rang... | [["+", 8, 196, 0, 1, 0, 662, 12, 634, 0, 612], ["+", 8, 196, 0, 1, 0, 662, 12, 634, 0, 21]] | 5 | 238 |
from itertools import combinations_with_replacement
def main():
n_ints, max_int, n_queries = map(int, input().split())
queries = [list(map(int, input().split())) for _ in range(n_queries)]
possible_sequences = combinations_with_replacement(range(1, max_int+1), n_ints)
max_score = 0
for sequence... | from itertools import combinations_with_replacement
def main():
n_ints, max_int, n_queries = map(int, input().split())
queries = [list(map(int, input().split())) for _ in range(n_queries)]
possible_sequences = combinations_with_replacement(range(1, max_int+1), n_ints)
max_score = 0
for sequence... | [["-", 15, 666, 0, 657, 31, 206, 206, 657, 31, 22], ["+", 15, 666, 0, 657, 31, 206, 206, 657, 31, 22], ["-", 15, 666, 0, 657, 12, 206, 206, 657, 31, 22], ["+", 15, 666, 0, 657, 12, 206, 206, 657, 31, 22]] | 5 | 140 |
N, M ,Q = map(int, input().aplist())
lists = [list(map(int, input().split())) for i in range(Q)]
ans = 0
def calc_score(A):
score = 0
for a, b, c, d in lists:
if A[b -1] - A[a - 1] == c:
score += d
return score
def dfs(A):
global ans
if len(A) == N:
score = calc_score(A... | N, M, Q = map(int, input().split())
lists = [list(map(int, input().split())) for i in range(Q)]
ans = 0
def calc_score(A):
score = 0
for a, b, c, d in lists:
if A[b - 1] - A[a - 1] == c:
score += d
return score
def dfs(A):
global ans
if len(A) == N:
score = calc_score(A)
... | [["-", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22]] | 5 | 154 |
n, m, q = [int(e) for e in input().split()]
import itertools as it
abcd=list()
for i in range(q):
abcd.append([int(e) for e in input().split()])
all = it.combinations(range(1,m+1),n)
count=list()
num=0
for i in all:
for j in abcd:
if i[j[1]-1]-i[j[0]-1] == j[2]:
num += j[3]
else:... | n, m, q = [int(e) for e in input().split()]
import itertools as it
abcd=list()
for i in range(q):
abcd.append([int(e) for e in input().split()])
all = it.combinations_with_replacement(range(1,m+1),n)
count=list()
num=0
for i in all:
for j in abcd:
if i[j[1]-1]-i[j[0]-1] == j[2]:
num += j... | [["-", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22]] | 5 | 146 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, k, n) for (ll i = k; i < (n); i++)
ll N, M, Q;
vector<ll> a, b, c, d;
ll score(const vector<ll> &A) {
ll res = 0;
rep1(i, Q) {
i... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, k, n) for (ll i = k; i < (n); i++)
ll N, M, Q;
vector<ll> a, b, c, d;
ll score(const vector<ll> &A) {
ll res = 0;
rep1(i, Q) {
i... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18]] | 1 | 321 |
N,M,Q=map(int,input().split())
a=[0]*Q
b=[0]*Q
c=[0]*Q
d=[0]*Q
for i in range(Q):
a[i],b[i],c[i],d[i]=map(int,input().split())
a[i]-=1
b[i]-=1 #Aのa[i],b[i]番目を指定したいから-1する。
def score(A):
一つ一つの点数=0
for ai,bi,ci,di in zip(a,b,c,d):
if A[bi]-A[ai]==ci:
一つ一つの点数+=di
return 一つ一つ... | N,M,Q=map(int,input().split())
a=[0]*Q
b=[0]*Q
c=[0]*Q
d=[0]*Q
for i in range(Q):
a[i],b[i],c[i],d[i]=map(int,input().split())
a[i]-=1
b[i]-=1 #Aのa[i],b[i]番目を指定したいから-1する。
def score(A):
一つ一つの点数=0
for ai,bi,ci,di in zip(a,b,c,d):
if A[bi]-A[ai]==ci:
一つ一つの点数+=di
return 一つ一つ... | [["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]] | 5 | 229 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
int n, m, q;
vector<int> a, b, c, d;
int ans = 0;
void dfs(vector<int> A) {
if (A.size() == m + 1) {
int cnt = 0;
rep(i, q) {
if (A[b[i]] - A[a[i]] == c[i])... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
int n, m, q;
vector<int> a, b, c, d;
int ans = 0;
void dfs(vector<int> A) {
if (A.size() == n + 1) {
int cnt = 0;
rep(i, q) {
if (A[b[i]] - A[a[i]] == c[i])... | [["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22]] | 1 | 265 |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 100;
int a[N], b[N], c[N], d[N];
int A[N], n, m, q, ans = 0;
void dfs(int id, int num) {
if (id == n + 1) {
int sum = 0;
for (int i = 1; i <= q; i++) {
if (A[b[i]] - A[a[i]] == c[i])
sum += d[i];
ans = max(ans... | #include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 100;
int a[N], b[N], c[N], d[N];
int A[N], n, m, q, ans = 0;
void dfs(int id, int num) {
if (id == n + 1) {
int sum = 0;
for (int i = 1; i <= q; i++) {
if (A[b[i]] - A[a[i]] == c[i])
sum += d[i];
}
ans = max... | [["+", 0, 57, 64, 9, 0, 7, 8, 9, 0, 46], ["-", 0, 57, 64, 9, 0, 7, 8, 9, 0, 46]] | 1 | 237 |
#include <iostream>
#include <vector>
using namespace std;
int m, n, q;
vector<int> a, b, c, d;
int ans = 0;
void dfs(vector<int> v) {
if (v.size() == n) {
int tmp = 0;
for (int i = 0; i < q; i++) {
if (v[b[i]] - v[a[i]] == c[i])
tmp += d[i];
}
ans = max(ans, tmp);
return;
}
v.... | #include <iostream>
#include <vector>
using namespace std;
int m, n, q;
vector<int> a, b, c, d;
int ans = 0;
void dfs(vector<int> v) {
if (v.size() == n) {
int tmp = 0;
for (int i = 0; i < q; i++) {
if (v[b[i]] - v[a[i]] == c[i])
tmp += d[i];
}
ans = max(ans, tmp);
return;
}
v.... | [["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 38], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 35], ["-", 0, 1, 0, 16, 31, 16, 31, 16, 17, 152], ["-", 0, 1, 0, 16, 31, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 17, 152], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22]] | 1 | 254 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define r(i, j) for (int i = 1; i <= j; i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;
int main() {
int N, M, Q;
cin >> N >> M >> Q;
vec<int> A(Q), B(Q... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define r(i, j) for (int i = 1; i <= j; i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;
int main() {
int N, M, Q;
cin >> N >> M >> Q;
vec<int> A(Q), B(Q... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]] | 1 | 300 |
n, m, q = list(map(int, input().split(" ")))
Q = [list(map(int, input().split(" "))) for i in range(q)]
Q = [[i[0] - 1, i[1] - 1, i[2], i[3]] for i in Q]
def calc(arr: list):
return sum([i[3] for i in Q if arr[i[1]] - arr[i[0]] == i[2]])
def get_array(arr: list, num):
if len(arr) == n:
return calc(arr... | n, m, q = list(map(int, input().split(" ")))
Q = [list(map(int, input().split(" "))) for i in range(q)]
Q = [[i[0] - 1, i[1] - 1, i[2], i[3]] for i in Q]
def calc(arr: list):
return sum([i[3] for i in Q if arr[i[1]] - arr[i[0]] == i[2]])
def get_array(arr: list, num):
if len(arr) == n:
return calc(arr... | [["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 612]] | 5 | 189 |
// https://atcoder.jp/contests/abc165/tasks/abc165_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
... | // https://atcoder.jp/contests/abc165/tasks/abc165_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
... | [["-", 3, 4, 0, 23, 0, 41, 64, 16, 17, 72], ["-", 3, 4, 0, 23, 0, 41, 64, 16, 12, 13]] | 1 | 286 |
#include <bits/stdc++.h>
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define reset(x, y) memset(x, y, sizeof(x))
#define BUG(x) cerr << #x << " = " << (x) << endl
#defin... | #include <bits/stdc++.h>
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define reset(x, y) memset(x, y, sizeof(x))
#define BUG(x) cerr << #x << " = " << (x) << endl
#defin... | [["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]] | 1 | 382 |
#include <bits/stdc++.h>
#define prArr(Arr, n) \
for (int _ = 0; _ < n; _++) \
cout << (Arr)[_] << " ";
using namespace std;
const int INF = (int)0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
int n, m, q, ans;
vo... | #include <bits/stdc++.h>
#define prArr(Arr, n) \
for (int _ = 0; _ < n; _++) \
cout << (Arr)[_] << " ";
using namespace std;
const int INF = (int)0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
int n, m, q, ans;
vo... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]] | 1 | 331 |
// Author : Hardik Upadhyay
// college: SVNIT
// slogan : Ab to phod dunga
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#... | // Author : Hardik Upadhyay
// college: SVNIT
// slogan : Ab to phod dunga
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#... | [["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 39, 78], ["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 96], ["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 87], ["-", 8, 9, 0, 57, 64, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 57, 64, 9, 0, 43, 39, 78], ["-", 75, 76, 0, 9, 0, 43, 49, 50, 51, 13], ["+", 75, 76,... | 1 | 397 |
n,m,q = [int(i) for i in input().split()]
p = []
for i in range(q):
p.append([int(i) for i in input().split()])
dmax = 0
a = [1 for i in range(n)]
while True:
d = 0
for i in range(q):
if a[p[i][1]-1]-a[p[i][0]-1] == p[i][2]:
d += p[i][3]
if d > dmax:
dmax = d
if a[0] == 10:
break
c = 1
l... | n,m,q = [int(i) for i in input().split()]
p = []
for i in range(q):
p.append([int(i) for i in input().split()])
dmax = 0
a = [1 for i in range(n)]
while True:
d = 0
for i in range(q):
if a[p[i][1]-1]-a[p[i][0]-1] == p[i][2]:
d += p[i][3]
if d > dmax:
dmax = d
if a[0] == m:
break
c = 1
l ... | [["-", 0, 52, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 0, 22], ["-", 0, 52, 8, 196, 0, 52, 15, 666, 0, 612], ["+", 0, 52, 8, 196, 0, 52, 15, 666, 0, 22]] | 5 | 190 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll = long long;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define MOD 1000000007
c... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll = long long;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define MOD 1000000007
c... | [["-", 12, 11, 12, 11, 12, 2, 3, 4, 0, 22], ["+", 12, 11, 12, 11, 12, 2, 3, 4, 0, 22]] | 1 | 418 |
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
int N, M, Q;
// 先にアクセスできるようにする Aは数列用
vector<int> A(11), a(50), b(50), c(50), d(50);
int ans = 0;
void dfs(... | #include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
int N, M, Q;
// 先にアクセスできるようにする Aは数列用
vector<int> A(11, 0), a(50), b(50), c(50), d(50);
int ans = 0;
void d... | [["+", 0, 30, 0, 43, 49, 50, 51, 4, 0, 21], ["+", 0, 30, 0, 43, 49, 50, 51, 4, 0, 13], ["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["-", 0, 14, 8, 9, 0, 57, 75, 76, 0, 95], ["-", 8, 9, 0, 57, 75, 76, 0, 9, 0, 45], ["-", 75, 76, 0, 9, 0, 7, 8, 9, 0, 46]] | 1 | 247 |
N, M, Q = map(int, input().split())
A = []
B = []
C = []
D = []
for i in range(Q):
a, b, c, d = map(int, input().split())
A.append(a)
B.append(b)
C.append(c)
D.append(d)
def dfs(nums):
if len(nums) == N + 1:
score = 0
for j in range(Q):
if nums[B[j]] - nums[A[j]]... | N, M, Q = map(int, input().split())
A = []
B = []
C = []
D = []
for i in range(Q):
a, b, c, d = map(int, input().split())
A.append(a)
B.append(b)
C.append(c)
D.append(d)
def dfs(nums):
if len(nums) == N + 1:
score = 0
for j in range(Q):
if nums[B[j]] - nums[... | [["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32]] | 5 | 196 |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n, m, q, a, b, c, d;
vector<int> V;
int sol = 0;
int arrA[55];
int arrB[55];
int arrC[55];
int arrD[55];
void check() {
int cnt = 0;
for (int i = 0; i < q; i++) {
if (V[arrB[i] - 1] - V[arrA[i] - 1] == arrC[i])
cnt += arrD[i];
}
... | #include <bits/stdc++.h>
#define ll long long
using namespace std;
int n, m, q, a, b, c, d;
vector<int> V;
int sol = 0;
int arrA[55];
int arrB[55];
int arrC[55];
int arrD[55];
void check() {
int cnt = 0;
for (int i = 0; i < q; i++) {
if (V[arrB[i] - 1] - V[arrA[i] - 1] == arrC[i])
cnt += arrD[i];
}
... | [["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]] | 1 | 255 |
#include <bits/stdc++.h>
using namespace std;
#define int long long
void b(vector<vector<int>> A, vector<int> B, int &l) {
int j = 0;
for (vector<int> i : A) {
if (B[i[1]] - B[i[0]] == i[2])
j += i[3];
}
l = max(j, l);
}
void a(vector<vector<int>> A, vector<int> B, int N, int j, int M, int i,
... | #include <bits/stdc++.h>
using namespace std;
#define int long long
void b(vector<vector<int>> A, vector<int> B, int &l) {
int j = 0;
for (vector<int> i : A) {
if (B[i[1]] - B[i[0]] == i[2])
j += i[3];
}
l = max(j, l);
}
void a(vector<vector<int>> A, vector<int> B, int N, int j, int M, int i,
... | [["-", 0, 7, 15, 16, 12, 16, 31, 16, 17, 33], ["-", 0, 7, 15, 16, 12, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]] | 1 | 318 |
#include <bits/stdc++.h>
using namespace std;
// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
// REPEAT
// ------------... | #include <bits/stdc++.h>
using namespace std;
// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
// REPEAT
// ------------... | [["-", 0, 9, 0, 43, 49, 50, 51, 41, 64, 13], ["+", 0, 9, 0, 43, 49, 50, 51, 41, 64, 13]] | 1 | 742 |
#include <bits/stdc++.h>
#define ll long long
const int N = 100005;
using namespace std;
int A[15], n, m, q, a[55], b[55], c[55], d[55], ans;
void dfs(int dep, int pre) {
if (dep == n) {
int sum = 0;
for (int i = 0; i < q; i++)
if (A[b[i]] - A[a[i]] == c[i])
sum += d[i];
ans = max(ans, sum);... | #include <bits/stdc++.h>
#define ll long long
const int N = 100005;
using namespace std;
int A[15], n, m, q, a[55], b[55], c[55], d[55], ans;
void dfs(int dep, int pre) {
if (dep == n) {
int sum = 0;
for (int i = 0; i < q; i++)
if (A[b[i]] - A[a[i]] == c[i])
sum += d[i];
ans = max(ans, sum);... | [["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]] | 1 | 236 |
#include <bits/stdc++.h>
#define ll long long
const int N = 100005;
using namespace std;
int A[15], n, m, q, a[55], b[55], c[55], d[55], ans;
int main() {
cin >> n >> m >> q;
for (int i = 1; i <= q; i++)
cin >> a[i] >> b[i] >> c[i] >> d[i];
for (int i = 1; i <= n; i++)
A[i] = 1;
while (!a[1]) {
int ... | #include <bits/stdc++.h>
#define ll long long
const int N = 100005;
using namespace std;
int A[15], n, m, q, a[55], b[55], c[55], d[55], ans;
int main() {
cin >> n >> m >> q;
for (int i = 1; i <= q; i++)
cin >> a[i] >> b[i] >> c[i] >> d[i];
for (int i = 1; i <= n; i++)
A[i] = 1;
while (!A[0]) {
int ... | [["-", 0, 52, 15, 339, 51, 91, 28, 69, 28, 22], ["+", 0, 52, 15, 339, 51, 91, 28, 69, 28, 22], ["-", 15, 339, 51, 91, 28, 69, 341, 342, 0, 13], ["+", 15, 339, 51, 91, 28, 69, 341, 342, 0, 13]] | 1 | 256 |
#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")
#pragma GCC optimize("fast-math")
typedef long long ll;
typedef long double ld;
#define all... | #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")
#pragma GCC optimize("fast-math")
typedef long long ll;
typedef long double ld;
#define all... | [["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 21], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 13]] | 1 | 290 |
#include <algorithm>
#include <bitset>
#include <cmath>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#pragma GCC optim... | #include <algorithm>
#include <bitset>
#include <cmath>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#pragma GCC optim... | [["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]] | 1 | 676 |
//#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
... | //#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]] | 1 | 464 |
N,M,Q = (int(x) for x in input().split())
ABCD = [0]*Q
for T in range(0,Q):
ABCD[T] = [int(x) for x in input().split()]
MaxP = 0
for A1 in range(0,M+1):
for A2 in range(A1,M+1):
if N<=2:
Point = 0
A = [A1,A2]
for TT in range(0,Q):
if A[ABCD[TT][... | N,M,Q = (int(x) for x in input().split())
ABCD = [0]*Q
for T in range(0,Q):
ABCD[T] = [int(x) for x in input().split()]
MaxP = 0
for A1 in range(1,M+1):
for A2 in range(A1,M+1):
if N<=2:
Point = 0
A = [A1,A2]
for TT in range(0,Q):
if A[ABCD[TT][... | [["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612]] | 5 | 981 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int, int>;
/* ちゃんと考えてわかって実装 */
int n, m, q;
vector<int> a, b, c, d;
ll calc_score(const vector<int> &x) {
ll res = 0;
for (int i = 0; i < q; i++) {
if (x[b[i]] - x[a[i]] == c[i])
res += d[i];
}
return res;
}
ll dfs(v... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int, int>;
/* ちゃんと考えてわかって実装 */
int n, m, q;
vector<int> a, b, c, d;
ll calc_score(vector<int> &x) {
ll res = 0;
for (int i = 0; i < q; i++) {
if (x[b[i]] - x[a[i]] == c[i])
res += d[i];
}
return res;
}
ll dfs(vector<... | [["-", 49, 53, 54, 55, 0, 56, 0, 153, 0, 154], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18]] | 1 | 318 |
import itertools
n, m, q = list(map(int,input().split()))
sets = [list(map(int,input().split())) for i in range(q)]
mx = 0
nums = list(range(1,m+1))
for h in itertools.combinations_with_replacement(nums,n):
mxtemp = 0
for j in range(q):
a = sets[q][0]
b = sets[q][1]
if list(h)[b-1] - lis... | import itertools
n, m, q = list(map(int,input().split()))
sets = [list(map(int,input().split())) for i in range(q)]
#print(sets)
mx = 0
nums = list(range(1,m+1))
for h in itertools.combinations_with_replacement(nums,n):
mxtemp = 0
for j in range(q):
a = sets[j][0]
b = sets[j][1]
if list(... | [["-", 0, 1, 0, 662, 12, 206, 51, 206, 206, 22], ["+", 0, 1, 0, 662, 12, 206, 51, 206, 206, 22], ["-", 0, 57, 15, 666, 0, 206, 51, 206, 206, 22], ["+", 0, 57, 15, 666, 0, 206, 51, 206, 206, 22], ["-", 0, 1, 0, 677, 12, 206, 51, 206, 206, 22], ["+", 0, 1, 0, 677, 12, 206, 51, 206, 206, 22]] | 5 | 156 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int n, m, q;
vector<int> a, b, c, d;
int ans;
void dfs(vector<int> A) {
if (A.size() == n + 1) {
int now = 0;
rep(i, q) {
if (A.at(b.at(i)) - A.at(a.at(i)) == c.at(i))
now +=... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int n, m, q;
vector<int> a, b, c, d;
int ans;
void dfs(vector<int> A) {
if (A.size() == n + 1) {
int now = 0;
rep(i, q) {
if (A.at(b.at(i)) - A.at(a.at(i)) == c.at(i))
now +=... | [["-", 64, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 64, 9, 0, 1, 0, 11, 12, 2, 63, 22]] | 1 | 254 |
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
void Main() {
// input
int N, M, Q;
cin >> N >> M >> Q;
int a[Q + 1], b[Q + 1], c[Q + 1], d[Q + 1];
for (int i = 1; i <= Q; i++) {
cin >> a[i] >> b[i] >> c[i] >> d[i];
}
// translate
// 数列 A_1, …, A... |
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
void Main() {
// input
int N, M, Q;
cin >> N >> M >> Q;
int a[Q + 1], b[Q + 1], c[Q + 1], d[Q + 1];
for (int i = 1; i <= Q; i++) {
cin >> a[i] >> b[i] >> c[i] >> d[i];
}
// translate
// 数列 A_1, …, A... | [["+", 0, 43, 49, 50, 51, 4, 0, 16, 17, 33], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]] | 1 | 324 |
#https://atcoder.jp/contests/abc165/submissions/12672182
#写経
import itertools
import numpy as np
def resolve():
N,M,Q = map(int,input().split())
A = np.array(list(itertools.combinations_with_replacement(range(1,M+1),N)))
s = np.zeros(len(A), np.int32)
for i in range(Q):
a,b,c,d = map(int,input... | #https://atcoder.jp/contests/abc165/submissions/12672182
#写経
import itertools
import numpy as np
def resolve():
N,M,Q = map(int,input().split())
A = np.array(list(itertools.combinations_with_replacement(range(1,M+1),N)))
s = np.zeros(len(A), np.int32)
for i in range(Q):
a,b,c,d = map(int,input(... | [["+", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 132 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, n) for (int i = 1; i <= (int)n; i++)
#define rep2(i, j, n) for (int j = i; j < n; j++)
#define rep3(i, j, n) for (int j = i; j <= n; j++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define sp(n) cout << fixed << setprec... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, n) for (int i = 1; i <= (int)n; i++)
#define rep2(i, j, n) for (int j = i; j < n; j++)
#define rep3(i, j, n) for (int j = i; j <= n; j++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define sp(n) cout << fixed << setprec... | [["-", 75, 76, 0, 9, 0, 7, 15, 16, 17, 19], ["+", 75, 76, 0, 9, 0, 7, 15, 16, 17, 18]] | 1 | 377 |
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln = '\n';
constexpr long long MOD = 998244353;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(), (x).end()
#define rep(i... | #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln = '\n';
constexpr long long MOD = 998244353;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(), (x).end()
#define rep(i... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 413 |
n,m,q=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
for i in range(q):
A,B,C,D=map(int,input().split())
a.append(A)
b.append(B)
c.append(C)
d.append(D)
ans=0
M=[0,0,0,0,0,0,0,0,0,0,0]
for i in range(n):
M[i]=1
cursor=n
breakflag=0
while True:
ev=0
for i in range(q):
if M[b[i]-1]-M[a[i]-1]==c[i]:
... | n,m,q=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
for i in range(q):
A,B,C,D=map(int,input().split())
a.append(A)
b.append(B)
c.append(C)
d.append(D)
ans=0
M=[0,0,0,0,0,0,0,0,0,0,0]
for i in range(n):
M[i]=1
cursor=n
breakflag=0
while True:
ev=0
for i in range(q):
if M[b[i]-1]-M[a[i]-1]==c[i]:
... | [["+", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 12, 22]] | 5 | 253 |
N, M, Q = map(int, input().split())
lst = []
for i in range(Q):
lst.append(list(map(int, input().split())))
import itertools
## product 順番あり 重複あり(全て)
## premutations 順番あり 重複なし
## combinations 順番なし 重複なし
## combinations_with_replacement 順番なし 重複あり
A_pattern = itertools.combinations_with_replacement(range(0, M+1... | N, M, Q = map(int, input().split())
lst = []
for i in range(Q):
lst.append(list(map(int, input().split())))
import itertools
## product 順番あり 重複あり(全て)
## premutations 順番あり 重複なし
## combinations 順番なし 重複なし
## combinations_with_replacement 順番なし 重複あり
A_pattern = itertools.combinations_with_replacement(range(1, M+1... | [["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 612]] | 5 | 133 |
import intertools
N, M, Q = map(int, input().split())
abcd = []
ans = 0
for i in range(Q):
abcd.append(input())
for X in intertools.conbinations_with_replacemant(range(1, M + 1), N):
tmp = 0
for z in abcd:
a, b, c, d = map(int, z.split())
if X[b - 1] - X[a - 1] == c:
tmp += d
ans = max(ans, tmp)
p... | import itertools
N, M, Q = map(int, input().split())
abcd = []
ans = 0
for i in range(Q):
abcd.append(input())
for X in itertools.combinations_with_replacement(range(1, M + 1), N):
tmp = 0
for z in abcd:
a, b, c, d = map(int, z.split())
if X[b - 1] - X[a - 1] == c:
tmp += d
ans = max(ans, tmp)
pri... | [["-", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22], ["-", 0, 656, 0, 7, 12, 652, 63, 319, 500, 22], ["+", 0, 656, 0, 7, 12, 652, 63, 319, 500, 22], ["-", 0, 656, 0, 7, 12, 652, 63, 319, 319, 22], ["+", 0, 656, 0, 7, 12, 652, 63, 319, 319, 22]] | 5 | 120 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < ((ll)(n)); i++)
#define reg(i, a, b) for (ll i = ((ll)(a)); i <= ((ll)(b)); i++)
#define irep(i, n) for (ll i = ((ll)(n)-1); i >= 0; i--)
#define ireg(i, a, b) for (ll i = ((ll)(b)); i >= ((ll)(a)); i--)
template <c... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < ((ll)(n)); i++)
#define reg(i, a, b) for (ll i = ((ll)(a)); i <= ((ll)(b)); i++)
#define irep(i, n) for (ll i = ((ll)(n)-1); i >= 0; i--)
#define ireg(i, a, b) for (ll i = ((ll)(b)); i >= ((ll)(a)); i--)
template <c... | [["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 16, 31, 16, 12, 2, 3, 4, 0, 13], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 13]] | 1 | 334 |
N,M,Q = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(Q)]
def dfs(s):
if len(s) == N:
return[s]
result = []
if s == '':
num = 0
else:
num = int(s[-1])
for i in range(num,M+1):
result.extend(dfs(s+str(i)))
return result
ans = 0
S = dfs... | N,M,Q = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(Q)]
def dfs(s):
if len(s) == N:
return[s]
result = []
if s == '':
num = 0
else:
num = int(s[-1])
for i in range(num,M):
result.extend(dfs(s+str(i)))
return result
ans = 0
S = dfs('... | [["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]] | 5 | 190 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, m, n) for (ll i = m; i < (ll)(n); i++)
#define rrep(i, n, m) for (ll i = n; i >= (ll)(m); i--)
const int dx[4] = {1, 0, -1, 0... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, m, n) for (ll i = m; i < (ll)(n); i++)
#define rrep(i, n, m) for (ll i = n; i >= (ll)(m); i--)
const int dx[4] = {1, 0, -1, 0... | [["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22]] | 1 | 482 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll
const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll
const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0... | [["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]] | 1 | 584 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
int n, m, q;
int ans;
vector<int> a, b, c, d;
void dfs(vector<int> A) {
if (A.size() == n + 1) {
int now = 0;
rep(i, q) {
if (A[b[i]] - A[a[i]] == c[i])
now += d[i];
}
an... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
int n, m, q;
int ans;
vector<int> a, b, c, d;
void dfs(vector<int> A) {
if (A.size() == n + 1) {
int now = 0;
rep(i, q) {
if (A[b[i]] - A[a[i]] == c[i])
now += d[i];
}
an... | [["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 38], ["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 35]] | 1 | 232 |
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#define ll long long
#define PII pair<int, int>
#d... | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#define ll long long
#define PII pair<int, int>
#d... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]] | 1 | 536 |
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
vector<int> a, b, c, d;
ll mx = 0;
voi... | #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
vector<int> a, b, c, d;
ll mx = 0;
voi... | [["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]] | 1 | 356 |
import sys
def main():
input = sys.stdin.readline
N, M, Q = map(int, input().split())
abcd = [tuple(map(int, input().split())) for _ in range(Q)]
stk = [[]]
ans = 0
while stk:
A = stk.pop()
if len(A) < N:
t = A[-1] if len(A) > 0 else 0
for i in range(t, 10... | import sys
def main():
input = sys.stdin.readline
N, M, Q = map(int, input().split())
abcd = [tuple(map(int, input().split())) for _ in range(Q)]
stk = [[]]
ans = 0
while stk:
A = stk.pop()
if len(A) < N:
t = A[-1] if len(A) > 0 else 0
for i in range(t, M)... | [["-", 64, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 64, 196, 0, 7, 12, 652, 3, 4, 0, 22]] | 5 | 179 |
import itertools;n,m,q,*l=map(int,open(0).read().split());print(max(sum(d for a in[l[j*4:j*4+4]for j in range(q)]if i[b-1]-i[a-1]==c)for i in itertools.combinations_with_replacement(range(m),n))) | import itertools;n,m,q,*l=map(int,open(0).read().split());print(max(sum(d for a,b,c,d in[l[j*4:j*4+4]for j in range(q)]if i[b-1]-i[a-1]==c)for i in itertools.combinations_with_replacement(range(m),n))) | [["+", 8, 652, 3, 668, 0, 659, 31, 684, 0, 21], ["+", 8, 652, 3, 668, 0, 659, 31, 684, 0, 22]] | 5 | 94 |
#include <bits/stdc++.h>
using namespace std;
int n, m, q;
vector<int> a, b, c, d;
int ans;
void dfs(vector<int> A) {
if (A.size() == n + 1) {
int now = 0;
for (int i = 0; i < n; i++) {
if (A[b[i]] - A[a[i]] == c[i])
now += d[i];
}
ans = max(ans, now);
return;
}
A.push_back(A.b... | #include <bits/stdc++.h>
using namespace std;
int n, m, q;
vector<int> a, b, c, d;
int ans;
void dfs(vector<int> A) {
if (A.size() == n + 1) {
int now = 0;
for (int i = 0; i < q; i++) {
if (A[b[i]] - A[a[i]] == c[i])
now += d[i];
}
ans = max(ans, now);
return;
}
A.push_back(A.b... | [["-", 0, 57, 64, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 12, 22]] | 1 | 240 |
#include <bits/stdc++.h>
using namespace std;
int n, m, q;
vector<int> a, b, c, d;
int ans = 0;
void dfs(vector<int> A) {
if (A.size() == n + 1) {
// calc score
int sum = 0;
for (int i = 0; i < q; i++) {
if (A[b[i]] - A[a[i]] == c[i])
sum += d[i];
ans = max(ans, sum);
return;
... | #include <bits/stdc++.h>
using namespace std;
int n, m, q;
vector<int> a, b, c, d;
int ans = 0;
void dfs(vector<int> A) {
if (A.size() == n + 1) {
// calc score
int sum = 0;
for (int i = 0; i < q; i++) {
if (A[b[i]] - A[a[i]] == c[i])
sum += d[i];
}
ans = max(ans, sum);
return;... | [["+", 0, 57, 64, 9, 0, 7, 8, 9, 0, 46], ["-", 0, 57, 64, 9, 0, 7, 8, 9, 0, 46]] | 1 | 240 |
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define vi vector<int>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define x first
#define y second
#define sz(x) (x).size()
#define all(x) (x).begin(), (x).end() // Forward traversal
#define rall(x) (x).rbegin, (x).rend() ... | #include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define vi vector<int>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define x first
#define y second
#define sz(x) (x).size()
#define all(x) (x).begin(), (x).end() // Forward traversal
#define rall(x) (x).rbegin, (x).rend() ... | [["-", 64, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 64, 9, 0, 7, 10, 43, 49, 50, 51, 13]] | 1 | 1,016 |
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
int dx[4] =... | #include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
int dx[4] =... | [["+", 0, 57, 15, 339, 51, 16, 12, 74, 0, 24], ["+", 15, 339, 51, 16, 12, 74, 39, 77, 39, 40], ["+", 0, 57, 15, 339, 51, 16, 12, 74, 0, 25], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18]] | 1 | 448 |
// abc165_c.cpp
// Sun May 24 22:06:33 2020
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
using namespace std;
usi... | // abc165_c.cpp
// Sun May 24 22:06:33 2020
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
using namespace std;
usi... | [["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]] | 1 | 336 |
#include <iostream>
#include <vector>
using namespace std;
int n, m, q;
vector<int> a, b, c, d;
int ans = 0;
void dfs(vector<int> s) {
if (s.size() == n + 1) {
int now = 0;
for (int i = 0; i < q; i++)
if (s[b[i]] - s[a[i]] == c[i])
now += d[i];
ans = max(ans, now);
}
s.push_back(s.back()... | #include <iostream>
#include <vector>
using namespace std;
int n, m, q;
vector<int> a, b, c, d;
int ans = 0;
void dfs(vector<int> s) {
if (s.size() == n + 1) {
int now = 0;
for (int i = 0; i < q; i++)
if (s[b[i]] - s[a[i]] == c[i])
now += d[i];
ans = max(ans, now);
return;
}
s.push_b... | [["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 38], ["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 35]] | 1 | 238 |
import itertools
n,m,q = map(int, input().split())
candidates = [i for i in range(1,m+1)]
a = [0]*q
b = [0]*q
c = [0]*q
d = [0]*q
for i in range(q):
a[i], b[i], c[i], d[i] = map(int, input().split())
max_score = 0
for A in itertools.combinations(candidates, n):
A = list(A)
score = 0
for i in range(q):
if ... | import itertools
n,m,q = map(int, input().split())
candidates = [i for i in range(1,m+1)]
a = [0]*q
b = [0]*q
c = [0]*q
d = [0]*q
for i in range(q):
a[i], b[i], c[i], d[i] = map(int, input().split())
max_score = 0
for A in itertools.combinations_with_replacement(candidates, n):
A = list(A)
score = 0
for i in ... | [["-", 0, 656, 0, 7, 12, 652, 63, 319, 319, 22], ["+", 0, 656, 0, 7, 12, 652, 63, 319, 319, 22]] | 5 | 180 |
def dfs(n, lower):
if n == N:
return [[]]
else:
res = []
for i in range(lower, M + 1):
for p in dfs(n + 1, i):
res.append([i] + p)
return res
N, M, Q = map(int, input().split())
A, B, C, D = [], [], [], []
for _ in range(Q):
a, b, c, d = map(int,... | def dfs(n, lower):
if n == N:
return [[]]
else:
res = []
for i in range(lower, M + 1):
for p in dfs(n + 1, i):
res.append([i] + p)
return res
N, M, Q = map(int, input().split())
A, B, C, D = [], [], [], []
for _ in range(Q):
a, b, c, d = map(int,... | [["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612]] | 5 | 217 |
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int N, M, Q;
vector<int> A;
vector<int> a, b, c, d;
int ans = 0;
void dfs(int n) {
if (n == N) {
int sum = 0;
for (int i = 0; i < Q; i++) {
if (A[b[i]] - A[a[i]] == c[i])
sum += d[i];
}
ans = max(ans, sum);
r... | //#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int N, M, Q;
vector<int> A;
vector<int> a, b, c, d;
int ans = 0;
void dfs(int n) {
if (n == N) {
int sum = 0;
for (int i = 0; i < Q; i++) {
if (A[b[i]] - A[a[i]] == c[i])
sum += d[i];
}
ans = max(ans, sum);
r... | [["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13]] | 1 | 275 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
using ll = long long;
using namespace std;
using P = pair<int, int>;
ll mx = 0;
int N, M, Q;
vector<ll> a(52), b(52), c(52);
vector<ll> d(52);
void dfs(vector<int> A) {
if (A.size() == N) {
... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
using ll = long long;
using namespace std;
using P = pair<int, int>;
ll mx = 0;
int N, M, Q;
vector<ll> a(52), b(52), c(52), d(52);
void dfs(vector<int> A) {
if (A.size() == N) {
ll d_sum... | [["-", 36, 36, 36, 36, 0, 30, 0, 43, 0, 35], ["-", 36, 36, 0, 30, 0, 43, 39, 344, 141, 78], ["-", 0, 30, 0, 43, 39, 344, 3, 347, 0, 18], ["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78], ["-", 0, 30, 0, 43, 39, 344, 3, 347, 0, 47], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 0, 21], ["-", 75, 76, 0, 9, 0, 7, 15, 16, 12, 13], ["+",... | 1 | 295 |
import itertools
n, m, q = map(int, input().split())
array = []
for i in range(q):
a = list(map(int, input().split()))
array.append(a)
comb = list(itertools.combinations(range(1, m+1), n))
ans = 0
for i in comb:
score = 0
for a, b, c, d in array:
if i[b-1] - i[a-1] == c:
score += ... | import itertools
n, m, q = map(int, input().split())
array = []
for i in range(q):
a = list(map(int, input().split()))
array.append(a)
comb = list(itertools.combinations_with_replacement(range(1, m+1), n))
ans = 0
for i in comb:
score = 0
for a, b, c, d in array:
if i[b-1] - i[a-1] == c:
... | [["-", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22]] | 5 | 129 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int(1e9) + int(1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + ... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int(1e9) + int(1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + ... | [["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13]] | 1 | 564 |
# 解説を参考に作成
def solve():
N, M, Q = map(int, input().split())
abcd = [[int(i) for i in input().split()] for _ in range(Q)]
def dfs(AA=[0], now_max=0):
A = AA.copy()
if len(A) == N + 1:
new_max = 0
for a, b, c, d in abcd:
if A[b] - A[a] == c:
... | # 解説を参考に作成
def solve():
N, M, Q = map(int, input().split())
abcd = [[int(i) for i in input().split()] for _ in range(Q)]
# AAs first is minmum M.
def dfs(AA=[1], now_max=0):
A = AA.copy()
if len(A) == N + 1:
new_max = 0
for a, b, c, d in abcd:
i... | [["-", 0, 14, 54, 54, 0, 696, 51, 634, 0, 612], ["+", 0, 14, 54, 54, 0, 696, 51, 634, 0, 612]] | 5 | 173 |
n, m, q = map(int, input().split(" "))
k = []
for _ in range(q):
k.append(list(map(int, input().split(" "))))
max_score = 0
import itertools
for a in itertools.combinations_with_replacement(range(1, m+1), m):
score = 0
for i in range(q):
if a[k[i][1]-1] - a[k[i][0]-1] == k[i][2]:
score... | n, m, q = map(int, input().split(" "))
k = []
for _ in range(q):
k.append(list(map(int, input().split(" "))))
max_score = 0
import itertools
for a in itertools.combinations_with_replacement(range(1, m+1), n):
score = 0
for i in range(q):
if a[k[i][1]-1] - a[k[i][0]-1] == k[i][2]:
score... | [["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22]] | 5 | 147 |
import itertools as it
n,m,q = map(int,input().split())
ar = [[0]*4]*q
for i in range(q):
ar[i] = [int(s) for s in input().split()]
A = it.combinations_with_replacement(list(range(1,m+1)),n)
mx = 0
for cnd in A:
mx_tmp=0
for i in range(q):
if(A[ar[i][1]-1] - A[ar[i][0]-1] == ar[i][2]):
... | import itertools as it
n,m,q = map(int,input().split())
ar = [[0]*4]*q
for i in range(q):
ar[i] = [int(s) for s in input().split()]
A = list(it.combinations_with_replacement(list(range(1,m+1)),n))
mx = 0
for cnd in A:
mx_tmp=0
for i in range(q):
if(cnd[ar[i][1]-1] - cnd[ar[i][0]-1] == ar[i][2])... | [["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25], ["-", 15, 23, 0, 666, 0, 657, 31, 206, 51, 22], ["+", 15, 23, 0, 666, 0, 657, 31, 206, 51, 22], ["-", 15, 23, 0, 666, 0, 657, 12, 206, 51, 22], ["+", 15, 23, 0, 666, 0, 657, 12, 206, 51, ... | 5 | 159 |
#include <bits/stdc++.h>
using namespace std;
#include <cstdio>
#define el "\n"
#define sp " "
typedef long long ll;
ll n, m, q;
vector<ll> a(50), b(50), c(50), d(50);
void call(vector<ll> A, ll &ans) {
if (A.size() == m) {
ll k = 0;
for (ll i = 0; i < q; i++) {
if (A[b[i] - 1] - A[a[i] - 1] == c[i])
... | #include <bits/stdc++.h>
using namespace std;
#include <cstdio>
#define el "\n"
#define sp " "
typedef long long ll;
ll n, m, q;
vector<ll> a(50), b(50), c(50), d(50);
void call(vector<ll> A, ll &ans) {
if (A.size() == n) {
ll k = 0;
for (ll i = 0; i < q; i++) {
if (A[b[i] - 1] - A[a[i] - 1] == c[i])
... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]] | 1 | 292 |
n,m,q=map(int,input().split())
a=[0]*q
b=[0]*q
c=[0]*q
d=[0]*q
A=[]
for i in range(q):
a[i],b[i],c[i],d[i]=map(int,input().split())
def score(A):
sum=0
for (ai,bi,ci,di) in zip(a,b,c,d):
if A[bi-1]-A[ai-1]==ci:
sum+=di
return sum
def fbs(A):
if len(A)==n:
return score(A)
if len(A)>0:
pre_l... | n,m,q=map(int,input().split())
a=[0]*q
b=[0]*q
c=[0]*q
d=[0]*q
A=[]
for i in range(q):
a[i],b[i],c[i],d[i]=map(int,input().split())
def score(A):
sum=0
for (ai,bi,ci,di) in zip(a,b,c,d):
if A[bi-1]-A[ai-1]==ci:
sum+=di
return sum
def fbs(A):
if len(A)==n:
return score(A)
if len(A)>0:
pre_l... | [["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]] | 5 | 228 |
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int N, M, Q, ans = 0;
vector<int> a(50), b(50), c(50), d(50), A(10);
void dfs(int dep) {
if (d... | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int N, M, Q, ans = 0;
vector<int> a(50), b(50), c(50), d(50), A(10);
void dfs(int dep) {
if (d... | [["+", 31, 16, 31, 69, 341, 342, 0, 16, 17, 33], ["+", 31, 16, 31, 69, 341, 342, 0, 16, 12, 13], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 262 |
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
int N, M, Q; // 長さN、M種類の数列
vector<int> a, b, c, d; // Qの要素
long long score(const vector<int> &A) {
long long res = 0;
for (int i = 0; i < Q; ++i) {
if (A[b[i]] - A[a[i]] == c[i])
r... | #include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
int N, M, Q; // 長さN、M種類の数列
vector<int> a, b, c, d; // Qの要素
long long score(const vector<int> &A) {
long long res = 0;
for (int i = 0; i < Q; ++i) {
if (A[b[i]] - A[a[i]] == c[i])
r... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18]] | 1 | 320 |
#include <bits/stdc++.h>
using namespace std;
int n, m, q;
vector<int> a, b, c, d;
int ans = 0;
void dfs(vector<int> k) {
if ((int)k.size() == m + 1) {
int sco = 0;
for (int i = 0; i < q; i++) {
if (k.at(b.at(i)) - k.at(a.at(i)) == c.at(i))
sco += d.at(i);
}
ans = max(ans, sco);
ret... | #include <bits/stdc++.h>
using namespace std;
int n, m, q;
vector<int> a, b, c, d;
int ans = 0;
void dfs(vector<int> k) {
if ((int)k.size() == n + 1) {
int sco = 0;
for (int i = 0; i < q; i++) {
if (k.at(b.at(i)) - k.at(a.at(i)) == c.at(i))
sco += d.at(i);
}
ans = max(ans, sco);
ret... | [["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22]] | 1 | 263 |
N, M, Q = map(int, input().split())
query = []
for _ in range(Q):
query.append(tuple(map(int, input().split())))
res = 0
def solve(A):
global res
if len(A) == N:
tmp = 0
for q in query:
a, b, c, d = q
if A[b - 1] - A[a - 1] == c:
tmp += d
... | N, M, Q = map(int, input().split())
query = []
for _ in range(Q):
query.append(tuple(map(int, input().split())))
res = 0
def solve(A):
global res
if len(A) == N:
tmp = 0
for q in query:
a, b, c, d = q
if A[b - 1] - A[a - 1] == c:
tmp += d
... | [["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612]] | 5 | 157 |
/*
Author:zeke
pass System Test!
GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include... | /*
Author:zeke
pass System Test!
GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 1 | 513 |
/*
Author:zeke
pass System Test!
GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include... | /*
Author:zeke
pass System Test!
GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 1 | 485 |
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <climits>
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <deque> // deque
#include <functional>
#incl... | #include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <climits>
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <deque> // deque
#include <functional>
#incl... | [["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 38], ["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 35]] | 1 | 283 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int n, m, q;
vector<int> a, b, c, d;
int ans = 0;
void dfs(vector<int> A) {
if (A.size() == n + 1) {
int now = 0;
rep(i, n) {
if (A[b[i]] - A[a[i]] == c[i])
now += d[i];
}
... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int n, m, q;
vector<int> a, b, c, d;
int ans = 0;
void dfs(vector<int> A) {
if (A.size() == n + 1) {
int now = 0;
rep(i, q) {
if (A[b[i]] - A[a[i]] == c[i])
now += d[i];
}
... | [["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78]] | 1 | 236 |
vn,m,q=map(int,input().split())
lis=[]
for i in range(q):
a,b,c,d=map(int,input().split())
lis.append((a,b,c,d))
from itertools import combinations_with_replacement
co=list(combinations_with_replacement(range(1,m+1),n))
ans=0
for status in co:
tmp_score=0
for a,b,c,d in lis:
if status[b-1... | n,m,q=map(int,input().split())
lis=[]
for i in range(q):
a,b,c,d=map(int,input().split())
lis.append((a,b,c,d))
from itertools import combinations_with_replacement
co=list(combinations_with_replacement(range(1,m+1),n))
ans=0
for status in co:
tmp_score=0
for a,b,c,d in lis:
if status[b-1]... | [["-", 0, 656, 0, 1, 0, 662, 31, 684, 0, 22], ["+", 0, 656, 0, 1, 0, 662, 31, 684, 0, 22]] | 5 | 140 |
// g++ 5.4.0
#include <iostream>
#include <vector>
using namespace std;
int n, m, q;
int a[50], b[50], c[50], d[50];
long long int maxnum = 0;
long long int calc(std::vector<int> &v) {
long long int sum = 0;
for (int j = 0; j < q; j++) {
int aj = a[j] - 1;
int bj = b[j] - 1;
if (v[bj] - v[aj] == c[j... | // g++ 5.4.0
#include <iostream>
#include <vector>
using namespace std;
int n, m, q;
int a[50], b[50], c[50], d[50];
long long int maxnum = 0;
long long int calc(std::vector<int> &v) {
long long int sum = 0;
for (int j = 0; j < q; j++) {
int aj = a[j] - 1;
int bj = b[j] - 1;
if (v[bj] - v[aj] == c[j... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]] | 1 | 315 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
typedef long long ll;
int n, m, q;
vector<ll> a, b, c, d;
ll score(vector<int> &A) {
ll sc = 0;
rep(i, q) {
if (A[b[i] - A[a[i]]] == c[i])
sc += d[i];
}
return sc;
}
ll recur(vect... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
typedef long long ll;
int n, m, q;
vector<ll> a, b, c, d;
ll score(vector<int> &A) {
ll sc = 0;
rep(i, q) {
if (A[b[i]] - A[a[i]] == c[i])
sc += d[i];
}
return sc;
}
ll recur(vect... | [["+", 51, 16, 31, 16, 31, 69, 341, 342, 0, 73], ["-", 12, 69, 341, 342, 0, 69, 341, 342, 0, 73]] | 1 | 301 |
// C.
#include <algorithm>
#include <iostream>
#include <numeric>
#include <sstream>
#include <vector>
using namespace std;
typedef pair<int, int> II;
typedef pair<II, II> IIII;
typedef long long LL;
int main(int argc, char *argv[]) {
int n, m, q;
cin >> n >> m >> q;
vector<IIII> v(q);
for (int i = 0; i < q... | // C.
#include <algorithm>
#include <iostream>
#include <numeric>
#include <sstream>
#include <vector>
using namespace std;
typedef pair<int, int> II;
typedef pair<II, II> IIII;
typedef long long LL;
int main(int argc, char *argv[]) {
int n, m, q;
cin >> n >> m >> q;
vector<IIII> v(q);
for (int i = 0; i < q... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["-", 0, 338, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 338, 8, 9, 0, 7, 15, 16, 12, 22]] | 1 | 373 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
template <class T> inline... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
template <class T> inline... | [["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13]] | 1 | 394 |
import itertools
N, M, Q = map(int, input().split())
ABCD = [list(map(int, input().split())) for _ in range(Q)]
ans = 0
R = [i for i in range(1, M+1)]
# print(R)
for comb in itertools.combinations(R, N):
# print(comb)
temp = 0
for abcd in ABCD:
a, b, c, d = abcd
if comb[b-1] - comb[a-1] ==... | import itertools
N, M, Q = map(int, input().split())
ABCD = [list(map(int, input().split())) for _ in range(Q)]
# 重複組み合わせ: nHr = n+r-1Cr を考える
ans = 0
R = [i for i in range(1, M+1)]
# print(R)
for comb in itertools.combinations_with_replacement(R, N):
temp = 0
for abcd in ABCD:
a, b, c, d = abcd
... | [["-", 0, 656, 0, 7, 12, 652, 63, 319, 319, 22], ["+", 0, 656, 0, 7, 12, 652, 63, 319, 319, 22]] | 5 | 128 |
import itertools
N, M, Q = map(int, input().split())
a = []
b = []
c = []
d = []
for i in range(Q):
ai, bi, ci, di = map(int, input().split())
a.append(ai)
b.append(bi)
c.append(ci)
d.append(di)
A = [i for i in range(1, M+1)] # [1, 2, 3, 4, ... M]
A_pattern = list(itertools.combinations_with_r... | import itertools
N, M, Q = map(int, input().split())
a = []
b = []
c = []
d = []
for i in range(Q):
ai, bi, ci, di = map(int, input().split())
a.append(ai)
b.append(bi)
c.append(ci)
d.append(di)
A = [i for i in range(1, M+1)] # [1, 2, 3, 4, ... M]
A_pattern = list(itertools.combinations_with_r... | [["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 22]] | 5 | 185 |
import itertools
N, M, Q = map(int, input().split())
P = [[int(x) for x in input().split()] for _ in range(Q)]
li = [x for x in range(1, M+1)]
Com = itertools.combinations(li, N)
ans=0
for com in Com:
reg=0
for a,b,c,d in P:
if com[b-1] - com[a-1] == c:
reg += d
ans = max(reg, ans)
pri... | import itertools
N, M, Q = map(int, input().split())
P = [[int(x) for x in input().split()] for _ in range(Q)]
li = [x for x in range(1, M+1)]
Com = itertools.combinations_with_replacement(li, N)
ans=0
for com in Com:
reg=0
for a,b,c,d in P:
if com[b-1] - com[a-1] == c:
reg += d
ans = ... | [["-", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22]] | 5 | 127 |
N, M, Q = list(map(int, input().split()))
a = []
b = []
c = []
d = []
for _ in range(Q):
abcd = list(map(int, input().split()))
a.append(abcd[0]-1)
b.append(abcd[1]-1)
c.append(abcd[2])
d.append(abcd[3])
import itertools
ans = 0
for p in itertools.combinations_with_replacement([i for i in range(1, ... | N, M, Q = list(map(int, input().split()))
a = []
b = []
c = []
d = []
for _ in range(Q):
abcd = list(map(int, input().split()))
a.append(abcd[0]-1)
b.append(abcd[1]-1)
c.append(abcd[2])
d.append(abcd[3])
import itertools
ans = 0
for p in itertools.combinations_with_replacement([i for i in range(1, ... | [["-", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 187 |
#include <iostream>
#include <vector>
using namespace std;
int n, m, q;
vector<long long> a, b, c, d;
long long score(const vector<int> &A) {
long long res = 0;
for (int i = 0; i < q; i++) {
if (A[b[i]] - A[a[i]] == c[i])
res += d[i];
}
return res;
}
long long dfs(vector<int> &A) {
if (A.size() =... | #include <iostream>
#include <vector>
using namespace std;
int n, m, q;
vector<long long> a, b, c, d;
long long score(const vector<int> &A) {
long long res = 0;
for (int i = 0; i < q; i++) {
if (A[b[i]] - A[a[i]] == c[i])
res += d[i];
}
return res;
}
long long dfs(vector<int> &A) {
if (A.size() =... | [["-", 0, 43, 49, 50, 51, 23, 0, 41, 64, 13], ["+", 0, 43, 49, 50, 51, 23, 0, 41, 64, 13]] | 1 | 304 |
n,m,q = map(int,input().split())
a = [0] * q
b = [0] * q
c = [0] * q
d = [0] * q
for i in range(q):
a[i], b[i], c[i], d[i] = map(int, input().split())
mm = [0]*m
for k in range(1,m+1,1):
mm[k-1]=k
A = list(itertools.combinations_with_replacement(mm, n))
su = 0
ans = 0
for x in range(len(A)):
l=A[x]
... | import itertools
n,m,q = map(int,input().split())
a = [0] * q
b = [0] * q
c = [0] * q
d = [0] * q
for i in range(q):
a[i], b[i], c[i], d[i] = map(int, input().split())
mm = [0]*m
for k in range(1,m+1,1):
mm[k-1]=k
A = list(itertools.combinations_with_replacement(mm, n))
su = 0
ans = 0
for x in range(len(A)... | [["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22]] | 5 | 209 |
n,m,q = map(int,input().split())
a=[]
b=[]
c=[]
d=[]
max_= 0
def dfs(A):
global max_
ans = 0
last = A[-1]
if len(A) == n+1:
for i in range(n):
if A[b[i]]-A[a[i]] == c[i]:
ans += d[i]
max_ = max(max_, ans)
return
for i in range(last, m+1):
dfs(A+[i])
for i in range(q):
aa... | n,m,q = map(int,input().split())
a=[]
b=[]
c=[]
d=[]
max_= 0
def dfs(A):
global max_
ans = 0
last = A[-1]
if len(A) == n+1:
for i in range(q):
if A[b[i]]-A[a[i]] == c[i]:
ans += d[i]
max_ = max(max_, ans)
return
for i in range(last, m+1):
dfs(A+[i])
for i in range(q):
aa... | [["-", 64, 196, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 64, 196, 0, 7, 12, 652, 3, 4, 0, 22]] | 5 | 192 |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <iostream>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<long long int, long long int>, null_type,
less<pair<long long int, long long int>>, rb_tree_tag,
tree_o... | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <iostream>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<long long int, long long int>, null_type,
less<pair<long long int, long long int>>, rb_tree_tag,
tree_o... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]] | 1 | 328 |
import itertools
n,m,q = map(int,input().split())
a = [0]*q
b = [0]*q
c = [0]*q
d = [0]*q
for i in range(q):
a[i],b[i],c[i],d[i] = map(int,input().split())
ans = 0
for A in itertools.combinations_with_replacement(range(1,m+1),n):
cnt = 0
for i in range(q):
if A[b[i]-1] - A[a[i]-1] == c[i]:
... | import itertools
n,m,q = map(int,input().split())
a = [0]*q
b = [0]*q
c = [0]*q
d = [0]*q
for i in range(q):
a[i],b[i],c[i],d[i] = map(int,input().split())
ans = 0
for A in itertools.combinations_with_replacement(range(1,m+1),n):
cnt = 0
for i in range(q):
if A[b[i]-1] - A[a[i]-1] == c[i]:
... | [["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22]] | 5 | 165 |
n,m,q = map(int,input().split())
a = [0]*q
b = [0]*q
c = [0]*q
d = [0]*q
for i in range(n):
a[i],b[i],c[i],d[i] = map(int,input().split())
a[i] -= 1
b[i] -= 1
A = [0]*n
ans = 0
def dfs(h):
global ans
if h == n-1:
cnt = 0
for i in range(q):
if A[b[i]] - A[a[i]] == c[i]:
... | n,m,q = map(int,input().split())
a = [0]*q
b = [0]*q
c = [0]*q
d = [0]*q
for i in range(q):
a[i],b[i],c[i],d[i] = map(int,input().split())
a[i] -= 1
b[i] -= 1
A = [0]*n
ans = 0
def dfs(h):
global ans
if h == n-1:
cnt = 0
for i in range(q):
if A[b[i]] - A[a[i]] == c[i]:
... | [["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22]] | 5 | 228 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge {
long long to, cost;
};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#defin... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge {
long long to, cost;
};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#defin... | [["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 57, 64, 9, 0, 14, 8, 9, 0, 46], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13]] | 1 | 709 |
#include <bits/stdc++.h>
using namespace std;
int a[50], b[50], c[50], d[50];
int n, m, q;
int ans = 0;
int A[10];
void dfs(int dep, int pre) {
if (dep == n) {
int sum = 0;
for (int i = 0; i < q; i++) {
if (A[b[i] - 1] - A[a[i] - 1] == c[i])
sum += d[i];
}
ans = max(sum, ans);
ret... | #include <bits/stdc++.h>
using namespace std;
int a[50], b[50], c[50], d[50];
int n, m, q;
int ans = 0;
int A[10];
void dfs(int dep, int pre) {
if (dep == n) {
int sum = 0;
for (int i = 0; i < q; i++) {
if (A[b[i] - 1] - A[a[i] - 1] == c[i])
sum += d[i];
}
ans = max(sum, ans);
ret... | [["-", 75, 76, 0, 9, 0, 7, 15, 16, 17, 18], ["-", 0, 9, 0, 7, 15, 16, 12, 16, 31, 22], ["-", 0, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 0, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["+", 75, 76, 0, 9, 0, 7, 15, 16, 17, 19], ["+", 75, 76, 0, 9, 0, 7, 15, 16, 12, 22], ["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 1... | 1 | 232 |
from itertools import combinations_with_replacement
N,M,Q = map(int,input().split())
A = []
for i in range(Q):
b = list(map(int,input().split()))
A.append(b)
T = range(M+1)
K = list(combinations_with_replacement(T,N))
ans = 0
for line in K:
total = 0
for combi in A:
if line[combi[1]-1] - line[... | from itertools import combinations_with_replacement
N,M,Q = map(int,input().split())
A = []
for i in range(Q):
b = list(map(int,input().split()))
A.append(b)
T = range(1,M+1)
K = list(combinations_with_replacement(T,N))
ans = 0
for line in K:
total = 0
for combi in A:
if line[combi[1]-1] - lin... | [["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 612], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 21]] | 5 | 136 |
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define IOS ... | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define IOS ... | [["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 0, 32], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]] | 1 | 335 |
def make(n, A, M):
if n == 0:
A_list.append(A)
return
for i in range(A[-1], M+1):
make(n-1, A+[i], M)
n, M, q = map(int, input().split())
A_list = []
for i in range(M+1):
make(n, [i], M)
# print(A_list)
abcd = [list(map(int, input().split())) for _ in range(q)]
ans = 0
for i in A_l... | def make(n, A, M):
if n == 0:
A_list.append(A)
return
for i in range(A[-1], M+1):
make(n-1, A+[i], M)
n, M, q = map(int, input().split())
A_list = []
for i in range(1, M+1):
make(n, [i], M)
# print(A_list)
abcd = [list(map(int, input().split())) for _ in range(q)]
ans = 0
for i in ... | [["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 21]] | 5 | 171 |
N, M, Q = map(int, input().split())
B = [tuple(int(i) for i in input().split()) for i in range(Q)]
A = [1]*N
def recur(A=A, index=0, lim=M):
if index>len(A)-2:
return
while A[index] <= lim-1:
A[index] += 1
yield A[::-1]
yield from recur(A[:], index+1, A[index])
return
def g... | N, M, Q = map(int, input().split())
B = [tuple(int(i) for i in input().split()) for i in range(Q)]
A = [1]*N
def recur(A=A, index=0, lim=M):
if index>len(A)-2:
return
while A[index] <= lim-1:
A[index] += 1
yield A[::-1]
yield from recur(A[:], index+1, A[index])
return
def g... | [["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 21]] | 5 | 192 |
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
... | #define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]] | 1 | 409 |
# 重複順列 19C10
from itertools import combinations_with_replacement as cw
n,m,q = map(int, input().split())
a_candidates = cw([i+1 for i in range(m)],m)
fs = [list(map(int, input().split())) for i in range(q)]
def calc(fs,As):
cnt = 0
for a,b,c,d in fs:
a -= 1
b -= 1
if As[b]-As[a] == c: ... | # 重複順列 19C10
from itertools import combinations_with_replacement as cw
n,m,q = map(int, input().split())
a_candidates = cw([i+1 for i in range(m)],n)
fs = [list(map(int, input().split())) for i in range(q)]
def calc(fs,As):
cnt = 0
for a,b,c,d in fs:
a -= 1
b -= 1
if As[b]-As[a] == c: ... | [["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22]] | 5 | 144 |
//競技プログラミング用のテンプレート
#include "unistd.h"
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
using namespace... | //競技プログラミング用のテンプレート
#include "unistd.h"
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
using namespace... | [["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13]] | 1 | 374 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m, q;
vector<int> a, b, c, d;
int ans = 0;
void dfs(int cnt, vector<int> A, int now) {
if (cnt == n) {
int num = 0;
for (int i = 0; i < q; i++) {
if (A[b[i] - 1] - A[a[i] - 1] == c[i]) {
num += d[i];
}
}
a... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m, q;
vector<int> a, b, c, d;
int ans = 0;
void dfs(int cnt, vector<int> A, int now) {
if (cnt == n) {
int num = 0;
for (int i = 0; i < q; i++) {
if (A[b[i] - 1] - A[a[i] - 1] == c[i]) {
num += d[i];
}
}
a... | [["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 22], ["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13]] | 1 | 273 |
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespac... | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespac... | [["-", 49, 50, 51, 69, 341, 342, 0, 16, 31, 22], ["+", 49, 50, 51, 69, 341, 342, 0, 16, 31, 22]] | 1 | 401 |
n,m,q = map(int,input().split())
abcd_list = []
for i in range(q):
abcd_list.append(list(map(int,input().split())))
a = [1]*n
def next_a(a):
if a[-1] != 10:
a[-1] += 1
else:
d = n-1
while d > 0 and a[d] == 10:
d-=1
if d < 0:
return a
a[d] +=... | n,m,q = map(int,input().split())
abcd_list = []
for i in range(q):
abcd_list.append(list(map(int,input().split())))
a = [1]*n
def next_a(a):
if a[-1] != m:
a[-1] += 1
else:
d = n-1
while d > 0 and a[d] == m:
d-=1
if d < 0:
return a
a[d] += 1
... | [["-", 0, 14, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 14, 8, 196, 0, 57, 15, 666, 0, 22], ["-", 8, 196, 0, 52, 15, 679, 12, 666, 0, 612], ["+", 8, 196, 0, 52, 15, 679, 12, 666, 0, 22], ["-", 0, 656, 0, 52, 15, 666, 0, 657, 12, 612], ["+", 0, 656, 0, 52, 15, 666, 0, 657, 12, 22]] | 5 | 228 |
//#define _GLIBCXX_DEBUG
#include <algorithm>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod = 1e+9 + 7;
ll n, m, q;
vector<ll> a(55), b(55), c(55), d(55);
ll mx;
... | //#define _GLIBCXX_DEBUG
#include <algorithm>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod = 1e+9 + 7;
ll n, m, q;
vector<ll> a(55), b(55), c(55), d(55);
ll mx;
... | [["-", 49, 53, 54, 55, 0, 56, 49, 352, 0, 67]] | 1 | 266 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.