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())
a, b, c, d = [[0]*q for i in range(4)]
for i in range(q):
a[i], b[i], c[i], d[i] = map(int, input().split())
a[i] -= 1
b[i] -= 1
def dfs(vec, mx, cnt):
if cnt:
tmp = 0
for i in range(mx, m+1):
tmp = max(tmp, dfs(vec+[i], i, cnt-1))
... | n, m, q = map(int, input().split())
a, b, c, d = [[0]*q for i in range(4)]
for i in range(q):
a[i], b[i], c[i], d[i] = map(int, input().split())
a[i] -= 1
b[i] -= 1
def dfs(vec, mx, cnt):
if cnt:
tmp = 0
for i in range(mx, m+1):
tmp = max(tmp, dfs(vec+[i], i, cnt-1))
... | [["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 612]] | 5 | 198 |
/*
@・ω・@
*/
// メモ:https://scrapbox.io/hitsujirere-memo/
/*****/
/**/
#pragma GCC target("avx") // CPU 処理並列化
#pragma GCC optimize("O3") // CPU 処理並列化
#pragma GCC optimize("unroll-loops") // 条件処理の呼び出しを減らす
/**/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#inc... |
/*
@・ω・@
*/
// メモ:https://scrapbox.io/hitsujirere-memo/
/*****/
/**/
#pragma GCC target("avx") // CPU 処理並列化
#pragma GCC optimize("O3") // CPU 処理並列化
#pragma GCC optimize("unroll-loops") // 条件処理の呼び出しを減らす
/**/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#inc... | [["-", 0, 56, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 56, 39, 344, 3, 347, 0, 77, 39, 78], ["-", 8, 9, 0, 57, 64, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 57, 64, 9, 0, 43, 39, 78], ["-", 64, 9, 0, 7, 8, 9, 0, 43, 39, 40], ["+", 64, 9, 0, 7, 8, 9, 0, 43, 39, 78], ["-", 10, 43, 49, 50, 51, 23, 0, 41, 64, 13], ["+", 10, 43, 4... | 1 | 2,187 |
#include <iostream>
using namespace std;
struct node {
int a, b, c, d;
} b[55];
int n, m, q;
int a[15];
int ans;
void dfs(int dep, int las) {
if (dep == n + 1) {
int k = 0;
for (int i = 1; i <= q; i++) {
if (a[b[i].b] - a[b[i].a] == b[i].c) {
k += b[i].d;
}
}
ans = max(ans, k);
... | #include <iostream>
using namespace std;
struct node {
int a, b, c, d;
} b[55];
int n, m, q;
int a[15];
int ans;
void dfs(int dep, int las) {
if (dep == n + 1) {
int k = 0;
for (int i = 1; i <= q; i++) {
if (a[b[i].b] - a[b[i].a] == b[i].c) {
k += b[i].d;
}
}
ans = max(ans, k);
... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]] | 1 | 237 |
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define lc (x << 1)
#define rc (x << 1 | 1)
#define gc \
getchar() //(p1... | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define lc (x << 1)
#define rc (x << 1 | 1)
#define gc \
getchar() //(p1... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]] | 1 | 490 |
#define _USE_MATH_DEFINES
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD int(1e9 + 7)
#define INF (long long)(1e18)
long long N, M, Q;
l... | #define _USE_MATH_DEFINES
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD int(1e9 + 7)
#define INF (long long)(1e18)
long long N, M, Q;
l... | [["+", 49, 53, 54, 55, 0, 56, 49, 352, 0, 67], ["-", 0, 16, 31, 16, 12, 2, 3, 4, 0, 13], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 13]] | 1 | 329 |
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF (1 << 29)
#define LINF (1LL << 60)
#define EPS... | #include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF (1 << 29)
#define LINF (1LL << 60)
#define EPS... | [["+", 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, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]] | 1 | 340 |
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
int n, m, q;
int suretsu[100];
int a[100], b[100], c[100], d[100];
int ans = 0;
void saiki(int before, int x) {
if (x == n) {
int sum = 0;
for (int i = 0; i < q; i++) {
if (suretsu[b[i] - 1]... | #include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
int n, m, q;
int suretsu[100];
int a[100], b[100], c[100], d[100];
int ans = 0;
void saiki(int before, int x) {
if (x == n) {
int sum = 0;
for (int i = 0; i < q; i++) {
if (suretsu[b[i] - 1]... | [["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]] | 1 | 241 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vec... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vec... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 481 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, m, q, v[15], a[51], b[51], c[51], d[51], sol;
void backtr(int k, int pos) {
if (k == m) {
int suma = 0;
for (int i = 1; i <= q; i++)
if (v[b[i]] - v[a[i]] == c[i])
suma += d[i];
sol = max(sol, suma);
return;
}
... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, m, q, v[15], a[51], b[51], c[51], d[51], sol;
void backtr(int k, int pos) {
if (k == n) {
int suma = 0;
for (int i = 1; i <= q; i++)
if (v[b[i]] - v[a[i]] == c[i])
suma += d[i];
sol = max(sol, suma);
return;
}
... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]] | 1 | 237 |
import os
from functools import reduce
from operator import mul
import itertools
import sys
if os.getenv("LOCAL"):
sys.stdin = open("_in.txt", "r")
sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353
def ncr(n, r, mod=None):
"""
組み合わせの数 nCr
:param... | import os
from functools import reduce
from operator import mul
import itertools
import sys
if os.getenv("LOCAL"):
sys.stdin = open("_in.txt", "r")
sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353
def ncr(n, r, mod=None):
"""
組み合わせの数 nCr
:param... | [["-", 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, 22]] | 5 | 415 |
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;
template <class T> constexp... | #include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;
template <class T> constexp... | [["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]] | 1 | 333 |
n,m,q=map(int, input().split())
abcd=[list(map(int, input().split())) for i in range(q)]
from itertools import combinations_with_replacement
data=list(range(1,11))
prep=combinations_with_replacement(data, n)
ans=0
for p in prep:
tmp=0
p=sorted(list(p))
for i in range(q):
if p[abcd[i][1]-1]-p[abcd[i]... | n,m,q=map(int, input().split())
abcd=[list(map(int, input().split())) for i in range(q)]
from itertools import combinations_with_replacement
data=list(range(1,m+1))
prep=combinations_with_replacement(data, n)
ans=0
for p in prep:
tmp=0
p=sorted(list(p))
for i in range(q):
if p[abcd[i][1]-1]-p[abcd[i... | [["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 31, 22], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 12, 612]] | 5 | 151 |
#include "bits/stdc++.h"
#include <unordered_set>
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#defin... | #include "bits/stdc++.h"
#include <unordered_set>
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#defin... | [["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13]] | 1 | 1,112 |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 55;
int a[maxn], b[maxn], c[maxn], d[maxn];
int n, m, q;
vector<int> v;
int solve(int pos, int last) {
if (pos == n) {
int ans = 0;
for (int i = 0; i < q; ++i) {
ans += d[i] * (v[b[i] - 1] - v[a[i] - 1] == c[i]);
}
return ans;
}
... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 55;
int a[maxn], b[maxn], c[maxn], d[maxn];
int n, m, q;
vector<int> v;
int solve(int pos, int last) {
if (pos == n) {
int ans = 0;
for (int i = 0; i < q; ++i) {
ans += d[i] * (v[b[i] - 1] - v[a[i] - 1] == c[i]);
}
return ans;
}
... | [["-", 0, 16, 31, 16, 12, 2, 3, 4, 0, 13], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 13]] | 1 | 242 |
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define debug cerr << "-- " << __LINE__ << " --" << endl
#define MOD 1000000007
#define ALL(o) (o).begin(), (o).end()
typedef long long int ll;
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll... | #include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define debug cerr << "-- " << __LINE__ << " --" << endl
#define MOD 1000000007
#define ALL(o) (o).begin(), (o).end()
typedef long long int ll;
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll... | [["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 33], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]] | 1 | 1,235 |
def Int():
return int(input())
def Ints():
return map(int,input().split())
def IntList():
return list(Ints())
def IntMat(N):
return [IntList() for i in range(N)]
N,M,Q = Ints()
List = []
for i in range(Q):
a,b,c,d = Ints()
List.append([a,b,c,d])
import itertools
Num = [i for i in range(N+... | def Int():
return int(input())
def Ints():
return map(int,input().split())
def IntList():
return list(Ints())
def IntMat(N):
return [IntList() for i in range(N)]
N,M,Q = Ints()
List = []
for i in range(Q):
a,b,c,d = Ints()
List.append([a,b,c,d])
import itertools
Num = [i for i in range(N+... | [["+", 0, 659, 12, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 659, 12, 652, 3, 4, 0, 657, 12, 612]] | 5 | 227 |
/*
∫ ∫ ∫
ノヽ
(_ )
(_ )
(______ )
ヽ(´・ω・)ノ
| /
UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1 << 30;
const char bn = '\n';
template <class T> bool c... | /*
∫ ∫ ∫
ノヽ
(_ )
(_ )
(______ )
ヽ(´・ω・)ノ
| /
UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1 << 30;
const char bn = '\n';
template <class T> bool c... | [["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 13], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 13]] | 1 | 796 |
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return... | #!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return... | [["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22]] | 5 | 412 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pl;
#define all(a) (a).begin(), (a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for (ll i = 0; i < (n); i++)
#define rep2(i, n) for (ll i = 0; i < (n); i++)
#define rep3(i, a, b) for (ll i = (a); i < (b)... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pl;
#define all(a) (a).begin(), (a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for (ll i = 0; i < (n); i++)
#define rep2(i, n) for (ll i = 0; i < (n); i++)
#define rep3(i, a, b) for (ll i = (a); i < (b)... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 72], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["-", 0, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, ... | 1 | 524 |
#include <algorithm>
#include <cmath>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int n, m, q;
int a[50], b[50], c[50], d[50];
int ... | #include <algorithm>
#include <cmath>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int n, m, q;
int a[50], b[50], c[50], d[50];
int ... | [["-", 75, 76, 0, 9, 0, 7, 15, 16, 12, 22], ["+", 75, 76, 0, 9, 0, 7, 15, 16, 12, 22]] | 1 | 285 |
def cur(x):
if len(x)<m+1:
ans=0
for i in range(x[-1],m+1):
ans=max(ans,cur(x+[i]))
else:
ans=0
for i in range(q):
[a,b,c,d]=l[i]
if x[b]-x[a]==c: ans+=d
return ans
n,m,q=map(int,input().split())
l=[list(map(int,input().split())) for i in... | def cur(x):
if len(x)<n+1:
ans=0
for i in range(x[-1],m+1):
ans=max(ans,cur(x+[i]))
else:
ans=0
for i in range(q):
[a,b,c,d]=l[i]
if x[b]-x[a]==c: ans+=d
return ans
n,m,q=map(int,input().split())
l=[list(map(int,input().split())) for i in... | [["-", 8, 196, 0, 57, 15, 666, 0, 657, 31, 22], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 31, 22]] | 5 | 148 |
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
int n... | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
int n... | [["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]] | 1 | 289 |
import itertools
n,m,q = map(int,input().split())
sc = []
for i in range(q):
a,b,c,d = map(int,input().split())
sc.append([a,b,c,d])
nums = [(i+1) for i in range(m+1)]
ans = 0
for balls in itertools.combinations_with_replacement(nums, n):
tp = 0
for i in range(q):
if balls[sc[i][1]-1]-balls[sc... | import itertools
n,m,q = map(int,input().split())
sc = []
for i in range(q):
a,b,c,d = map(int,input().split())
sc.append([a,b,c,d])
nums = [(i+1) for i in range(m)]
ans = 0
for balls in itertools.combinations_with_replacement(nums, n):
tp = 0
# print(balls)
for i in range(q):
if balls[sc[... | [["-", 0, 659, 12, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 659, 12, 652, 3, 4, 0, 657, 12, 612]] | 5 | 166 |
#include <bits/stdc++.h>
using namespace std;
template <class T> bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
using P = pair<int, int>;
int n, m, q;
int ans = 0;
vect... | #include <bits/stdc++.h>
using namespace std;
template <class T> bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
using P = pair<int, int>;
int n, m, q;
int ans = 0;
vect... | [["-", 75, 76, 0, 9, 0, 7, 15, 16, 17, 18], ["+", 75, 76, 0, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]] | 1 | 365 |
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
const int INF = 1e9;
typedef pair<int, int> P;
int main() {
int n, m, q;
cin >> n >> m >> q;
int a[q], b[q], c[q], d[q];
for (int i = 0; i <... | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
const int INF = 1e9;
typedef pair<int, int> P;
int main() {
int n, m, q;
cin >> n >> m >> q;
int a[q], b[q], c[q], d[q];
for (int i = 0; i <... | [["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 22], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 22]] | 1 | 529 |
#include <bits/stdc++.h>
using namespace std;
// template {{{
#define range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r)-1; i >= (int)(l); (i) -= 1)
#define whole(f, x, ...) \
([&](decltype((x)) container)... | #include <bits/stdc++.h>
using namespace std;
// template {{{
#define range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r)-1; i >= (int)(l); (i) -= 1)
#define whole(f, x, ...) \
([&](decltype((x)) container)... | [["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]] | 1 | 825 |
n, m, q = map(int, input().split())
check = [list(map(int, input().split())) for _ in range(q)]
def calc(r):
res = 0
for a, b, c, d in check:
if r[b-1] - r[a-1] == c:
res += d
return res
def dfs(t):
if len(t) == n:
return calc(t)
res = [dfs(t + [i]) for i in range(t[... | n, m, q = map(int, input().split())
check = [list(map(int, input().split())) for _ in range(q)]
def calc(r):
res = 0
for a, b, c, d in check:
if r[b-1] - r[a-1] == c:
res += d
return res
def dfs(t):
if len(t) == n:
return calc(t)
res = [dfs(t + [i]) for i in range(t[... | [["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 612], ["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 21]] | 5 | 163 |
#pragma GCC optimize("Ofast")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string... | #pragma GCC optimize("Ofast")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]] | 1 | 2,656 |
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define int long long
int ans = 0;
vector<tuple<int, int, int, int>> vec;
void go(int id, int last, int n, int m, vector<int> &v) {
if (id == n) {
int cur = 0;
for (auto [a, b, c, d] : vec) {
if (v[b - 1] - v[a - 1] ==... | #include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define int long long
int ans = 0;
vector<tuple<int, int, int, int>> vec;
void go(int id, int last, int n, int m, vector<int> &v) {
if (id == n) {
int cur = 0;
for (auto [a, b, c, d] : vec) {
if (v[b - 1] - v[a - 1] ==... | [["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]] | 1 | 286 |
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;
int a[50], b[50], c[50], d[50], y[10];
int n, m, q;
int sol;
void dfs(int x, int p) {
if (x == 10) {
int sum = 0;
for (int i = 0; i < q; ++i)
if (y[b[i]] - y[a[i]] == c[i])
s... | #include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;
int a[50], b[50], c[50], d[50], y[10];
int n, m, q;
int sol;
void dfs(int x, int p) {
if (x == n) {
int sum = 0;
for (int i = 0; i < q; ++i)
if (y[b[i]] - y[a[i]] == c[i])
su... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]] | 1 | 243 |
ans = []
def dfs(li):
if len(li) == n:
ans.append(li)
return
else:
for i in range(li[-1], m + 1):
dfs(li + [i])
n, m, q = map(int, input().split())
info = [list(map(int, input().split())) for i in range(q)]
for i in range(1, m):
dfs([i])
# print(ans)
res = 0
for pt... | ans = []
def dfs(li):
if len(li) == n:
ans.append(li)
return
else:
for i in range(li[-1], m + 1):
dfs(li + [i])
n, m, q = map(int, input().split())
info = [list(map(int, input().split())) for i in range(q)]
for i in range(1, m + 1):
dfs([i])
# print(ans)
res = 0
fo... | [["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]] | 5 | 168 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<int, int>;
using PL = pair<ll, ll>;
using vp = vector<P>;
using vpl = vector<PL>;
#define pqueue priority_queue
template <typename T> constexp... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<int, int>;
using PL = pair<ll, ll>;
using vp = vector<P>;
using vpl = vector<PL>;
#define pqueue priority_queue
template <typename T> constexp... | [["-", 0, 1, 0, 2, 3, 4, 0, 41, 75, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 41, 75, 13]] | 1 | 1,972 |
from itertools import combinations_with_replacement
n,m,q=map(int,input().split())
l=[list(map(int,input().split())) for i in range(q)]
ans=0
for i in combinations_with_replacement([i for i in range(1,11)], n):
tmp=0
for a,b,c,d in l:
if i[b-1]-i[a-1]==c:
tmp+=d
ans=max(ans,tmp)
print(an... | from itertools import combinations_with_replacement
n,m,q=map(int,input().split())
l=[list(map(int,input().split())) for i in range(q)]
ans=0
for i in combinations_with_replacement([i for i in range(1,m+1)], n):
tmp=0
for a,b,c,d in l:
if i[b-1]-i[a-1]==c:
tmp+=d
ans=max(ans,tmp)
print(a... | [["-", 0, 658, 0, 659, 12, 652, 3, 4, 0, 612], ["+", 0, 659, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 659, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 659, 12, 652, 3, 4, 0, 657, 12, 612]] | 5 | 118 |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>
int n, m, q;
vi a(51), b(51), c(51), d(51);
int ans = 0;
void solve(vi &v) {
if (v.size() == 10) {
int res = 0;
for (int i = 1; i <= q; i++) {
if (v[b[i] - 1] - v[... | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>
int n, m, q;
vi a(51), b(51), c(51), d(51);
int ans = 0;
void solve(vi &v) {
if (v.size() == n) {
int res = 0;
for (int i = 1; i <= q; i++) {
if (v[b[i] - 1] - v[a... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]] | 1 | 286 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define DEC(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
typedef pair<ll, ll> pi;
typedef pair<pi, pi> pii;
#define f first
#define s second
#define pb push_back
#define a... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define DEC(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
typedef pair<ll, ll> pi;
typedef pair<pi, pi> pii;
#define f first
#define s second
#define pb push_back
#define a... | [["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["-", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]] | 1 | 326 |
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
//#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for0(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i <= (n); i++)
#define mp make_pair
#define all(x) x.begin(), x.end()
#... | #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
//#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for0(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i <= (n); i++)
#define mp make_pair
#define all(x) x.begin(), x.end()
#... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]] | 1 | 265 |
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x, y) CPP_CAT_I(x, y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x, y) x##y
using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int... | #include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x, y) CPP_CAT_I(x, y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x, y) x##y
using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]] | 1 | 597 |
#define DEBUG 1
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <util... | #define DEBUG 1
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <util... | [["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]] | 1 | 1,997 |
package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
var si = bufio.NewScanner(os.Stdin)
func readInt() int {
si.Scan()
r, _ := strconv.Atoi(si.Text())
return r
}
func max(x, y int) int {
if x > y {
return x
}
return y
}
func calc(Q int, q [50][4]int, n, m int, a []int) int {
ret := 0
if n == 0 {
f... | package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
var si = bufio.NewScanner(os.Stdin)
func readInt() int {
si.Scan()
r, _ := strconv.Atoi(si.Text())
return r
}
func max(x, y int) int {
if x > y {
return x
}
return y
}
func calc(Q int, q [50][4]int, n, m int, a []int) int {
ret := 0
if n == 0 {
f... | [["-", 3, 4, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 3, 4, 0, 2, 3, 4, 0, 16, 12, 433]] | 7 | 370 |
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)
# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
return [ int(s) for s in input().split(" ")]
# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
return [ int(input()) for _ in range(n)]
# 改行またはスペース... | import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)
# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
return [ int(s) for s in input().split(" ")]
# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
return [ int(input()) for _ in range(n)]
# 改行またはスペース... | [["-", 64, 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], ["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612]] | 5 | 338 |
n, m, q = map(int, input().split())
lis = [list(map(int, input().split())) for _ in range(q)]
import itertools
seq = list(range(1,m+1))
lis_p = list(itertools.combinations(seq, n))
ans = 0
ans_max = 0
for li_p in lis_p:
for li in lis:
if li_p[li[1]-1] - li_p[li[0]-1] == li[2]:
ans += li[3]
... | n, m, q = map(int, input().split())
lis = [list(map(int, input().split())) for _ in range(q)]
import itertools
seq = list(range(1,m+1))
lis_p = list(itertools.combinations_with_replacement(seq, n))
ans = 0
ans_max = 0
for li_p in lis_p:
for li in lis:
if li_p[li[1]-1] - li_p[li[0]-1] == li[2]:
... | [["-", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22]] | 5 | 136 |
import itertools
def nasu(s, l):
n = N - 2
T = []
for i in range(s, l + 1):
T.append(i)
L = list(itertools.combinations_with_replacement(T, n))
ans = 0
for i in L:
P = [s] + list(i) + [l]
ans = max(ans, honya(P))
return ans
def honya(L):
ans = 0
for a, b, c, d in abcd:
a -= 1
b -=... | import itertools
def nasu(s, l):
n = N - 2
T = []
for i in range(s, l + 1):
T.append(i)
L = list(itertools.combinations_with_replacement(T, n))
ans = 0
for i in L:
P = [s] + list(i) + [l]
ans = max(ans, honya(P))
return ans
def honya(L):
ans = 0
for a, b, c, d in abcd:
a -= 1
b -=... | [["-", 0, 656, 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], ["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612]] | 5 | 216 |
N,M,Q=map(int,input().split())
s=[list(map(int, input().split())) for i in range(Q)]
def ju(N,a,l):
k=[]
if N==1:
for i in range(a,M+1):
k+=[l+[i]]
else:
for i in range(a,M+1):
k+=ju(N-1,i,l+[i])
return k
l=ju(N,0,[])
a=0
for i in l:
t=0
for j in s:
... | N,M,Q=map(int,input().split())
s=[list(map(int, input().split())) for i in range(Q)]
def ju(N,a,l):
k=[]
if N==1:
for i in range(a,M+1):
k+=[l+[i]]
else:
for i in range(a,M+1):
k+=ju(N-1,i,l+[i])
return k
l=ju(N,1,[])
a=0
for i in l:
t=0
for j in s:
... | [["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 612], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 612]] | 5 | 187 |
#include <iostream>
#ifdef MBP
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define REP(i, n) for (long long int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (long long int i = 1, i##_len = (n); i <= i##_len; ... | #include <iostream>
#ifdef MBP
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define REP(i, n) for (long long int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (long long int i = 1, i##_len = (n); i <= i##_len; ... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]] | 1 | 1,450 |
n, m, q = list(map(int, input().split(' ')))
aq = [None] * q
bq = [None] * q
cq = [None] * q
dq = [None] * q
for i in range(q):
aq[i], bq[i], cq[i], dq[i] = list(map(int, input().split(' ')))
result = 0
def dfs(i, ary):
global result
if i == n:
val = 0
for j in range(q):
if ar... | n, m, q = list(map(int, input().split(' ')))
aq = [None] * q
bq = [None] * q
cq = [None] * q
dq = [None] * q
for i in range(q):
aq[i], bq[i], cq[i], dq[i] = list(map(int, input().split(' ')))
result = 0
def dfs(i, ary):
global result
if i == n:
val = 0
for j in range(q):
if ar... | [["-", 64, 196, 0, 1, 0, 677, 12, 206, 206, 22], ["+", 64, 196, 0, 1, 0, 677, 12, 206, 206, 22]] | 5 | 241 |
n , m , q = map(int,input().split())
p = []
for i in range(q):
a , b , c , d = map(int,input().split())
p.append([a,b,c,d])
ans = 0
for a1 in range(1,m+1):
for a2 in range(a1,m+1):
for a3 in range(a2,m+1):
for a4 in range(a3,m+1):
for a5 in range(a4,m+1):
... | n , m , q = map(int,input().split())
p = []
for i in range(q):
a , b , c , d = map(int,input().split())
p.append([a,b,c,d])
ans = 0
for a1 in range(1,m+1):
for a2 in range(a1,m+1):
for a3 in range(a2,m+1):
for a4 in range(a3,m+1):
for a5 in range(a4,m+1):
... | [["+", 8, 196, 0, 1, 0, 662, 12, 634, 0, 612], ["+", 8, 196, 0, 1, 0, 662, 12, 634, 0, 21]] | 5 | 252 |
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
// #include <bits/stdc++.h>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#in... | //#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
// #include <bits/stdc++.h>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#in... | [["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]] | 1 | 556 |
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a... | // clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a... | [["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]] | 1 | 782 |
import itertools
n,m,q=map(int,input().split())
abcd=[list(map(int,input().split())) for _ in range(q)]
l=list(range(1,m+1))
l=list(itertools.combinations_with_replacement(l,m))
ans=0
for i in l:
kari=0
for j in range(q):
if i[abcd[j][1]-1]-i[abcd[j][0]-1]==abcd[j][2]:
kari+=abcd[j][3]
ans=max(ans,kari)... | import itertools
n,m,q=map(int,input().split())
abcd=[list(map(int,input().split())) for _ in range(q)]
l=list(range(1,m+1))
l=list(itertools.combinations_with_replacement(l,n))
ans=0
for i in l:
kari=0
for j in range(q):
if i[abcd[j][1]-1]-i[abcd[j][0]-1]==abcd[j][2]:
kari+=abcd[j][3]
ans=max(ans,kari)... | [["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 22]] | 5 | 147 |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb(x) push_back(x)
#define fi first
#define se second
#define mp(x, y) make_pair(x, y);
/*struct comp
{
bool operator()()
{
}
};*/
struct node {
int a, b, c, d;
node(int A, int B, int C, int D) {
a = A;
b = B;
c = ... | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb(x) push_back(x)
#define fi first
#define se second
#define mp(x, y) make_pair(x, y);
/*struct comp
{
bool operator()()
{
}
};*/
struct node {
int a, b, c, d;
node(int A, int B, int C, int D) {
a = A;
b = B;
c = ... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]] | 1 | 344 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;
ll p[10];
int main() {
ll n, m, i, j, k;
ll q;
cin >> n >> m >> q;
vector<ll> a(q), b(q), c(q), d(q);
for (i = 0; i < q; i++) {
cin >> a[i] >> b[i] >> c[i] >> d[i];
}
ll ret = -... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;
ll p[10];
int main() {
ll n, m, i, j, k;
ll q;
cin >> n >> m >> q;
vector<ll> a(q), b(q), c(q), d(q);
for (i = 0; i < q; i++) {
cin >> a[i] >> b[i] >> c[i] >> d[i];
}
ll ret = 0... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]] | 1 | 275 |
N, M, Q = map(int, input().split())
ts = [tuple(map(int, input().split())) for _ in range(Q)]
As = [0] * N
def next(ls):
if ls[-1] < M:
ls[-1] += 1
else:
for i, elem in reversed(list(enumerate(ls))):
if elem < M:
for j in range(i, N):
ls[j] = ele... | N, M, Q = map(int, input().split())
ts = [tuple(map(int, input().split())) for _ in range(Q)]
As = [1] * N
def next(ls):
if ls[-1] < M:
ls[-1] += 1
else:
for i, elem in reversed(list(enumerate(ls))):
if elem < M:
for j in range(i, N):
ls[j] = ele... | [["-", 0, 1, 0, 662, 12, 657, 31, 634, 0, 612], ["+", 0, 1, 0, 662, 12, 657, 31, 634, 0, 612]] | 5 | 182 |
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
... | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
... | [["-", 0, 7, 10, 43, 49, 50, 51, 41, 64, 13], ["+", 0, 7, 10, 43, 49, 50, 51, 41, 64, 13]] | 1 | 931 |
from itertools import (
accumulate, # 累積和のイテレータ
groupby, # 値をkey,同じ値の集まりをgroup
permutations, # 順列
combinations, # 組み合わせ
product, # 重複あり順列(直積, 深いネストにも使える)
combinations_with_replacement, # 重複あり組み合わせ
)
N, M, Q = map(int, input().split())
q = []
for _ in range(Q):
q.append(list(map(int, i... | from itertools import (
accumulate, # 累積和のイテレータ
groupby, # 値をkey,同じ値の集まりをgroup
permutations, # 順列
combinations, # 組み合わせ
product, # 重複あり順列(直積, 深いネストにも使える)
combinations_with_replacement, # 重複あり組み合わせ
)
N, M, Q = map(int, input().split())
q = []
for _ in range(Q):
q.append(list(map(int, i... | [["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 612]] | 5 | 155 |
import itertools
N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for i in range(Q)]
A_itr = itertools.combinations(range(1, M+1), N)
max_score = 0
for A in A_itr:
score = 0
for j_abcd in abcd:
if A[j_abcd[1]-1]-A[j_abcd[0]-1] == j_abcd[2]:
score += j_abcd[3]
m... | import itertools
N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for i in range(Q)]
A_itr = itertools.combinations_with_replacement(range(1, M+1), N)
max_score = 0
for A in A_itr:
score = 0
for j_abcd in abcd:
if A[j_abcd[1]-1]-A[j_abcd[0]-1] == j_abcd[2]:
score +... | [["-", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22]] | 5 | 123 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
/* REPmacro */
#define FOR(i, a, b) for (int ... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
/* REPmacro */
#define FOR(i, a, b) for (int ... | [["-", 0, 9, 0, 43, 49, 50, 51, 41, 64, 13], ["+", 0, 9, 0, 43, 49, 50, 51, 41, 64, 13]] | 1 | 402 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
co... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
co... | [["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]] | 1 | 412 |
N, M, Q = map(int, input().split())
X=[0]*Q
for i in range(Q):
X[i] = list(map(int, input().split()))
from itertools import combinations_with_replacement
def solve(N,M,Q,X):
ans = 0
for c in combinations_with_replacement(range(1,11), N-1):
A = [1]+list(c)
score = 0
for x in X:
... | N, M, Q = map(int, input().split())
X=[0]*Q
for i in range(Q):
X[i] = list(map(int, input().split()))
from itertools import combinations_with_replacement
def solve(N,M,Q,X):
ans = 0
for c in combinations_with_replacement(range(1,M+1), N-1):
A = [1]+list(c)
score = 0
for x in X:
... | [["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 31, 22], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 12, 612]] | 5 | 162 |
#include <bits/stdc++.h>
using namespace std;
struct quer {
int a, b, c, d;
};
int n, m, q;
int ans;
quer inp[50 + 1];
void genallp(vector<int> A) {
if (A.size() == n + 1) {
int fans = 0;
for (int i = 1; i <= q; i++) {
if (A[inp[i].b] - A[inp[i].a] == inp[i].c)
fans += inp[i].d;
}
an... | #include <bits/stdc++.h>
using namespace std;
struct quer {
int a, b, c, d;
};
int n, m, q;
int ans;
quer inp[50 + 1];
void genallp(vector<int> A) {
if (A.size() == n + 1) {
int fans = 0;
for (int i = 1; i <= q; i++) {
if (A[inp[i].b] - A[inp[i].a] == inp[i].c)
fans += inp[i].d;
}
an... | [["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]] | 1 | 258 |
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
... | #define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
... | [["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 0, 7, 15, 16, 12, 16, 12, 23, 0, 24], ["-", 15, 16, 12, 16, 12, 23, 0, 16, 31, 22], ["-", 15, 16, 12, 16, 12, 23, 0, 16, 17, 33], ["-", 15, 16, 12, 16, 12, 23, 0, 16, 12, 22], ["-", 0, 7, 15, 16, 12, 16, 12, 23, 0, 25]] | 1 | 572 |
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string.h>
#include <vector>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
typedef long long... | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string.h>
#include <vector>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
typedef long long... | [["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]] | 1 | 317 |
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#else
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
public:
int n, m, q;
int a[55], b[55], c[55]... | #include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#else
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
public:
int n, m, q;
int a[55], b[55], c[55]... | [["-", 8, 9, 0, 1, 0, 11, 31, 69, 28, 22], ["+", 8, 9, 0, 1, 0, 11, 31, 69, 28, 22]] | 1 | 322 |
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin(), (x).end()
#define lowbit(x) x & -x
#define pb push_back
#define ls (id << 1)
#define rs (id << 1 | 1)
#define Rint register int
#define UNI(x) sort(ALL(x)), x.resize(unique(ALL(x)) ... | #include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin(), (x).end()
#define lowbit(x) x & -x
#define pb push_back
#define ls (id << 1)
#define rs (id << 1 | 1)
#define Rint register int
#define UNI(x) sort(ALL(x)), x.resize(unique(ALL(x)) ... | [["-", 8, 9, 0, 1, 0, 11, 31, 69, 28, 22], ["+", 8, 9, 0, 1, 0, 11, 31, 69, 28, 22]] | 1 | 875 |
/**
If comrades that you trust gather around you, hope can take physical form and
become visible. That’s what I believe.
*/
#include <bits/stdc++.h>
using namespace std;
/**
(▀̿Ĺ̯▀̿ ̿) (ง ͠° ͟ل͜ ͡°)ง
*/
const int N = 57;
// int a[N], b[N], c[N], d[N];
struct T {
int a, b, c, d;
};
T a[N];
int n, m, q;
set<vector<int... | /**
If comrades that you trust gather around you, hope can take physical form and
become visible. That’s what I believe.
*/
#include <bits/stdc++.h>
using namespace std;
/**
(▀̿Ĺ̯▀̿ ̿) (ง ͠° ͟ل͜ ͡°)ง
*/
const int N = 57;
// int a[N], b[N], c[N], d[N];
struct T {
int a, b, c, d;
};
T a[N];
int n, m, q;
set<vector<int... | [["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 20], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 47]] | 1 | 360 |
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define fastio \
ios_base::sync_with_stdio(false); \
cin.tie(nullptr);
#define all(x) x.begin(), x.end()
#defi... | #include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define fastio \
ios_base::sync_with_stdio(false); \
cin.tie(nullptr);
#define all(x) x.begin(), x.end()
#defi... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 38], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]] | 1 | 391 |
import sys
sys.setrecursionlimit(10**8)
N,M,Q = map(int ,input().split())
ls = [0]*Q
for i in range(Q):
a,b,c,d = map(int, input().split())
ls[i] = (a,b,c,d)
def f(l,cnt):
if cnt>0:
j = l[-1]
ans = 0
for i in range(j,M+1):
ans = max(f(l+[i],cnt-1),ans)
return ans
else:
m = 0
for ... | import sys
sys.setrecursionlimit(10**8)
N,M,Q = map(int ,input().split())
ls = [0]*Q
for i in range(Q):
a,b,c,d = map(int, input().split())
ls[i] = (a,b,c,d)
def f(l,cnt):
if cnt>0:
j = l[-1]
ans = 0
for i in range(j,M+1):
ans = max(f(l+[i],cnt-1),ans)
return ans
else:
m = 0
for ... | [["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 21]] | 5 | 205 |
N, M, Q = list(map(int, input().split()))
abcd = [list(map(int, input().split())) for _ in range(Q)]
A_cand = []
max_score = 0
def gen(mae):
global A_cand
if len(mae)==N:
A_cand.append(mae)
return 0
for one in range(mae[-1], 11):
gen(mae+[one])
for i in range(1,M+1):
gen([i])
fo... | N, M, Q = list(map(int, input().split()))
abcd = [list(map(int, input().split())) for _ in range(Q)]
A_cand = []
max_score = 0
def gen(mae):
global A_cand
if len(mae)==N:
A_cand.append(mae)
return 0
for one in range(mae[-1], M+1):
gen(mae+[one])
for i in range(1,M+1):
gen([i])
f... | [["-", 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]] | 5 | 178 |
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define bit(n) 1 << n
using namespace std;
using cd = complex<double>;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
typedef map<int, int> mii;
const int Inf = 1000000007;... | #include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define bit(n) 1 << n
using namespace std;
using cd = complex<double>;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
typedef map<int, int> mii;
const int Inf = 1000000007;... | [["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]] | 1 | 346 |
#include <bits/stdc++.h>
using namespace std;
#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 all(a) (a).begin(), (a).end()
#define print(v) \
{ ... | #include <bits/stdc++.h>
using namespace std;
#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 all(a) (a).begin(), (a).end()
#define print(v) \
{ ... | [["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78], ["-", 0, 56, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 56, 39, 344, 3, 347, 0, 77, 39, 78], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]] | 1 | 551 |
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <vector>
// #include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).en... | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <vector>
// #include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).en... | [["-", 8, 9, 0, 1, 0, 11, 31, 69, 28, 22], ["+", 8, 9, 0, 1, 0, 11, 31, 69, 28, 22]] | 1 | 1,064 |
#include <bits/stdc++.h>
#define rep(l, r) for (int i = (l); i < (r); i++)
typedef long long ll;
using namespace std;
int n, m, q;
vector<int> a, b, c, d;
int dfs(vector<int> A, int new_n) {
A.push_back(new_n);
if (A.size() == m) {
int sum = 0;
rep(0, q) {
if (A[b[i]] - A[a[i]] == c[i]) {
... | #include <bits/stdc++.h>
#define rep(l, r) for (int i = (l); i < (r); i++)
typedef long long ll;
using namespace std;
int n, m, q;
vector<int> a, b, c, d;
int dfs(vector<int> A, int new_n) {
A.push_back(new_n);
if (A.size() == n) {
int sum = 0;
rep(0, q) {
if (A[b[i]] - A[a[i]] == c[i]) {
... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]] | 1 | 306 |
#include <algorithm>
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#incl... | #include <algorithm>
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#incl... | [["-", 64, 9, 0, 52, 15, 339, 51, 16, 12, 22], ["+", 64, 9, 0, 52, 15, 339, 51, 16, 12, 22]] | 1 | 498 |
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <... |
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]] | 1 | 417 |
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <vector>
using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constex... | #include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <vector>
using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constex... | [["-", 0, 2, 3, 4, 0, 2, 3, 4, 0, 13], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 13]] | 1 | 603 |
N, M, Q = [int(n) for n in 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] = [int(n) for n in input().split()]
def gen(i, n, m):
if n == 0:
yield []
return
for f in range(i, m - n + 2):
for rest in gen(f, n - 1, m):
... | N, M, Q = [int(n) for n in 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] = [int(n) for n in input().split()]
def gen(i, n, m):
if n == 0:
yield []
return
for f in range(i, m + 1):
for rest in gen(f, n - 1, m):
y... | [["-", 12, 652, 3, 4, 0, 657, 31, 657, 17, 33], ["-", 12, 652, 3, 4, 0, 657, 31, 657, 12, 22], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]] | 5 | 217 |
#!/usr/bin/env python3
import sys
def solve(N: int, M: int, Q: int, a: "List[int]", b: "List[int]", c: "List[int]", d: "List[int]"):
from itertools import combinations_with_replacement
answer = 0
for AA in combinations_with_replacement(range(0,M+1),r=N):
tmp_ans = 0
for q in range(Q):
... | #!/usr/bin/env python3
import sys
def solve(N: int, M: int, Q: int, a: "List[int]", b: "List[int]", c: "List[int]", d: "List[int]"):
from itertools import combinations_with_replacement
answer = 0
for AA in combinations_with_replacement(range(1,M+1),r=N):
tmp_ans = 0
for q in range... | [["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 612]] | 5 | 318 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T> using V = vector<T>;
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
const ll inf = (1e18);
const ll mod = 998244353;
// const ll mod=1000000007;
int GCD(ll a, ll b) { return b ? GCD(b... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T> using V = vector<T>;
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
const ll inf = (1e18);
const ll mod = 998244353;
// const ll mod=1000000007;
int GCD(ll a, ll b) { return b ? GCD(b... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]] | 1 | 470 |
import sys
sys.setrecursionlimit(10**5)
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,B,C,D=map(int,input().split())
a[i]=A;b[i]=B;c[i]=C;d[i]=D
r=[]
def dfs(i,depth,b,h):
if depth==0:
b.append(h)
return
for j in range(i,M):
nh=h[:]
... | import sys
sys.setrecursionlimit(10**5)
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,B,C,D=map(int,input().split())
a[i]=A;b[i]=B;c[i]=C;d[i]=D
r=[]
def dfs(i,depth,b,h):
if depth==0:
b.append(h)
return
for j in range(i,M+1):
nh=h[:]... | [["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]] | 5 | 255 |
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
struct Hoge {
int a, b, c, d;
};
template <typename F> constexpr decltype(auto) fix(F &&f) {
return [f = std::forward<F>(f)](auto &&...args) {
return f(f, std::forward<decltype(args)>(args)...);
};
}
int main() {
int n, m, q;
... | #include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
struct Hoge {
int a, b, c, d;
};
template <typename F> constexpr decltype(auto) fix(F &&f) {
return [f = std::forward<F>(f)](auto &&...args) {
return f(f, std::forward<decltype(args)>(args)...);
};
}
int main() {
int n, m, q;
... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]] | 1 | 339 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> piii;
#define pb push_back
#define NeedForSpeed ios_base::sync_with_stdio(0), cin.tie(0)
#define PI acos(-1)
#define all(c) c.begin(), c.end()
#define SET(x, y) memset((x), y, sizeof(x))
con... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> piii;
#define pb push_back
#define NeedForSpeed ios_base::sync_with_stdio(0), cin.tie(0)
#define PI acos(-1)
#define all(c) c.begin(), c.end()
#define SET(x, y) memset((x), y, sizeof(x))
con... | [["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]] | 1 | 447 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
ll n, m, q, ans = 0;
vector<vector<ll>> a;
void dfs(ll d, vector<ll> v) {
if (d == n) {
ll sum = 0;
rep(i, q) {
if (v[a[i][1] - 1] - v[a[i][0] - 1] == a[i][2])
... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
ll n, m, q, ans = 0;
vector<vector<ll>> a;
void dfs(ll d, vector<ll> v) {
if (d == n) {
ll sum = 0;
rep(i, q) {
if (v[a[i][1] - 1] - v[a[i][0] - 1] == a[i][2])
... | [["-", 8, 9, 0, 57, 64, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 12, 13]] | 1 | 278 |
/// __Macro's__
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define II pair<int, int>
#define III pair<int, II>
#define VI vector<int>
#define VII vector<II>
#define VIII vector<III>
#define VVI vector<vector<int>>
#define VVII vector<vector<II>>
#define fr first
#define sc second
#define mkpr ma... | /// __Macro's__
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define II pair<int, int>
#define III pair<int, II>
#define VI vector<int>
#define VII vector<II>
#define VIII vector<III>
#define VVI vector<vector<int>>
#define VVII vector<vector<II>>
#define fr first
#define sc second
#define mkpr ma... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]] | 1 | 1,206 |
//
// Created by watemus on 02.05.2020.
//
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ff first
#define ss second
using ll = long long;
using ld = long double;
#define int ll
constexpr ll INF... | //
// Created by watemus on 02.05.2020.
//
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ff first
#define ss second
using ll = long long;
using ld = long double;
#define int ll
constexpr ll INF... | [["-", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13]] | 1 | 366 |
#include "bits/stdc++.h"
using namespace std;
int N, M, Q;
long long ans = 0;
vector<int> a(M), b(M), c(M), d(M);
void dfs(vector<int> v, int depth, int lastNum) {
if (depth == N) {
// 数列が完成したらスコア計算
long long score = 0;
for (int i = 0; i < Q; i++) {
if (v[b[i] - 1] - v[a[i] - 1] == c[i])
s... | #include "bits/stdc++.h"
using namespace std;
int N, M, Q;
long long ans = 0;
vector<int> a(50), b(50), c(50), d(50);
void dfs(vector<int> v, int depth, int lastNum) {
if (depth == N) {
// 数列が完成したらスコア計算
long long score = 0;
for (int i = 0; i < Q; i++) {
if (v[b[i] - 1] - v[a[i] - 1] == c[i])
... | [["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 30, 0, 43, 49, 50, 51, 4, 0, 13]] | 1 | 255 |
a = input().split()
N = int(a[0])
M = int(a[1])
Q = int(a[2])
current = []
for i in range(Q):
e = input().split()
f = [int(i) for i in e]
current.append(f)
import itertools
c = list(itertools.combinations_with_replacement(range(1, M + 1), N))
value_list = []
for item in c:
value = 0
for k in curren... | a = input().split()
N = int(a[0])
M = int(a[1])
Q = int(a[2])
current = []
for i in range(Q):
e = input().split()
f = [int(i) for i in e]
current.append(f)
import itertools
c = list(itertools.combinations_with_replacement(range(1, M + 1), N))
value_list = []
for item in c:
value = 0
for k in curren... | [["+", 15, 666, 0, 657, 31, 206, 206, 657, 17, 33], ["+", 15, 666, 0, 657, 31, 206, 206, 657, 12, 612], ["+", 15, 666, 0, 657, 12, 206, 206, 657, 17, 33], ["+", 15, 666, 0, 657, 12, 206, 206, 657, 12, 612]] | 5 | 155 |
#include <bits/stdc++.h>
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF (1 << 29)
using namespace std;
struct Tuple {
int a, b, c, d;
};
vector<Tuple> T;
int n, m, q, ans = -INF;
int main() {
cin >> n >> m >> q;
... | #include <bits/stdc++.h>
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF (1 << 29)
using namespace std;
struct Tuple {
int a, b, c, d;
};
vector<Tuple> T;
int n, m, q, ans = -INF;
int main() {
cin >> n >> m >> q;
... | [["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]] | 1 | 308 |
#include <bits/stdc++.h>
using namespace std;
mt19937_64 llrand((int)chrono::steady_clock::now().time_since_epoch().count());
#define st first
#define nd second
#define pb push_back
#ifndef ONLINE_JUDGE
#define db(x) cerr << #x << " == " << x << endl
#define dbs(x) cerr << x << endl
#define _ << ", " <<
#else
#defin... | #include <bits/stdc++.h>
using namespace std;
mt19937_64 llrand((int)chrono::steady_clock::now().time_since_epoch().count());
#define st first
#define nd second
#define pb push_back
#ifndef ONLINE_JUDGE
#define db(x) cerr << #x << " == " << x << endl
#define dbs(x) cerr << x << endl
#define _ << ", " <<
#else
#defin... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]] | 1 | 374 |
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#inc... | #include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#inc... | [["-", 64, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 64, 9, 0, 7, 10, 43, 49, 50, 51, 13]] | 1 | 1,377 |
#include <bits/stdc++.h>
int popcount(int n) {
int res = 0;
int t = 0;
while ((1 << t) <= n) {
if ((1 << t) & n)
++res;
++t;
}
return res;
}
std::vector<int> a, b, c, d;
int N, M, Q;
int ans = -1;
void solve(std::vector<int> v) {
if (v.size() == N) {
int tans = 0;
for (int i = 0; i < Q... | #include <bits/stdc++.h>
int popcount(int n) {
int res = 0;
int t = 0;
while ((1 << t) <= n) {
if ((1 << t) & n)
++res;
++t;
}
return res;
}
std::vector<int> a, b, c, d;
int N, M, Q;
int ans = -1;
void solve(std::vector<int> v) {
if (v.size() == N) {
int tans = 0;
for (int i = 0; i < Q... | [["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]] | 1 | 349 |
/**
* Created by hiramekun at 20:53 on 2020-05-02.
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template <typename T> using pq = priority_queue<T>;
template <typename T> using minpq = priority_q... | /**
* Created by hiramekun at 20:53 on 2020-05-02.
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template <typename T> using pq = priority_queue<T>;
template <typename T> using minpq = priority_q... | [["-", 51, 218, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 51, 218, 8, 9, 0, 7, 15, 16, 12, 22]] | 1 | 632 |
import sys
input = sys.stdin.readline
import numpy as np
from itertools import combinations_with_replacement as CwR
n, m, q = map(int, input().split())
Lis = [[int(e) for e in input().split()] for _ in range(q)]
Tables = list(CwR(range(1,M+1),N))
Sum_cor = []
for Table in Tables:
d_sum = 0
for l in Lis:
... | import sys
input = sys.stdin.readline
import numpy as np
from itertools import combinations_with_replacement as CwR
n, m, q = map(int, input().split())
Lis = [[int(e) for e in input().split()] for _ in range(q)]
Tables = list(CwR(range(1,m+1),n))
Sum_cor = []
for Table in Tables:
d_sum = 0
for l in Lis:
... | [["-", 3, 4, 0, 652, 3, 4, 0, 657, 31, 22], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 31, 22], ["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 22]] | 5 | 144 |
#include <bits/stdc++.h>
#define rep(i, a, b) for (i = a; i < b; i++)
#define rep2(i, a, b) for (i = a; i >= b; i--)
#define mod 1000000007
#define mod2 998244353
#define FIO \
ios_base::sync_with_stdio(false); ... | #include <bits/stdc++.h>
#define rep(i, a, b) for (i = a; i < b; i++)
#define rep2(i, a, b) for (i = a; i >= b; i--)
#define mod 1000000007
#define mod2 998244353
#define FIO \
ios_base::sync_with_stdio(false); ... | [["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]] | 1 | 573 |
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stri... | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stri... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]] | 1 | 414 |
/*"Success isn't permanent, failure isn't fatal,
it's the courage to continue that counts"*/
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<in... | /*"Success isn't permanent, failure isn't fatal,
it's the courage to continue that counts"*/
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<in... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 362 |
def main():
N, M, Q = [int(x) for x in input().split()]
queries = [[int(x) for x in input().split()] for _ in range(Q)]
ans = float("-inf")
def dfs(A: list):
nonlocal ans
if len(A) == N:
s = sum(d for a, b, c, d in queries if A[b-1]-A[a-1] == c)
ans = max(ans,... |
def main():
N, M, Q = [int(x) for x in input().split()]
queries = [[int(x) for x in input().split()] for _ in range(Q)]
ans = float("-inf")
def dfs(A: list):
nonlocal ans
if len(A) == N:
s = sum(d for a, b, c, d in queries if A[b-1]-A[a-1] == c)
ans = max(ans,... | [["-", 8, 196, 0, 1, 0, 662, 12, 41, 0, 612], ["+", 8, 196, 0, 1, 0, 662, 12, 41, 0, 612]] | 5 | 180 |
N, M, Q = gets.split.map(&:to_i)
A, B, C, D = Q.times.map { gets.split.map(&:to_i) }.transpose
puts (0..M).to_a.repeated_combination(N).map { |arr| Q.times.map { |i| arr[B[i] - 1] - arr[A[i] - 1] == C[i] ? D[i] : 0 }.sum }.max | N, M, Q = gets.split.map(&:to_i)
A, B, C, D = Q.times.map { gets.split.map(&:to_i) }.transpose
puts (0...M).to_a.repeated_combination(N).map { |arr| Q.times.map { |i| arr[B[i] - 1] - arr[A[i] - 1] == C[i] ? D[i] : 0 }.sum }.max | [["-", 486, 652, 486, 652, 486, 739, 0, 475, 17, 757], ["+", 486, 652, 486, 652, 486, 739, 0, 475, 17, 389]] | 4 | 106 |
import sys
readline = sys.stdin.readline
from itertools import combinations_with_replacement
def main():
N, M, Q = map(int, readline().rstrip().split())
P = [tuple(map(int, readline().rstrip().split())) for _ in range(Q)]
ans = 0
for pair in combinations_with_replacement([i for i in range(1, M+1)],... | import sys
readline = sys.stdin.readline
from itertools import combinations_with_replacement
def main():
N, M, Q = map(int, readline().rstrip().split())
P = [tuple(map(int, readline().rstrip().split())) for _ in range(Q)]
ans = 0
for pair in combinations_with_replacement([i for i in range(1, M+1)],... | [["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 22]] | 5 | 152 |
# ABC165 C
import itertools
def main():
n, m, q = map(int, input().split())
List = []
for i in range(q):
a, b, c, d = map(int, input().split())
List.append([a, b, c, d])
max_total = 0
for A in list(itertools.combinations(range(1, m+1),n)):
total = 0
for abcd i... | # ABC165 C
import itertools
def main():
n, m, q = map(int, input().split())
List = []
for i in range(q):
a, b, c, d = map(int, input().split())
List.append([a, b, c, d])
max_total = 0
for A in list(itertools.combinations_with_replacement(range(1, m+1),n)):
total = 0
... | [["-", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22]] | 5 | 160 |
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()))
l = list(itertools.combinations_with_areplacement(range(1,M+1), N))
nax = 0
for x in l:
score = 0
for i in range(Q):
if int(x[b[i]-1]) - ... | 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()))
l = list(itertools.combinations_with_replacement(range(1,M+1), N))
nax = 0
for x in l:
score = 0
for i in range(Q):
if int(x[b[i]-1]) - i... | [["-", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22]] | 5 | 181 |
from itertools import combinations as c
n, m, q = map(int, input().split())
arr = []
for i in range(q):
l = [*map(int, input().split())]
arr.append(l)
res = 0
for g in c(list(range(1, m+1)), n):
f = 0
for h in arr:
if g[h[1]-1] - g[h[0]-1] == h[2]:
f += h[3]
res = max(r... | from itertools import combinations_with_replacement as c
n, m, q = map(int, input().split())
arr = []
for i in range(q):
l = [*map(int, input().split())]
arr.append(l)
res = 0
for g in c(list(range(1, m+1)), n):
f = 0
for h in arr:
if g[h[1]-1] - g[h[0]-1] == h[2]:
f += h[3]... | [["-", 0, 656, 0, 686, 141, 704, 141, 673, 0, 22], ["+", 0, 656, 0, 686, 141, 704, 141, 673, 0, 22]] | 5 | 134 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.