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 |
|---|---|---|---|---|
#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>;
int main() {
ll x, k, d;
cin >> x >> k >> d;
x = abs(x);
ll tmp = x % d;
if (x - tmp > k * d) {
ll ans = x - k * d;
cout << ans << endl;
return 0;
}
ll... | #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>;
int main() {
ll x, k, d;
cin >> x >> k >> d;
x = abs(x);
ll tmp = x % d;
if ((x - tmp) / d > k) {
ll ans = x - k * d;
cout << ans << endl;
return 0;
}
... | [["+", 15, 339, 51, 16, 31, 16, 31, 23, 0, 24], ["+", 15, 339, 51, 16, 31, 16, 31, 23, 0, 25], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 48], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]] | 1 | 144 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
x = abs(x);
if (x > k * d) {
cout << x - k * d << endl;
return 0;
}
long long ans = x % d;
k -= x / d;
k %= 2;
ans = abs(ans - d * k);
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long x, k, d;
cin >> x >> k >> d;
x = abs(x);
if (x / d >= k) {
cout << x - k * d << endl;
return 0;
}
long long ans = x % d;
k -= x / d;
k %= 2;
ans = abs(ans - d * k);
cout << ans << endl;
} | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 48], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]] | 1 | 93 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
constexpr ll mod = 1000000007;
constexpr int inf = 1000000000;
constexpr ll linf = 1000000000000000000;
int main() {
ll x, k, d;
cin >> x >> k >> d;
x = abs(x);
if (x / d >= k) {
cout << x - k ... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
constexpr ll mod = 1000000007;
constexpr int inf = 1000000000;
constexpr ll linf = 1000000000000000000;
int main() {
ll x, k, d;
cin >> x >> k >> d;
x = abs(x);
if (x / d >= k) {
cout << abs(x)... | [["+", 0, 16, 31, 16, 12, 16, 31, 2, 63, 22], ["+", 31, 16, 12, 16, 31, 2, 3, 4, 0, 24], ["+", 31, 16, 12, 16, 31, 2, 3, 4, 0, 25], ["+", 0, 9, 0, 43, 49, 50, 51, 16, 31, 22], ["+", 0, 9, 0, 43, 49, 50, 51, 16, 17, 33]] | 1 | 129 |
from sys import stdin
import math
import re
import queue
input = stdin.readline
MOD = 1000000007
INF = 122337203685477580
def solve():
x,k,d = map(int, input().split())
move = k*d
x = abs(x)
if x > k*d:
print(x -k*d)
else:
q = x//d
if abs(q - k)/2 == 0:
print(... | from sys import stdin
import math
import re
import queue
input = stdin.readline
MOD = 1000000007
INF = 122337203685477580
def solve():
x,k,d = map(int, input().split())
move = k*d
x = abs(x)
if x > k*d:
print(x -k*d)
else:
q = x//d
if abs(q - k)%2 == 0:
print(... | [["-", 8, 196, 0, 57, 15, 666, 0, 657, 17, 85], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 17, 109]] | 5 | 115 |
x, k, d = map(int, input().split())
a = x//d
k2 = k-a
if x-k*d > 0:
print(x-k*d)
exit()
if k2%2 == 0:
print(x%d)
else:
print(abs(x%d-d))
| x, k, d = map(int, input().split())
x = abs(x)
a = x//d
k2 = k-a
if x-k*d > 0:
print(x-k*d)
exit()
if k2%2 == 0:
print(x%d)
else:
print(abs(x%d-d))
| [["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 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, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]] | 5 | 74 |
#include <cmath>
#include <iostream>
using namespace std;
using ll = long long;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll X, K, D;
cin >> X >> K >> D;
X = abs(X);
if (X > K * D) {
cout << X - K * D << "\n";
} else {
ll i = X / D;
if ((K - i) % 2 == 0) {
cout << X - i * D... | #include <cmath>
#include <iostream>
using namespace std;
using ll = long long;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll X, K, D;
cin >> X >> K >> D;
X = abs(X);
if (X / D > K) {
cout << X - K * D << "\n";
} else {
ll i = X / D;
if ((K - i) % 2 == 0) {
cout << X - i * D... | [["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 48], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]] | 1 | 136 |
from sys import stdin
def main():
input = stdin.readline
X,K,D = map(int,input().split())
# 普通に絶対値に近づくだけ
sho = X // D
if sho >= K:
ans = abs(X - D * K)
elif (K - sho) % 2 == 0:
ans = abs(X % D)
else:
ans = abs(abs(X % D) - D)
print(ans)
if __name__ == "__mai... | from sys import stdin
def main():
input = stdin.readline
X,K,D = map(int,input().split())
X = abs(X)
sho = X // D
if sho >= K:
ans = abs(X - D * K)
elif (K - sho) % 2 == 0:
ans = abs(X % D)
else:
ans = abs(abs(X % D) - D)
print(ans)
if __name__ == "__main__... | [["+", 0, 14, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 14, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 8, 196, 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, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]] | 5 | 101 |
#include <bits/stdc++.h>
#include <queue>
#include <set>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repsl(i, s, n) for (ll i =... | #include <bits/stdc++.h>
#include <queue>
#include <set>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repsl(i, s, n) for (ll i =... | [["-", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 108], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["-", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]] | 1 | 168 |
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>,
// rb_tree_tag, tree_order_statist... | #include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>,
// rb_tree_tag, tree_order_statist... | [["-", 0, 11, 12, 16, 12, 23, 0, 16, 31, 22], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 31, 22]] | 1 | 250 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ll x, k, d, a;
cin >> x >> k >> d;
a = (ll)ceil((double)x / d);
if (x == 0) {
k %= 2;
x += k * d;
cout << abs(x);
return 0;
}
if (a > k)
a = k;
if (x < 0)
x += a * d;
else if (x > 0)
x -= a * d;
... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ll x, k, d, a;
cin >> x >> k >> d;
a = (ll)ceil((double)abs(x) / d);
if (x == 0) {
k %= 2;
x += k * d;
cout << abs(x);
return 0;
}
if (a > k)
a = k;
if (x < 0)
x += a * d;
else if (x > 0)
x -= a *... | [["+", 3, 4, 0, 16, 31, 74, 51, 2, 63, 22], ["+", 0, 16, 31, 74, 51, 2, 3, 4, 0, 24], ["+", 0, 16, 31, 74, 51, 2, 3, 4, 0, 25]] | 1 | 149 |
def abs(a):
if a<0:
return -a
return a
x,k,d=map(int,input().split())
if x==0:
if k%2==0:
print(d)
else:
print(0)
if x>0:
if k*d<=x:
print(x-k*d)
exit(0)
r=x%d
steps=(x-r)//d
l=abs(r-d)
if((k-steps)%2==0):
print(r)
else:
print(l)
if x<0:
if k*d<=abs(x):
print(abs(x+k*d))
exit(0)
l=abs(x)%... | def abs(a):
if a<0:
return -a
return a
x,k,d=map(int,input().split())
if x==0:
if k%2==1:
print(d)
else:
print(0)
if x>0:
if k*d<=x:
print(x-k*d)
exit(0)
r=x%d
steps=(x-r)//d
l=abs(r-d)
if((k-steps)%2==0):
print(r)
else:
print(l)
if x<0:
if k*d<=abs(x):
print(abs(x+k*d))
exit(0)
l=abs(x)%... | [["-", 0, 57, 64, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 57, 64, 196, 0, 57, 15, 666, 0, 612]] | 5 | 205 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ios_base::sync_with_stdio(NULL);
cin.tie(NULL);
cout.tie(NULL);
ll x, k, d;
while (cin >> x >> k >> d) {
ll req = x / d;
ll res = 1e18;
if (req <= k) {
ll y = abs(x) - (req * d);
ll baki = (k - req) % 2;
... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ios_base::sync_with_stdio(NULL);
cin.tie(NULL);
cout.tie(NULL);
ll x, k, d;
while (cin >> x >> k >> d) {
ll req = abs(x) / d;
ll res = 1e18;
if (req <= k) {
ll y = abs(x) - (req * d);
ll baki = (k - req) %... | [["+", 0, 43, 49, 50, 51, 16, 31, 2, 63, 22], ["+", 49, 50, 51, 16, 31, 2, 3, 4, 0, 24], ["+", 49, 50, 51, 16, 31, 2, 3, 4, 0, 25]] | 1 | 272 |
x,k,d=(int(i) for i in input().split())
c=(abs(x)//d)
if(x<0):
x+=(min(k,c)*d)
else:
x-=(min(k,c)*d)
k=max(0,k-c)
if(k%2==1 and x<0):
print(abs(x+d))
elif(k%2==1 and x>0):
print(abs(x-d))
elif(k%2==1 and x==0):
print(x+d)
else:
print(x) | x,k,d=(int(i) for i in input().split())
c=(abs(x)//d)
if(x<0):
x+=(min(k,c)*d)
else:
x-=(min(k,c)*d)
k=max(0,k-c)
if(k%2==1 and x<0):
print(abs(x+d))
elif(k%2==1 and x>0):
print(abs(x-d))
elif(k%2==1 and x==0):
print(x+d)
else:
print(abs(x)) | [["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]] | 5 | 144 |
X, K, D = map(int, input().split())
ans = 0
if K*D < X:
ans = X - K*D
else:
a1 = X//D
a2 = X%D
K -= a1
# 往復する
if K%2 == 0:
ans= a2
else:
ans = abs(a2-D)
print(ans)
# 1000000000000000 1000000000000000 1000000000000000 | X, K, D = map(int, input().split())
ans = 0
if K*D < abs(X):
ans = abs(X) - K*D
else:
a1 = X//D
a2 = X%D
K -= a1
# 往復する
if K%2 == 0:
ans= a2
else:
ans = abs(a2-D)
print(ans)
# 1000000000000000 1000000000000000 1000000000000000 | [["+", 0, 656, 0, 57, 15, 666, 0, 652, 63, 22], ["+", 0, 57, 15, 666, 0, 652, 3, 4, 0, 24], ["+", 0, 57, 15, 666, 0, 652, 3, 4, 0, 25], ["+", 0, 1, 0, 662, 12, 657, 31, 652, 63, 22], ["+", 0, 662, 12, 657, 31, 652, 3, 4, 0, 24], ["+", 0, 662, 12, 657, 31, 652, 3, 4, 0, 25]] | 5 | 76 |
x,k,d=map(int,input().split())
x=abs(x)
if x>k*d:
ans=x-k*d
else:
n=x//d
if n%2==0:
ans=x-n*d
else:
ans=abs(x-(n+1)*d)
print(ans) | x,k,d=map(int,input().split())
x=abs(x)
if x>k*d:
ans=x-k*d
else:
n=x//d
if (k-n)%2==0:
ans=x-n*d
else:
ans=abs(x-(n+1)*d)
print(ans) | [["+", 0, 57, 15, 666, 0, 657, 31, 23, 0, 24], ["+", 15, 666, 0, 657, 31, 23, 0, 657, 31, 22], ["+", 15, 666, 0, 657, 31, 23, 0, 657, 17, 33], ["+", 0, 57, 15, 666, 0, 657, 31, 23, 0, 25]] | 5 | 79 |
X, K, D = map(int, input().split())
def solve():
if X > K*D:
return X - K*D
elif -1*X > K*D:
return K*D - X
elif X >= 0:
first = X // D
rem = K - first
if rem % 2 == 0:
return X % D
else:
return D - (X % D)
else: # X < 0
fi... | X, K, D = map(int, input().split())
def solve():
if X > K*D:
return X - K*D
elif -1*X > K*D:
return -X - K*D
elif X >= 0:
first = X // D
rem = K - first
if rem % 2 == 0:
return X % D
else:
return D - (X % D)
else: # X < 0
f... | [["+", 64, 196, 0, 37, 0, 657, 31, 664, 17, 33], ["+", 64, 196, 0, 37, 0, 657, 31, 664, 28, 22], ["+", 75, 665, 64, 196, 0, 37, 0, 657, 17, 33], ["-", 75, 665, 64, 196, 0, 37, 0, 657, 17, 33], ["-", 75, 665, 64, 196, 0, 37, 0, 657, 12, 22]] | 5 | 141 |
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RREP(i, n) for (int i = (int)(n); i >= 0; --i)
#define RFOR(i, a, b) for (int i = (int)(a); i >= (int)(b); --i)
#define ALL(a) (a).be... | #include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RREP(i, n) for (int i = (int)(n); i >= 0; --i)
#define RFOR(i, a, b) for (int i = (int)(a); i >= (int)(b); --i)
#define ALL(a) (a).be... | [["-", 0, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 31, 22]] | 1 | 436 |
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i, n, N) for (int i = n; i <= N; ++i)
#define asd(i, n, N) for (int i = n; i < N; ++i)
#define rap(i, n, N) for (int i = n; i >= N; --i)
#define... | #include <bits/stdc++.h>
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i, n, N) for (int i = n; i <= N; ++i)
#define asd(i, n, N) for (int i = n; i < N; ++i)
#define rap(i, n, N) for (int i = n; i >= N; --i)
#define... | [["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 48], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]] | 1 | 351 |
#include "bits/stdc++.h"
using namespace std;
typedef long long li;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
li x, k, d;
cin >> x >> k >> d;
x = abs(x);
li ans = x;
li mreq = x / d;
if (k < mreq) {
ans = min(ans, x - d * k);
} else {
li rem = k - mreq;
if (rem % 2 == 0) {
... | #include "bits/stdc++.h"
using namespace std;
typedef long long li;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
li x, k, d;
cin >> x >> k >> d;
x = abs(x);
li ans = 1LL << 62;
li mreq = x / d;
if (k < mreq) {
ans = min(ans, x - d * k);
} else {
li rem = k - mreq;
if (rem % 2 ... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 31, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 151], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13]] | 1 | 153 |
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template<typename key, typename val>
// using ordered_tree =
// tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std... | #include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template<typename key, typename val>
// using ordered_tree =
// tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std... | [["+", 0, 1, 0, 16, 31, 16, 12, 2, 63, 22], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 24], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 25]] | 1 | 250 |
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template <typename T> usin... | //#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template <typename T> usin... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["-", 0, 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, 109], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]] | 1 | 651 |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second
using... |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second
using... | [["-", 64, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 31, 22]] | 1 | 592 |
#include <stdio.h>
int main() {
long long int a, b, c;
scanf("%lld%lld%lld", &a, &b, &c);
if (a < 0)
a *= -1;
long long int d = a / c;
if (b <= d)
printf("%lld", a - b * c);
else {
long long int s1 = a % c;
long long int s2 = a - s1;
if ((b - d) % 2 == 0)
printf("%lld", s1);
... | #include <stdio.h>
int main() {
long long int a, b, c;
scanf("%lld%lld%lld", &a, &b, &c);
if (a < 0)
a *= -1;
long long int d = a / c;
if (b <= d)
printf("%lld", a - b * c);
else {
long long int s1 = a % c;
long long int s2 = c - s1;
if ((b - d) % 2 == 0)
printf("%lld", s1);
... | [["-", 0, 9, 0, 43, 49, 50, 51, 16, 31, 22], ["+", 0, 9, 0, 43, 49, 50, 51, 16, 31, 22]] | 1 | 123 |
X, K, D = map(int, input().split())
k = X // D
rt = X - k * D
lt = abs(rt - D)
if k > K:
print(X - K * D)
elif k % 2 == K % 2:
print(rt)
else:
print(lt) | X, K, D = map(int, input().split())
X = abs(X)
k = X // D
rt = X - k * D
lt = abs(rt - D)
if k > K:
print(X - K * D)
elif k % 2 == K % 2:
print(rt)
else:
print(lt) | [["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 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, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]] | 5 | 70 |
x, k, d = map(int, input().split())
x = abs(x)
ans = 0
if x >= k * d:
ans = x - k * d
else:
step = x // d
x -= d * step
k -= step
if step % 2 == 0:
ans = abs(x)
else:
ans = abs(x - d)
print(ans)
| x, k, d = map(int, input().split())
x = abs(x)
ans = 0
if x >= k * d:
ans = x - k * d
else:
step = x // d
x -= d * step
k -= step
if k % 2 == 0:
ans = abs(x)
else:
ans = abs(x - d)
print(ans)
| [["-", 8, 196, 0, 57, 15, 666, 0, 657, 31, 22], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 31, 22]] | 5 | 83 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll x, k, d, ans;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> x >> k >> d;
if (x < 0)
x = -x;
ll a = x / d;
if (k > a) {
if (a % 2 == 0) {
ans = x - a * d;
} else {
ans = abs(x - (a + 1) * d);
... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll x, k, d, ans;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> x >> k >> d;
if (x < 0)
x = -x;
ll a = x / d;
if (k > a) {
if ((k - a) % 2 == 0) {
ans = x - a * d;
} else {
ans = abs(x - (a + 1) *... | [["+", 15, 339, 51, 16, 31, 16, 31, 23, 0, 24], ["+", 51, 16, 31, 16, 31, 23, 0, 16, 31, 22], ["+", 51, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 15, 339, 51, 16, 31, 16, 31, 23, 0, 25]] | 1 | 126 |
def solve(x, k, d):
n, m = divmod(x, d)
if n >= k:
return x - k * d
if n % 2 == k % 2:
return m
return abs(m - d)
x, k, d = map(int, input().split())
print(solve(x, k, d))
| def solve(x, k, d):
x = abs(x)
n, m = divmod(x, d)
if n >= k:
return x - k * d
if n % 2 == k % 2:
return m
return abs(m - d)
x, k, d = map(int, input().split())
print(solve(x, k, d))
| [["+", 0, 14, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 14, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 8, 196, 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, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]] | 5 | 78 |
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <map>
#include <set>
#include <vector>
using namespace std;
namespace my {
//-----------------------------------------------------------------------------
inline char cn() {
static char buf[1000010], *p1 = buf, *p2 = buf;
return p1... | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <map>
#include <set>
#include <vector>
using namespace std;
namespace my {
//-----------------------------------------------------------------------------
inline char cn() {
static char buf[1000010], *p1 = buf, *p2 = buf;
return p1... | [["-", 8, 9, 0, 57, 64, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 1, 0, 11, 12, 91, 17, 33], ["+", 0, 57, 64, 1, 0, 11, 12, 91, 28, 22]] | 1 | 1,115 |
#include <bits/stdc++.h>
using namespace std;
#define int long long
// #define double long double
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x... | #include <bits/stdc++.h>
using namespace std;
#define int long long
// #define double long double
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 48], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]] | 1 | 964 |
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2")
// 293206GT
#include <algorithm>
#include <algorithm>
#include <bitset>
#include <chrono>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <stri... | //#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2")
// 293206GT
#include <algorithm>
#include <algorithm>
#include <bitset>
#include <chrono>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <stri... | [["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 48], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]] | 1 | 567 |
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#incl... | #include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#incl... | [["-", 15, 339, 51, 16, 31, 16, 31, 23, 0, 24], ["-", 31, 16, 31, 23, 0, 16, 31, 16, 17, 72], ["-", 31, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["-", 51, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["-", 51, 16, 31, 16, 31, 23, 0, 16, 12, 13], ["-", 15, 339, 51, 16, 31, 16, 31, 23, 0, 25]] | 1 | 179 |
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
long long X, K, D;
cin >> X >> K >> D;
long long t = abs(X) / D;
if (t >= K) {
if (X < 0)
X += K * D;
else
X -= K * D;
cout << X << endl;
return 0;
}
if (X < 0)
X += t * D;
else
X ... | #include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
long long X, K, D;
cin >> X >> K >> D;
long long t = abs(X) / D;
if (t >= K) {
if (X < 0)
X += K * D;
else
X -= K * D;
cout << abs(X) << endl;
return 0;
}
if (X < 0)
X += t * D;
else
... | [["+", 0, 1, 0, 16, 31, 16, 12, 2, 63, 22], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 24], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 25]] | 1 | 145 |
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int>> RHEAP;
const int N = 100010, M = 1010;
int... | #include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int>> RHEAP;
const int N = 100010, M = 1010;
int... | [["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 109], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]] | 1 | 305 |
#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>;
int main() {
int n, k;
cin >> n >> k;
vector<int> p(n), c(n);
rep(i, n) cin >> p[i];
rep(i, n) cin >> c[i];
rep(i, n) p[i]--;
ll ans = -1e18;
rep(si, n) {
in... | #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>;
int main() {
int n, k;
cin >> n >> k;
vector<int> p(n), c(n);
rep(i, n) cin >> p[i];
rep(i, n) cin >> c[i];
rep(i, n) p[i]--;
ll ans = -1e18;
rep(si, n) {
in... | [["+", 64, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 17, 48]] | 1 | 257 |
N,K=map(int,input().split())
P=list(map(int,input().split()))
P=list(map(lambda x:x-1,P))
C=list(map(int,input().split()))
ans=-float("inf")
for i in range(N):
st=i
tmp=0
for j in range(K):
st=P[st]
tmp+=C[st]
ans=max(ans,tmp)
if i==st:
break
s,v=divmod(K,j+1)
if s>1 and... | N,K=map(int,input().split())
P=list(map(int,input().split()))
P=list(map(lambda x:x-1,P))
C=list(map(int,input().split()))
ans=-float("inf")
for i in range(N):
st=i
tmp=0
for j in range(K):
st=P[st]
tmp+=C[st]
ans=max(ans,tmp)
if i==st:
break
s,v=divmod(K,j+1)
if s>1 and... | [["+", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 64, 196, 0, 1, 0, 662, 12, 657, 31, 22], ["+", 64, 196, 0, 1, 0, 662, 12, 657, 17, 72], ["+", 64, 196, 0, 1, 0, 662, 12, 657, 12, 612]] | 5 | 190 |
#include <bits/stdc++.h>
using namespace std;
const int N = 2000 + 5;
struct Node {
int x, y;
} up[N << 4];
int a[N * 3], n, m, ans, MAX;
int f[N][N], p[N], S[N], L[N][N];
int b[4];
inline int read() {
int tot = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
f = -1;
c = g... | #include <bits/stdc++.h>
using namespace std;
const int N = 2000 + 5;
struct Node {
int x, y;
} up[N << 4];
int a[N * 3], n, m, ans, MAX;
int f[N][N], p[N], S[N], L[N][N];
int b[4];
inline int read() {
int tot = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
f = -1;
c = g... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]] | 1 | 1,211 |
// Original Code:
//#include <self/utility>
//#include <self/debug>
// using namespace std;
// int n;
// int a[2000*3+5];
// int dp1[2005][2005];//Õý³£µÄ´øÁ½¸ö
// int dp2[2005];//´øxµÄ×î´óÖµ
// int dp3;//È«²¿µÄ×î´óÖµ
// int k;
// int r[3];
// int tn;
//
// struct Info
//{
// int x;
// int y;
// int v;
// Info(int _x,in... | // Original Code:
//#include <self/utility>
//#include <self/debug>
// using namespace std;
// int n;
// int a[2000*3+5];
// int dp1[2005][2005];//Õý³£µÄ´øÁ½¸ö
// int dp2[2005];//´øxµÄ×î´óÖµ
// int dp3;//È«²¿µÄ×î´óÖµ
// int k;
// int r[3];
// int tn;
//
// struct Info
//{
// int x;
// int y;
// int v;
// Info(int _x,in... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22]] | 1 | 2,150 |
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
const int N = 2005;
const int INF = 123456789;
int n, tmx = -INF, ans;
int a[N * 3];
vector<pair<pii, int>> vtr;
int dp[N][N], mx[N];
inline void chmax(int &x, int y) { x = max(x, y); }
inline void update(int x, int y, int t) {
// printf("up... | #include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
const int N = 2005;
const int INF = 123456789;
int n, tmx = -INF, ans;
int a[N * 3];
vector<pair<pii, int>> vtr;
int dp[N][N], mx[N];
inline void chmax(int &x, int y) { x = max(x, y); }
inline void update(int x, int y, int t) {
// printf("up... | [["-", 49, 50, 51, 69, 341, 342, 0, 16, 12, 13], ["+", 49, 50, 51, 69, 341, 342, 0, 16, 12, 13]] | 1 | 693 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int n, a[6005], dp[2005][2005], rmx[2005], mx;
int todo[100005][3], tsz;
void add_todo(int x, int y, int... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int n, a[6005], dp[2005][2005], rmx[2005], mx;
int todo[100005][3], tsz;
void add_todo(int x, int y, int... | [["+", 0, 1, 0, 2, 3, 4, 0, 69, 28, 22], ["+", 0, 2, 3, 4, 0, 69, 341, 342, 0, 70], ["+", 0, 2, 3, 4, 0, 69, 341, 342, 0, 73]] | 1 | 629 |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 5;
int a[N * 3], f[N][N], ma[N], t, mx;
struct Node {
int x, y, z;
} op[N << 2];
int main() {
int n, n1, ans1 = 0;
scanf("%d", &n), n1 = 3 * n - 1;
for (int i = 0; i <= n1; i++)
scanf("%d", a + i);
memset(f, 0x8f, sizeof(f)), memset(ma, 0x8... | #include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 5;
int a[N * 3], f[N][N], ma[N], t, mx;
struct Node {
int x, y, z;
} op[N << 2];
int main() {
int n, n1, ans1 = 0;
scanf("%d", &n), n1 = 3 * n - 1;
for (int i = 0; i <= n1; i++)
scanf("%d", a + i);
memset(f, 0x8f, sizeof(f)), memset(ma, 0x8... | [["+", 0, 7, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 27, 17, 29], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]] | 1 | 792 |
#define DIN freopen("input.txt", "r", stdin);
#define DOUT freopen("output.txt", "w", stdout);
#include <bits/stdc++.h>
#include <cstdio>
#define mem(a, b) memset(a, b, sizeof(a))
#define REP(i, a, b) for (int i = (a); i <= (int)(b); i++)
#define REP_(i, a, b) for (int i = (a); i >= (b); i--)
#define pb push_back
using... | #define DIN freopen("input.txt", "r", stdin);
#define DOUT freopen("output.txt", "w", stdout);
#include <bits/stdc++.h>
#include <cstdio>
#define mem(a, b) memset(a, b, sizeof(a))
#define REP(i, a, b) for (int i = (a); i <= (int)(b); i++)
#define REP_(i, a, b) for (int i = (a); i >= (b); i--)
#define pb push_back
using... | [["-", 0, 7, 8, 9, 0, 57, 75, 76, 0, 95], ["-", 0, 57, 75, 76, 0, 57, 75, 76, 0, 95]] | 1 | 1,013 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repn(i, n) for (int i = 1; i <= n; i++)
#define LL long long
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair
using namespace std;
const LL MOD = 1e9 + 7;
int n, a[6010], nxt[6010],... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repn(i, n) for (int i = 1; i <= n; i++)
#define LL long long
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair
using namespace std;
const LL MOD = 1e9 + 7;
int n, a[6010], nxt[6010],... | [["-", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 69, 28, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 69, 28, 22]] | 1 | 966 |
#include <cstdio>
#include <cstring>
#include <tuple>
#include <vector>
using namespace std;
const int Maxn = 2000;
int n;
int a[Maxn * 3 + 5];
int dp[Maxn + 5][Maxn + 5];
int row_max[Maxn + 5];
int zero, all_max;
vector<tuple<int, int, int>> vis;
void update(int i, int j, int k) {
vis.emplace_back(i, j, k);
vis.em... | #include <cstdio>
#include <cstring>
#include <tuple>
#include <vector>
using namespace std;
const int Maxn = 2000;
int n;
int a[Maxn * 3 + 5];
int dp[Maxn + 5][Maxn + 5];
int row_max[Maxn + 5];
int zero, all_max;
vector<tuple<int, int, int>> vis;
void update(int i, int j, int k) {
vis.emplace_back(i, j, k);
vis.em... | [["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]] | 1 | 532 |
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MAXN = 2010;
int A[3 * MAXN];
int acum = 0;
int dp[MAXN][MAXN];
struct dpp {
int x, y, v;
};
int may[MAXN];
int mayg;
bool mk[MAXN][MAXN];
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
for (int i = 0; i < MAXN... | #include <bits/stdc++.h>
#define int long long
using namespace std;
const int MAXN = 2010;
int A[3 * MAXN];
int acum = 0;
int dp[MAXN][MAXN];
struct dpp {
int x, y, v;
};
int may[MAXN];
int mayg;
bool mk[MAXN][MAXN];
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
for (int i = 0; i < MAXN... | [["+", 0, 11, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 12, 22], ["-", 0, 11, 12, 16, 31, 2, 3, 4, 0, 25], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 25]] | 1 | 1,263 |
#include <bits/stdc++.h>
using namespace std;
int n, a[10000], dp[2010][2010], margin = 1e8, allmax = 1e8, rowmax[2010];
void chmax(int &a, int b) { a = max(a, b); }
main() {
cin >> n;
for (int i = 0; i < 3 * n; ++i)
cin >> a[i];
dp[a[0]][a[1]] = rowmax[a[0]] = rowmax[a[1]] = margin;
vector<tuple<int, int, ... | #include <bits/stdc++.h>
using namespace std;
int n, a[10000], dp[2010][2010], margin = 1e8, allmax = 1e8, rowmax[2010];
void chmax(int &a, int b) { a = max(a, b); }
main() {
cin >> n;
for (int i = 0; i < 3 * n; ++i)
cin >> a[i];
dp[a[0]][a[1]] = rowmax[a[0]] = rowmax[a[1]] = margin;
vector<tuple<int, int, ... | [["+", 3, 4, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 3, 4, 0, 2, 3, 4, 0, 16, 12, 13]] | 1 | 453 |
#include <bits/stdc++.h>
using namespace std;
/*
提出前に確認!
- setとmultisetを間違えない
*/
/*
n <= 5000なので必ず5000ステップ以内にループができる
ある場所から始めた時に、5000回やってどこかでループが出てくる
ループが出てきた時に、1ループで収支がプラスなら最大のループ数-1回ループをして、二回回って最大を見れば良さそう
5000 * 5000 * 3? = 7.5 * 10^7だから多分いける
piが全て異なるということから一個の輪になる
このことから1ループはciの総和
*/
int main(void) {
int n, k;... | #include <bits/stdc++.h>
using namespace std;
/*
提出前に確認!
- setとmultisetを間違えない
*/
/*
n <= 5000なので必ず5000ステップ以内にループができる
ある場所から始めた時に、5000回やってどこかでループが出てくる
ループが出てきた時に、1ループで収支がプラスなら最大のループ数-1回ループをして、二回回って最大を見れば良さそう
5000 * 5000 * 3? = 7.5 * 10^7だから多分いける
piが全て異なるということから一個の輪になる
このことから1ループはciの総和
*/
int main(void) {
int n, k;... | [["+", 8, 9, 0, 43, 49, 50, 51, 69, 28, 22], ["+", 0, 43, 49, 50, 51, 69, 341, 342, 0, 70], ["+", 0, 43, 49, 50, 51, 69, 341, 342, 0, 73]] | 1 | 293 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define all(c) begin(c), end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template <typename T1, typename T2> bool chmax(T1 &a, T2 b) {
if (a < b) {
a = b;
return true;
} else
return false;
}
... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define all(c) begin(c), end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template <typename T1, typename T2> bool chmax(T1 &a, T2 b) {
if (a < b) {
a = b;
return true;
} else
return false;
}
... | [["-", 64, 9, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 12, 22]] | 1 | 423 |
#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;
#ifdef LOCAL
#define debug(...) \
fprintf(stderr, __VA_ARGS__); ... | #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;
#ifdef LOCAL
#define debug(...) \
fprintf(stderr, __VA_ARGS__); ... | [["+", 75, 76, 0, 9, 0, 57, 64, 9, 0, 46], ["-", 75, 76, 0, 9, 0, 57, 64, 9, 0, 46]] | 1 | 512 |
#include <bits/stdc++.h>
using namespace std;
long long N, K, P[5005], C[5005];
vector<long long> scores[5005];
bool visited[5005];
int start = 0;
void dfs(int src) {
if (visited[src])
return;
visited[src] = true;
if (scores[start].empty())
scores[start].push_back(C[P[src]]);
else
scores[start]... | #include <bits/stdc++.h>
using namespace std;
long long N, K, P[5005], C[5005];
vector<long long> scores[5005];
bool visited[5005];
int start = 0;
void dfs(int src) {
if (visited[src])
return;
visited[src] = true;
if (scores[start].empty())
scores[start].push_back(C[P[src]]);
else
scores[start]... | [["-", 64, 9, 0, 7, 15, 16, 12, 16, 31, 22], ["-", 64, 9, 0, 7, 15, 16, 12, 16, 17, 109]] | 1 | 564 |
n, k = map(int, input().split())
pp = list(map(int, input().split()))
p = [pp[i]-1 for i in range(n)]
c = list(map(int, input().split()))
ans = -(10**9+1)
for i in range(n):
s = 0
x = i
for j in range(k):
x = p[x]
s += c[x]
ans = max(ans,s)
if i == x:
break
a = int(k/(j+1))
m = k%(j+1)
... | n, k = map(int, input().split())
pp = list(map(int, input().split()))
p = [pp[i]-1 for i in range(n)]
c = list(map(int, input().split()))
ans = -(10**9+1)
for i in range(n):
s = 0
x = i
for j in range(k):
x = p[x]
s += c[x]
ans = max(ans,s)
if i == x:
break
a = int(k/(j+1))
m = k%(j+1)
... | [["-", 64, 196, 0, 1, 0, 662, 12, 657, 31, 22], ["+", 64, 196, 0, 1, 0, 662, 12, 657, 31, 22]] | 5 | 206 |
N, K = map(int, input().split())
Ps = list(map(int, input().split()))
Ps = [i - 1 for i in Ps]
Cs = list(map(int, input().split()))
max_score = -float("inf")
for i in range(N):
scores = []
idx = i # starting index
while True:
idx = Ps[idx] # point to the next index
scores.append(Cs[idx]... | N, K = map(int, input().split())
Ps = list(map(int, input().split()))
Ps = [i - 1 for i in Ps]
Cs = list(map(int, input().split()))
max_score = -float("inf")
for i in range(N):
scores = []
idx = i # starting index
while True:
idx = Ps[idx] # point to the next index
scores.append(Cs[idx])... | [["+", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 64, 196, 0, 1, 0, 662, 12, 657, 31, 22], ["+", 64, 196, 0, 1, 0, 662, 12, 657, 17, 48], ["+", 64, 196, 0, 1, 0, 662, 12, 657, 12, 612]] | 5 | 245 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
namespace IO {
#define gc getchar()
template <typename T> inline void read(T &x) {
x = 0;
bool f = 1;
char ch;
for (ch = g... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
namespace IO {
#define gc getchar()
template <typename T> inline void read(T &x) {
x = 0;
bool f = 1;
char ch;
for (ch = g... | [["-", 3, 4, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 3, 4, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 3, 4, 0, 16, 12, 16, 12, 23, 0, 24], ["+", 12, 16, 12, 23, 0, 16, 12, 23, 0, 25]] | 1 | 549 |
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi... | #include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]] | 1 | 1,136 |
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
using Int = int64_t;
using P = pair<Int, Int>;
const Int INF... | #include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
using Int = int64_t;
using P = pair<Int, Int>;
const Int INF... | [["+", 64, 9, 0, 43, 49, 50, 51, 16, 17, 72], ["+", 64, 9, 0, 43, 49, 50, 51, 16, 12, 22], ["+", 49, 50, 51, 16, 12, 23, 0, 16, 17, 33], ["+", 49, 50, 51, 16, 12, 23, 0, 16, 12, 13]] | 1 | 695 |
#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable : 4244) // 最悪をします
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include... | #define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable : 4244) // 最悪をします
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include... | [["-", 0, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 0, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 0, 43, 49, 50, 51, 16, 12, 16, 17, 48], ["+", 0, 43, 49, 50, 51, 16, 12, 16, 12, 22]] | 1 | 11,314 |
N, K = map(int, input().split())
P = [int(i) - 1 for i in input().split()]
Q = [int(i) for i in input().split()]
ans = - float('inf')
for i in range(N):
now = i
cnt = 0
span = 0
while True:
span += 1
cnt += Q[now]
now = P[now]
if now == i:
break
po... | N, K = map(int, input().split())
P = [int(i) - 1 for i in input().split()]
Q = [int(i) for i in input().split()]
ans = - float('inf')
for i in range(N):
now = i
cnt = 0
span = 0
while True:
span += 1
cnt += Q[now]
now = P[now]
if now == i:
break
point = 0
... | [["+", 0, 657, 12, 23, 0, 657, 31, 23, 0, 24], ["+", 12, 657, 12, 23, 0, 657, 12, 23, 0, 25]] | 5 | 172 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define RFOR(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define ITR(x, c) for (__typeof(c.begin()) x = c.begin(); x != c.end(); x++)
#define RITR(x, c) for (__typeof(c.... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define RFOR(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define ITR(x, c) for (__typeof(c.begin()) x = c.begin(); x != c.end(); x++)
#define RITR(x, c) for (__typeof(c.... | [["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]] | 1 | 599 |
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i ... | #include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i ... | [["-", 0, 1, 0, 11, 12, 69, 28, 69, 28, 22], ["+", 0, 11, 12, 118, 28, 69, 28, 69, 28, 22], ["+", 64, 9, 0, 1, 0, 11, 12, 118, 17, 131], ["+", 64, 9, 0, 1, 0, 11, 12, 118, 119, 120]] | 1 | 874 |
N, K = map(int, input().split())
P = [x-1 for x in map(int, input().split())]
C = list(map(int, input().split()))
ans = -100_000_000_000
for i in range(N):
n = 0
socre_sum = 0
now = i
while True:
n += 1
socre_sum += C[now]
now = P[now]
if i == now:
break
... | N, K = map(int, input().split())
P = [x-1 for x in map(int, input().split())]
C = list(map(int, input().split()))
ans = -100_000_000_000
for i in range(N):
n = 0
socre_sum = 0
now = i
while True:
n += 1
socre_sum += C[now]
now = P[now]
if i == now:
break
... | [["+", 12, 657, 12, 23, 0, 657, 31, 23, 0, 24], ["+", 3, 4, 0, 657, 12, 657, 12, 23, 0, 25]] | 5 | 163 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#de... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#de... | [["+", 49, 50, 51, 16, 12, 16, 31, 2, 63, 22], ["+", 51, 16, 12, 16, 31, 2, 3, 4, 0, 24], ["+", 51, 16, 12, 16, 31, 2, 3, 4, 0, 13], ["+", 51, 16, 12, 16, 31, 2, 3, 4, 0, 21], ["+", 51, 16, 12, 16, 31, 2, 3, 4, 0, 25]] | 1 | 355 |
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iosfwd>
#... | #include <algorithm>
#include <assert.h>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iosfwd>
#... | [["+", 0, 11, 12, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 17, 72]] | 1 | 1,062 |
n, k = map(int, input().split())
P = [int(x)-1 for x in input().split()]
C = [int(x) for x in input().split()]
vis = [0 for i in range(n+1)]
res = -10000000000000000000000
for i in range(0,n):
if vis[i] == 0:
su = 0
vis[i] = 1
v = []
v.append(C[i])
su += C[i]
x = P[i]
while x != i:
vis[x] = 1
s... | n, k = map(int, input().split())
P = [int(x)-1 for x in input().split()]
C = [int(x) for x in input().split()]
vis = [0 for i in range(n+1)]
res = -10000000000000000000000
for i in range(0,n):
if vis[i] == 0:
su = 0
vis[i] = 1
v = []
v.append(C[i])
su += C[i]
x = P[i]
while x != i:
vis[x] = 1
s... | [["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 22]] | 5 | 276 |
N, K = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))
for i in range(len(p)):
p[i] -= 1
ans = float("-inf")
for i in range(N):
#iはスタートポジション
pos = i
#移動先のマスにかかれたポイント
point = []
total = 0
while True:
pos = p[pos]
point.appe... | N, K = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))
for i in range(len(p)):
p[i] -= 1
ans = float("-inf")
for i in range(N):
#iはスタートポジション
pos = i
#移動先のマスにかかれたポイント
point = []
total = 0
while True:
pos = p[pos]
point.appe... | [["+", 64, 196, 0, 1, 0, 677, 12, 23, 0, 24], ["+", 0, 677, 12, 23, 0, 657, 12, 23, 0, 24], ["+", 0, 677, 12, 23, 0, 657, 12, 23, 0, 25], ["+", 64, 196, 0, 1, 0, 677, 12, 23, 0, 25]] | 5 | 195 |
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin()... | #include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin()... | [["-", 8, 9, 0, 43, 49, 53, 54, 55, 0, 24], ["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["-", 8, 9, 0, 43, 49, 53, 54, 55, 0, 25]] | 1 | 818 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define REP(i, n) for (ll i = 1; i <= (n); i++)
typedef long long ll;
int main() {
ll n, k;
cin >> n >> k;
vector<ll> p(n + 1), c(n + 1);
REP(i, n) cin >> p[i];
REP(i, n) cin >> c[i];
ll ans = -10000000000;
REP(i... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define REP(i, n) for (ll i = 1; i <= (n); i++)
typedef long long ll;
int main() {
ll n, k;
cin >> n >> k;
vector<ll> p(n + 1), c(n + 1);
REP(i, n) cin >> p[i];
REP(i, n) cin >> c[i];
ll ans = -10000000000;
REP(i... | [["+", 0, 1, 0, 11, 12, 23, 0, 16, 17, 33], ["+", 0, 1, 0, 11, 12, 23, 0, 16, 12, 13], ["+", 0, 2, 3, 4, 0, 16, 31, 16, 12, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72]] | 1 | 225 |
#include <bits/stdc++.h>
using namespace std;
#define INPUT freopen("input.txt", "r", stdin);
#define ll long long
#define ld long double
#define len(s) s.size()
#define fl(st, en, in) for (int i = st; i < en; i += in)
#define rfl(st, en, de) for (int i = st; i < en; i -= de)
#define fll fl(0, n, 1)
#define cy cou... | #include <bits/stdc++.h>
using namespace std;
#define INPUT freopen("input.txt", "r", stdin);
#define ll long long
#define ld long double
#define len(s) s.size()
#define fl(st, en, in) for (int i = st; i < en; i += in)
#define rfl(st, en, de) for (int i = st; i < en; i -= de)
#define fll fl(0, n, 1)
#define cy cou... | [["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]] | 1 | 516 |
#include "list"
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
using ull = unsi... | #include "list"
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
using ull = unsi... | [["+", 49, 50, 51, 4, 0, 16, 31, 16, 31, 13], ["+", 49, 50, 51, 4, 0, 16, 31, 16, 17, 48]] | 1 | 1,702 |
#include <iostream>
#include <limits.h>
#include <queue>
#include <vector>
using namespace std;
int main(void) {
int N;
long long K;
cin >> N >> K;
vector<int> P(N + 1); // move
for (int i = 1; i < N + 1; i++) {
cin >> P[i];
}
vector<long long> C(N + 1); // point
for (int i = 1; i < N + 1; i++) {... | #include <iostream>
#include <limits.h>
#include <queue>
#include <vector>
using namespace std;
int main(void) {
int N;
long long K;
cin >> N >> K;
vector<int> P(N + 1); // move
for (int i = 1; i < N + 1; i++) {
cin >> P[i];
}
vector<long long> C(N + 1); // point
for (int i = 1; i < N + 1; i++) {... | [["-", 64, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 64, 9, 0, 7, 10, 43, 49, 50, 51, 13]] | 1 | 342 |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T> // *s.find_by_order(0), s.order_of_key(2) ;
using ordered_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;... | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T> // *s.find_by_order(0), s.order_of_key(2) ;
using ordered_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;... | [["-", 8, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 8, 1, 0, 2, 3, 4, 0, 16, 17, 72]] | 1 | 537 |
#include <bits/stdc++.h>
#define MOD (long long)(1e9 + 7)
using namespace std;
long long n, k, vis[5005];
long long p[5005], c[5005], sum[5005], ans = -1e18;
int main() {
cin >> n >> k;
for (int i = 1; i <= n; i++)
cin >> p[i];
for (int i = 1; i <= n; i++)
cin >> c[i];
for (int i = 1; i <= n; i++) {
... | #include <bits/stdc++.h>
#define MOD (long long)(1e9 + 7)
using namespace std;
long long n, k, vis[5005];
long long p[5005], c[5005], sum[5005], ans = -1e18;
int main() {
cin >> n >> k;
for (int i = 1; i <= n; i++)
cin >> p[i];
for (int i = 1; i <= n; i++)
cin >> c[i];
for (int i = 1; i <= n; i++) {
... | [["-", 0, 7, 26, 11, 12, 69, 341, 342, 0, 22], ["+", 0, 7, 26, 11, 12, 69, 341, 342, 0, 22]] | 1 | 241 |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int a[5005];
ll p[5005];
bool vis[5005];
int tot = 0;
vector<int> vec[5005];
map<int, ll> mp;
int main() {
int n, k;
cin >> n >> k;
for (int i = 1; i <= n; i++)
cin >> a[i];
for (int i = 1; i <= n; i++)
cin >> p[i];
for (int i = 1; i <... | #include <bits/stdc++.h>
#define ll long long
using namespace std;
int a[5005];
ll p[5005];
bool vis[5005];
int tot = 0;
vector<int> vec[5005];
map<int, ll> mp;
int main() {
int n, k;
cin >> n >> k;
for (int i = 1; i <= n; i++)
cin >> a[i];
for (int i = 1; i <= n; i++)
cin >> p[i];
for (int i = 1; i <... | [["+", 12, 16, 12, 23, 0, 16, 31, 23, 0, 24], ["+", 0, 16, 12, 74, 51, 2, 3, 4, 0, 25]] | 1 | 362 |
#include <algorithm>
#include <iostream>
using namespace std;
using ll = long long;
int main() {
int n, k;
cin >> n >> k;
int *p = new int[n];
for (int i = 0; i < n; i++) {
cin >> p[i];
p[i]--;
}
ll *c = new ll[n];
for (int i = 0; i < n; i++) {
cin >> c[i];
}
ll scoa = -1e9;
int *arri... | #include <algorithm>
#include <iostream>
using namespace std;
using ll = long long;
int main() {
int n, k;
cin >> n >> k;
int *p = new int[n];
for (int i = 0; i < n; i++) {
cin >> p[i];
p[i]--;
}
ll *c = new ll[n];
for (int i = 0; i < n; i++) {
cin >> c[i];
}
ll scoa = -1e9;
int *arri... | [["-", 0, 11, 12, 2, 3, 4, 0, 74, 0, 24], ["-", 12, 2, 3, 4, 0, 74, 39, 77, 39, 78], ["-", 0, 11, 12, 2, 3, 4, 0, 74, 0, 25], ["-", 0, 11, 12, 2, 3, 4, 0, 74, 51, 13], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22]] | 1 | 521 |
#include <stdio.h>
typedef long long int ll;
int main() {
int n, k;
int p[5000], c[5000];
scanf("%d %d", &n, &k);
for (int i = 0; i < n; i++)
scanf("%d", &p[i]);
for (int i = 0; i < n; i++)
scanf("%d", &c[i]);
for (int i = 0; i < n; i++)
p[i]--; // 0-indexed
ll ans = -1e10;... | #include <stdio.h>
typedef long long int ll;
int main() {
int n, k;
int p[5000], c[5000];
scanf("%d %d", &n, &k);
for (int i = 0; i < n; i++)
scanf("%d", &p[i]);
for (int i = 0; i < n; i++)
scanf("%d", &c[i]);
for (int i = 0; i < n; i++)
p[i]--; // 0-indexed
ll ans = -1e10;... | [["-", 8, 9, 0, 1, 0, 11, 12, 69, 28, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 69, 28, 22]] | 0 | 302 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
int n, k;
cin >> n >> k;
int p[n], c[n];
rep(i, n) cin >> p[i], --p[i];
rep(i, n) cin >> c[i];
ll ans = 0;
rep(i, n) {
int v = i;
ll lo... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
int n, k;
cin >> n >> k;
int p[n], c[n];
rep(i, n) cin >> p[i], --p[i];
rep(i, n) cin >> c[i];
ll ans = -1e18;
rep(i, n) {
int v = i;
l... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 243 |
// ABC175DW.cpp
//#include "pch.h"
#include <algorithm> // max
#include <iostream>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
int main() {
ll n, k;
cin >> n >> k;
vector<ll> p(n);
rep(i, n) {
cin >> p.at(i);
p.at(i)--;
}
... | // ABC175DW.cpp
//#include "pch.h"
#include <algorithm> // max
#include <iostream>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
int main() {
ll n, k;
cin >> n >> k;
vector<ll> p(n);
rep(i, n) {
cin >> p.at(i);
p.at(i)--;
}
... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 417 |
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
int n, k;
int p[6000];
int c[6000];
cin >> n >> k;
rep(i, n) cin >> p[i];
rep(i, n) p[i]--;
rep(i, n) cin >> c[i];
ll ans = (ll)-1e18;
for (i... | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
int n, k;
int p[6000];
int c[6000];
cin >> n >> k;
rep(i, n) cin >> p[i];
rep(i, n) p[i]--;
rep(i, n) cin >> c[i];
ll ans = (ll)-1e18;
for (i... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["+", 12, 23, 0, 16, 12, 2, 3, 4, 0, 25]] | 1 | 266 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll n, k;
cin >> n >> k;
ll p[n], c[n];
for (int i = 0; i < n; ++i) {
cin >> p[i];
p[i]--;
}
for (int i = 0; i < n; ++i) {
cin >> c[i];
}
ll ans = 0;
for (int st = 0; st < n; ++st) {
int running = p[st];
... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll n, k;
cin >> n >> k;
ll p[n], c[n];
for (int i = 0; i < n; ++i) {
cin >> p[i];
p[i]--;
}
for (int i = 0; i < n; ++i) {
cin >> c[i];
}
ll ans = -1e18;
for (int st = 0; st < n; ++st) {
int running = p[s... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 240 |
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, combinations, chain, product
from functools import lru_cache
from collections import deque, defaultdict
from operator import itemgetter
from pprint import ppr... | import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, combinations, chain, product
from functools import lru_cache
from collections import deque, defaultdict
from operator import itemgetter
from pprint import ppr... | [["-", 0, 57, 75, 665, 15, 666, 0, 657, 12, 612], ["+", 0, 57, 75, 665, 15, 666, 0, 657, 12, 612], ["+", 64, 196, 0, 1, 0, 677, 12, 657, 17, 72], ["+", 64, 196, 0, 1, 0, 677, 12, 657, 12, 612]] | 5 | 729 |
/*
Krishnakant Tiwari
Problem Link:
*/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _cin \
ios_base::sync_wit... | /*
Krishnakant Tiwari
Problem Link:
*/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _cin \
ios_base::sync_wit... | [["+", 49, 50, 51, 16, 12, 16, 31, 2, 63, 22], ["+", 51, 16, 12, 16, 31, 2, 3, 4, 0, 24], ["+", 51, 16, 12, 16, 31, 2, 3, 4, 0, 13], ["+", 51, 16, 12, 16, 31, 2, 3, 4, 0, 21], ["+", 51, 16, 12, 16, 31, 2, 3, 4, 0, 25]] | 1 | 575 |
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int p[5010];
ll c[5010], ans = -1e18;
int main() {
ios_base::sync_with_stdio(0);
int n, k;
cin >> n >> k;
for (int i = 0; i < n; i++) {
cin >> p[i];
p... | #include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int p[5010];
ll c[5010], ans = -1e18;
int main() {
ios_base::sync_with_stdio(0);
int n, k;
cin >> n >> k;
for (int i = 0; i < n; i++) {
cin >> p[i];
p... | [["+", 31, 16, 12, 23, 0, 16, 31, 23, 0, 24], ["+", 0, 16, 12, 74, 51, 2, 3, 4, 0, 25]] | 1 | 267 |
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(), a.end()
using ll = long long;
const int INF = 1 << 30;
const ll INFll = 1LL << 62;
const int mod = int(1e9) + 7;
using P = pair<ll, ll>;
using ld = long double;
int main() {
ll n, k;
cin >> n >> k;
vector<ll> p(n);
vector<ll> c(n);
for ... | #include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(), a.end()
using ll = long long;
const int INF = 1 << 30;
const ll INFll = 1LL << 62;
const int mod = int(1e9) + 7;
using P = pair<ll, ll>;
using ld = long double;
int main() {
ll n, k;
cin >> n >> k;
vector<ll> p(n);
vector<ll> c(n);
for ... | [["-", 0, 338, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 338, 8, 9, 0, 7, 15, 16, 17, 18]] | 1 | 490 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int n, k;
scanf("%d%d", &n, &k);
vector<int> p(n, 0), l(n, 0);
vector<ll> c(n, 0), s(n, 0);
for (int i = 0; i < n; ++i) {
scanf("%d", &p[i]);
p[i]--;
}
for (int i = 0; i < n; ++i) {
scanf("%lld", &c[i]);
}
f... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int n, k;
scanf("%d%d", &n, &k);
vector<int> p(n, 0), l(n, 0);
vector<ll> c(n, 0), s(n, 0);
for (int i = 0; i < n; ++i) {
scanf("%d", &p[i]);
p[i]--;
}
for (int i = 0; i < n; ++i) {
scanf("%lld", &c[i]);
}
f... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 1 | 501 |
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predic... | // #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predic... | [["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98]] | 1 | 965 |
import sys
import resource
sys.setrecursionlimit(10000)
n,k=map(int,input().rstrip().split())
p=list(map(int,input().rstrip().split()))
c=list(map(int,input().rstrip().split()))
def find(start,now,up,max,sum,count,flag):
if start==now:
flag+=1
if start==now and flag==2:
return [max,sum,count]
... | import sys
import resource
sys.setrecursionlimit(10000)
n,k=map(int,input().rstrip().split())
p=list(map(int,input().rstrip().split()))
c=list(map(int,input().rstrip().split()))
def find(start,now,up,max,sum,count,flag):
if start==now:
flag+=1
if start==now and flag==2:
return [max,sum,count]
... | [["+", 75, 665, 64, 196, 0, 1, 0, 662, 31, 22], ["+", 75, 665, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 64, 196, 0, 1, 0, 662, 12, 206, 51, 22], ["+", 64, 196, 0, 1, 0, 662, 12, 206, 0, 70], ["+", 64, 196, 0, 1, 0, 662, 12, 206, 206, 612], ["+", 64, 196, 0, 1, 0, 662, 12, 206, 0, 73]] | 5 | 504 |
// c++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <climits>
#include <complex>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#in... | // c++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <climits>
#include <complex>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#in... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 3, 4, 0, 2, 3, 4, 0, 16, 31, 13], ["-", 3, 4, 0, 2, 3, 4, 0, 16, 17, 48]] | 1 | 965 |
#include <bits/stdc++.h>
#define fname "D"
#define bug(x) cerr << (#x) << " = " << (x) << endl
#define ll long long
#define REP0(i, n) for (int i = 0, _n = (n); i < _n; ++i)
#define REP1(i, n) for (int i = 1, _n = (n); i <= _n; ++i)
#define REPB0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPB1(i, n) for (int i = (... | #include <bits/stdc++.h>
#define fname "D"
#define bug(x) cerr << (#x) << " = " << (x) << endl
#define ll long long
#define REP0(i, n) for (int i = 0, _n = (n); i < _n; ++i)
#define REP1(i, n) for (int i = 1, _n = (n); i <= _n; ++i)
#define REPB0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPB1(i, n) for (int i = (... | [["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 106], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 98], ["+", 12, 16, 31, 16, 31, 16, 31, 23, 0, 24], ["-", 31, 16, 31, 16, 31, 16, 12, 23, 0, 24]] | 1 | 759 |
#include <iostream>
#include <vector>
using namespace std;
int N;
long long K;
vector<int> P;
vector<long long> C;
int main() {
cin >> N;
cin >> K;
P = vector<int>(N + 1);
C = vector<long long>(N + 1);
auto f = vector<bool>(N + 1, true);
for (int i = 1; i <= N; i++) {
cin >> P[i];
}
for (int i = ... | #include <iostream>
#include <vector>
using namespace std;
int N;
long long K;
vector<int> P;
vector<long long> C;
int main() {
cin >> N;
cin >> K;
P = vector<int>(N + 1);
C = vector<long long>(N + 1);
auto f = vector<bool>(N + 1, true);
for (int i = 1; i <= N; i++) {
cin >> P[i];
}
for (int i = ... | [["-", 0, 57, 64, 9, 0, 1, 0, 27, 17, 68], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 110], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22]] | 1 | 410 |
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> p... | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> p... | [["-", 8, 9, 0, 338, 8, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 338, 8, 9, 0, 43, 39, 78], ["-", 12, 2, 3, 4, 0, 16, 31, 69, 28, 22], ["+", 12, 2, 3, 4, 0, 16, 31, 69, 28, 22], ["-", 12, 2, 3, 4, 0, 16, 12, 69, 28, 22], ["+", 12, 2, 3, 4, 0, 16, 12, 69, 28, 22]] | 1 | 1,008 |
/**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,a... | /**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,a... | [["+", 8, 9, 0, 43, 49, 50, 49, 352, 0, 67], ["-", 64, 9, 0, 43, 49, 50, 51, 16, 12, 22], ["+", 64, 9, 0, 43, 49, 50, 51, 16, 12, 22]] | 1 | 2,051 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
int main() {
ll n, k;
cin >> n >> k;
ll a[n + 1];
ll c[n + 1];
for (ll i = 1; i <= n; i++)
cin >> a[i];
for (ll i = 1; i <= n; i++)
cin >> c[i];
ll ans = -inf;
for (ll i = 1; i <= n; i++) {
vector<ll> v;
... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
int main() {
ll n, k;
cin >> n >> k;
ll a[n + 1];
ll c[n + 1];
for (ll i = 1; i <= n; i++)
cin >> a[i];
for (ll i = 1; i <= n; i++)
cin >> c[i];
ll ans = -inf;
for (ll i = 1; i <= n; i++) {
vector<ll> v;
... | [["+", 0, 16, 12, 23, 0, 16, 31, 23, 0, 24], ["+", 51, 16, 12, 23, 0, 16, 12, 23, 0, 25]] | 1 | 257 |
// Problem: D - Moving Piece
// Contest: AtCoder - AtCoder Beginner Contest 175
// URL: https://atcoder.jp/contests/abc175/tasks/abc175_d
// Memory Limit: 1024 MB
// Time Limit: 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#... |
// Problem: D - Moving Piece
// Contest: AtCoder - AtCoder Beginner Contest 175
// URL: https://atcoder.jp/contests/abc175/tasks/abc175_d
// Memory Limit: 1024 MB
// Time Limit: 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#... | [["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22]] | 1 | 471 |
N, K = list(map(int, input().split()))
P = list(map(lambda x: int(x) - 1, input().split()))
C = list(map(int, input().split()))
ans = -10**9-1
for i in range(N):
cumsum = [0]*(N+1)
seen = [-1]*N
K_ = K
now = i
j = 0
while K_ > 0 and seen[now] == -1:
seen[now] = 1
now = P[now]
... | N, K = list(map(int, input().split()))
P = list(map(lambda x: int(x) - 1, input().split()))
C = list(map(int, input().split()))
ans = -10**9-1
for i in range(N):
cumsum = [0]*(N+1)
seen = [-1]*N
K_ = K
now = i
j = 0
while K_ > 0 and seen[now] == -1:
seen[now] = 1
now = P[now]
... | [["+", 0, 206, 206, 663, 0, 657, 31, 657, 17, 109], ["+", 0, 206, 206, 663, 0, 657, 31, 657, 12, 22]] | 5 | 268 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 11007;
ll n, k, p[N], c[N], sum[N];
int vis[N];
vector<ll> g[N];
deque<int> q;
ll hello[N];
ll work(int x, int cnt) {
while (q.size())
q.pop_front();
for (int i = 1; i <= x; i++) {
while (!q.empty() && sum[q.back()] >= s... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 11007;
ll n, k, p[N], c[N], sum[N];
int vis[N];
vector<ll> g[N];
deque<int> q;
ll hello[N];
ll work(int x, int cnt) {
while (q.size())
q.pop_front();
for (int i = 1; i <= x; i++) {
while (!q.empty() && sum[q.back()] >= s... | [["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 64, 9, 0, 1, 0, 11, 12, 69, 28, 22], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 70], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 31, 22], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 73]] | 1 | 719 |
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#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;
template <typename T>
using ordered_set =
tree<T, null... |
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#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;
template <typename T>
using ordered_set =
tree<T, null... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 91, 17, 33], ["+", 8, 9, 0, 43, 49, 50, 51, 91, 28, 22], ["-", 0, 7, 8, 9, 0, 43, 49, 50, 51, 13]] | 1 | 750 |
N, K = map(int, input().split())
p_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))
max_score = 0
for i in range(N):
first = True
score = 0
step = 0
path = {}
cumulative_score = []
current_p = i
cycle_passed = False
while step < K:
# record current step
cumulative... | N, K = map(int, input().split())
p_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))
max_score = 0
first = True
for i in range(N):
score = 0
step = 0
path = {}
cumulative_score = []
current_p = i
cycle_passed = False
while step < K:
# record current step
cumulative_s... | [["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 146], ["-", 0, 7, 8, 196, 0, 1, 0, 662, 31, 22], ["-", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["-", 0, 7, 8, 196, 0, 1, 0, 662, 12, 146]] | 5 | 247 |
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = ... | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = ... | [["-", 0, 1, 0, 662, 12, 657, 31, 206, 206, 22], ["+", 0, 1, 0, 662, 12, 657, 31, 206, 206, 22]] | 5 | 524 |
#include "bits/stdc++.h"
using namespace std;
#ifdef LOCAL
#include "debug.h"
#define input \
freopen("input.txt", "r", stdin); \
freopen("output.txt", "w", stdout);
#else
#define debug(...) 4
#define input ... | #include "bits/stdc++.h"
using namespace std;
#ifdef LOCAL
#include "debug.h"
#define input \
freopen("input.txt", "r", stdin); \
freopen("output.txt", "w", stdout);
#else
#define debug(...) 4
#define input ... | [["+", 0, 9, 0, 7, 15, 16, 12, 16, 31, 22], ["+", 0, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 109], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 22]] | 1 | 367 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define rrep1(i, n) for (int i = (n); i > 0; i--)
#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>
#define MOD 10000000... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define rrep1(i, n) for (int i = (n); i > 0; i--)
#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>
#define MOD 10000000... | [["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]] | 1 | 282 |
N, K = [int(x) for x in input().split()]
P = [0] + [int(x) for x in input().split()]
C = [0] + [int(x) for x in input().split()]
max_score = max(C[1:])
for init in range(1, N + 1): # 初めの場所をinitとする
score = [0] # k回移動後のスコア
i = init
for k in range(1, K + 1):
i = P[i] # k回移動後に着くところ
score.ap... | N, K = [int(x) for x in input().split()]
P = [0] + [int(x) for x in input().split()]
C = [0] + [int(x) for x in input().split()]
max_score = max(C[1:])
for init in range(1, N + 1): # 初めの場所をinitとする
score = [0] # k回移動後のスコア
i = init
for k in range(1, K + 1):
i = P[i] # k回移動後に着くところ
score.ap... | [["+", 12, 657, 12, 23, 0, 657, 31, 23, 0, 24], ["+", 3, 668, 8, 657, 12, 657, 12, 23, 0, 25]] | 5 | 219 |
#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>;
int main() {
int n, k;
cin >> n >> k;
vector<int> c(n), p(n);
rep(i, n) cin >> p.at(i);
rep(i, n) cin >> c.at(i);
rep(i, n) p.at(i)--;
ll ans = -1e18;
rep(start,... | #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>;
int main() {
int n, k;
cin >> n >> k;
vector<int> c(n), p(n);
rep(i, n) cin >> p.at(i);
rep(i, n) cin >> c.at(i);
rep(i, n) p.at(i)--;
ll ans = -1e18;
rep(start,... | [["+", 0, 2, 3, 4, 0, 2, 63, 118, 28, 22], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 17, 131], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 25]] | 1 | 268 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.