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 "algorithm"
#include "iostream"
#include "map"
#include "queue"
#include "set"
#include "string"
#include "unordered_map"
#include "unordered_set"
#include "vector"
using namespace std;
#define ll long long
#define INF 2e9
#define INF2 4611686018427387904
//#define MOD 1000000007
#define MOD 998244353
#defin... | #include "algorithm"
#include "iostream"
#include "map"
#include "queue"
#include "set"
#include "string"
#include "unordered_map"
#include "unordered_set"
#include "vector"
using namespace std;
#define ll long long
#define INF 2e9
#define INF2 4611686018427387904
//#define MOD 1000000007
#define MOD 998244353
#defin... | [["+", 64, 9, 0, 1, 0, 16, 12, 16, 17, 72], ["+", 64, 9, 0, 1, 0, 16, 12, 16, 12, 13]] | 1 | 1,443 |
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll, ll>
#define ppp pair<ll, pp>
#define... | #pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll, ll>
#define ppp pair<ll, pp>
#define... | [["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 355], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 17, 47], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 12, 13]] | 1 | 512 |
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
int a[200000], visited[200000];
ll dfs(int x, int y) {
ll res = 0LL;
while (a[x] != y) ... | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
int a[200000], visited[200000];
ll dfs(int x, int y) {
ll res = 0LL;
while (a[x] != y) ... | [["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 238 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define enld '\n'
#define rep(i, n) for (int i = 0; i < (n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
co... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define enld '\n'
#define rep(i, n) for (int i = 0; i < (n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
co... | [["+", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13]] | 1 | 402 |
import java.util.Scanner;
public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
long K = sc.nextLong();
int A[] = new int[N];
for (int i = 0; i < N; i++) {
A[i] = sc.nextInt();
}
if (A[0... | import java.util.Scanner;
public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
long K = sc.nextLong();
int A[] = new int[N];
for (int i = 0; i < N; i++) {
A[i] = sc.nextInt();
}
if (A[0... | [["+", 0, 57, 64, 196, 0, 1, 0, 27, 0, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 27, 0, 68], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35]] | 3 | 247 |
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#define mkp make_pair
#define mkt make_tuple
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const l... | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#define mkp make_pair
#define mkt make_tuple
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const l... | [["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 310 |
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> pi;
typedef vector<int> vi;
const int MAXN = 205;
const int MOD = 1000000007;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define DEC(i, a, b) for (int i = (a); i >= (b); i--)
#define pb push_back
#define mp make_pair... | #include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> pi;
typedef vector<int> vi;
const int MAXN = 200005;
const int MOD = 1000000007;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define DEC(i, a, b) for (int i = (a); i >= (b); i--)
#define pb push_back
#define mp make_p... | [["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]] | 1 | 327 |
// For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456
// a.cpp -o a.exe in cmd
#include <bits/stdc++.h>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vvi v... | // For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456
// a.cpp -o a.exe in cmd
#include <bits/stdc++.h>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vvi v... | [["-", 31, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]] | 1 | 329 |
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 200010
using namespace std;
vector<ll>... | #include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 200010
using namespace std;
vector<ll>... | [["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 72], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13]] | 1 | 208 |
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
A = list(map(lambda x: int(x)-1, input().split()))
cities = [0]
c = 0
used = [False] * N
used[0] = True
while not used[A[c]]:
used[A[c]] = True
cities.append(A[c])
c = A[c]
x = cities.index(A[c])
if K < x:
print(cities[K])
else:
... | import sys
input = sys.stdin.readline
N, K = map(int, input().split())
A = list(map(lambda x: int(x)-1, input().split()))
cities = [0]
c = 0
used = [False] * N
used[0] = True
while not used[A[c]]:
used[A[c]] = True
cities.append(A[c])
c = A[c]
x = cities.index(A[c])
if K < x:
print(cities[K] + 1)
else:... | [["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]] | 5 | 152 |
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
int to[200200][68];
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
ll n, k;
cin >> n >> k;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
to[0][i + 1] = a... | #include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
int to[68][200200];
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
ll n, k;
cin >> n >> k;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
to[0][i + 1] = a... | [["-", 0, 30, 0, 43, 49, 80, 49, 80, 81, 13], ["+", 0, 30, 0, 43, 49, 80, 49, 80, 81, 13], ["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13]] | 1 | 213 |
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
constexpr lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
#define rep(i, n) for (int i = 0; i < i... | #include <bits/stdc++.h>
using namespace std;
using lint = long long;
constexpr lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
#define rep(i, n) for (int i = 0; i < i... | [["+", 8, 9, 0, 9, 0, 1, 0, 11, 31, 22], ["+", 8, 9, 0, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 14, 8, 9, 0, 9, 0, 1, 0, 35]] | 1 | 1,194 |
#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;
LL n, k, a[200010], val;
v... | #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;
LL n, k, a[200010], val;
v... | [["-", 0, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 31, 22], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 278 |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define endl '\n'
using namespace std;
struct custom_hash {
static unsigned long long splitmix64(unsigned long long x) {
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31... | #include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define endl '\n'
using namespace std;
struct custom_hash {
static unsigned long long splitmix64(unsigned long long x) {
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31... | [["-", 0, 57, 75, 76, 0, 9, 0, 43, 39, 40], ["+", 75, 76, 0, 9, 0, 43, 39, 86, 0, 96]] | 1 | 364 |
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
Scanner stdIn = new Scanner(System.in);
int N = stdIn.nextInt();
long K = stdIn.nextLong();
int A[] = new int[N];
int key[] = new int[N * 5];
boolean visit[] = new boolean[N];
int s = 0,... | import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
Scanner stdIn = new Scanner(System.in);
int N = stdIn.nextInt();
long K = stdIn.nextLong();
int A[] = new int[N];
int key[] = new int[N * 5];
boolean visit[] = new boolean[N];
int s = 0,... | [["+", 0, 1, 0, 492, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 492, 3, 4, 0, 16, 12, 499]] | 3 | 317 |
#include <bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set \
tree<pair<in... | #include <bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set \
tree<pair<in... | [["-", 0, 43, 49, 50, 51, 69, 341, 342, 0, 22], ["+", 0, 43, 49, 50, 51, 69, 341, 342, 0, 22]] | 1 | 391 |
#include <bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair<int, int>
#define iiii pair<int, pii>
#define mp make_pair
#define INF 1000000000
#define rep(i, x) for (int(i) = 0; (i) < (x); (i)++)
inline int getint() {
int x = 0, p = 1;
char c = getchar();
while (... | #include <bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair<int, int>
#define iiii pair<int, pii>
#define mp make_pair
#define INF 1000000000
#define rep(i, x) for (int(i) = 0; (i) < (x); (i)++)
inline int getint() {
int x = 0, p = 1;
char c = getchar();
while (... | [["+", 0, 91, 28, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 91, 28, 2, 3, 4, 0, 16, 12, 13]] | 1 | 354 |
/*
NO
TIME
TO
DIE
--007
*/
#include <bits/stdc++.h>
#include <complex>
#include <ext/pb_ds/assoc_container.hpp>
//#include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace ... | /*
NO
TIME
TO
DIE
--007
*/
#include <bits/stdc++.h>
#include <complex>
#include <ext/pb_ds/assoc_container.hpp>
//#include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace ... | [["+", 64, 9, 0, 1, 0, 11, 12, 69, 28, 22], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 70], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 73]] | 1 | 769 |
from collections import deque
def main():
def int_0(num):
return int(num) - 1
N, K = map(int, input().split())
A = tuple(map(int_0, input().split()))
# dfs
INF = 10 ** 18
visited = [False] * N
dist = [INF] * N
info = {}
def dfs(s):
stack = deque()
stac... | from collections import deque
def main():
def int_0(num):
return int(num) - 1
N, K = map(int, input().split())
A = tuple(map(int_0, input().split()))
# dfs
INF = 10 ** 18
visited = [False] * N
dist = [INF] * N
info = {}
def dfs(s):
stack = deque()
stac... | [["+", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 281 |
// Problem : D - Teleporter
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
... |
// Problem : D - Teleporter
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
... | [["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 33], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["-", 3, 4, 0, 69, 341, 342, 0, 16, 17, 33], ["-", 3, 4, 0, 69, 341, 342, 0, 16, 12, 13]] | 1 | 1,104 |
#include <bits/stdc++.h>
#define speed \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0)
// # pragma GCC optimize "-O3"
#define... | #include <bits/stdc++.h>
#define speed \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0)
// # pragma GCC optimize "-O3"
#define... | [["-", 0, 30, 0, 43, 49, 50, 51, 16, 31, 13], ["+", 0, 43, 49, 50, 51, 16, 31, 16, 31, 13], ["+", 0, 43, 49, 50, 51, 16, 31, 16, 17, 48], ["+", 0, 43, 49, 50, 51, 16, 31, 16, 12, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["-", 0, 16, 12, 69, 341, 342, 0, 16, 17, 33],... | 1 | 256 |
// Hey u r far away to know this
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define pb push_back
#define ss second
#define ll long long
#define MAX 5000
#define mpi map<int, int>
#define mpll map<ll, ll>
#define pll pair<ll, ll>
#define plld pair<ll, double>
#define SKILLER ... | // Hey u r far away to know this
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define pb push_back
#define ss second
#define ll long long
#define MAX 5000
#define mpi map<int, int>
#define mpll map<ll, ll>
#define pll pair<ll, ll>
#define plld pair<ll, double>
#define SKILLER ... | [["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22]] | 1 | 360 |
import sys
l = sys.stdin.readline().strip()
N, K = map(int, l.split())
l = sys.stdin.readline().strip()
A = [0] + list(map(int, l.split()))
visited = [-1] * (len(A)+1)
remain = K
crt = 1
entrance = -1
while remain > 0:
remain -= 1
# check visited
if visited[crt] == -1:
visited[crt] = K - remain
... | import sys
l = sys.stdin.readline().strip()
N, K = map(int, l.split())
l = sys.stdin.readline().strip()
A = [0] + list(map(int, l.split()))
visited = [-1] * (len(A)+1)
remain = K
crt = 1
entrance = -1
while remain > 0:
remain -= 1
# check visited
if visited[crt] == -1:
visited[crt] = K - remain
... | [["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 21], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 183 |
import sys
from _collections import deque
N,K = map(int,input().split())
A = list(map(int,input().split()))
for i in range(len(A)):
A[i] = A[i]-1
used = [0]*N
m = 0
c = 0
used[m] = 1
while(True):
m = A[m]
c += 1
if c == K:
print(m)
sys.exit()
if used[m] == 1:
break
else:... | import sys
from _collections import deque
N,K = map(int,input().split())
A = list(map(int,input().split()))
for i in range(len(A)):
A[i] = A[i]-1
used = [0]*N
m = 0
c = 0
used[m] = 1
while(True):
m = A[m]
c += 1
if c == K:
print(m+1)
sys.exit()
if used[m] == 1:
break
els... | [["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]] | 5 | 184 |
N, K = gets.chomp.split.map(&:to_i)
A = gets.chomp.split.map {|i| i.to_i - 1 }
idx = 0
m = { 0 => 0 }
ans = nil
(1..K).each do |i|
idx = A[idx]
if m[idx] # すでに通った
c = i - m[idx]
r = K - i
ans = A[m[idx]..(i-1)][r % c]
break
end
m[idx] = i
end
if ans
puts ans + 1
else
puts idx + 1
end
| N, K = gets.chomp.split.map(&:to_i)
A = gets.chomp.split.map {|i| i.to_i - 1 }
idx = 0
m = { 0 => 0 }
ans = nil
(1..K).each do |i|
idx = A[idx]
if m[idx]
c = i - m[idx]
r = K - i
ans = m.keys[m[idx]..-1][r % c]
break
end
m[idx] = i
end
if ans
puts ans + 1
else
puts idx + 1
end
| [["-", 64, 749, 0, 662, 12, 742, 500, 742, 500, 743], ["+", 0, 662, 12, 742, 500, 742, 500, 652, 486, 22], ["+", 0, 662, 12, 742, 500, 742, 500, 652, 17, 131], ["+", 0, 662, 12, 742, 500, 742, 500, 652, 735, 22], ["-", 12, 742, 500, 742, 0, 475, 444, 739, 0, 24], ["-", 500, 742, 0, 475, 444, 739, 0, 738, 31, 22], ["-",... | 4 | 124 |
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#incl... | #include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#incl... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]] | 1 | 390 |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5;
int a[N], n;
bool vis[N];
ll k;
int main() {
scanf("%d%lld", &n, &k), k++;
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
}
int pos = 1;
vector<int> vec;
while (!vis[pos]) {
vec.push_back(pos);
vis[pos]... | #include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5;
int a[N], n;
bool vis[N];
ll k;
int main() {
scanf("%d%lld", &n, &k), k++;
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
}
int pos = 1;
vector<int> vec;
while (!vis[pos]) {
vec.push_back(pos);
vis[pos]... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 3, 4, 0, 69, 341, 342, 0, 16, 17, 33], ["+", 3, 4, 0, 69, 341, 342, 0, 16, 12, 13]] | 1 | 264 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, k;
cin >> n >> k;
long long a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
a[i]--;
}
vector<bool> visit(n, false);
visit[0] = true;
vector<int> tele;
tele.push_back(0);
int w = 0;
while (true) {
w = a[w];
if ... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, k;
cin >> n >> k;
long long a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
a[i]--;
}
vector<bool> visit(n, false);
visit[0] = true;
vector<int> tele;
tele.push_back(0);
int w = 0;
while (true) {
w = a[w];
if ... | [["-", 12, 16, 31, 69, 341, 342, 0, 16, 17, 72], ["-", 12, 16, 31, 69, 341, 342, 0, 16, 12, 13]] | 1 | 247 |
//#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
//#pragma GCC target("avx,avx2,fma")
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#... | //#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
//#pragma GCC target("avx,avx2,fma")
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#... | [["-", 0, 11, 12, 69, 341, 342, 0, 27, 28, 22], ["+", 0, 11, 12, 69, 341, 342, 0, 27, 28, 22]] | 1 | 491 |
# @author
import sys
class DTeleporter:
def solve(self, tc=0):
n, k = [int(_) for _ in input().split()]
a = [int(_) - 1 for _ in input().split()]
done = dict()
cur = 0
steps = 0
while cur not in done and steps < k:
done[cur] = steps
cur = a[... | # @author
import sys
class DTeleporter:
def solve(self, tc=0):
n, k = [int(_) for _ in input().split()]
a = [int(_) - 1 for _ in input().split()]
done = dict()
cur = 0
steps = 0
while cur not in done and steps < k:
done[cur] = steps
cur = a[... | [["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]] | 5 | 162 |
import sys
n, k = map(int, input().split())
a = list(map(int, input().split()))
a = [0] + a
visited = set([])
hist = [-1 for _ in range(n+1)]
cur = 1
cnt = 0
d = 0
while True:
if cnt == k:
# print(cur)
sys.exit()
if hist[cur] != -1:
d = cnt - hist[cur]
break
hist[cur] = cn... | import sys
n, k = map(int, input().split())
a = list(map(int, input().split()))
a = [0] + a
visited = set([])
hist = [-1 for _ in range(n+1)]
cur = 1
cnt = 0
d = 0
while True:
if cnt == k:
print(cur)
sys.exit()
if hist[cur] != -1:
d = cnt - hist[cur]
break
hist[cur] = cnt
... | [["+", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 161 |
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i, l, r) for (i = l; i < r; i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define P pair<ll, ll>
#define F first
#define S second
signed main() {
ll N, K, i, j, c = 0, ans = -1;
cin >> N >> K;
ll A[N], F[N]... | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i, l, r) for (i = l; i < r; i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define P pair<ll, ll>
#define F first
#define S second
signed main() {
ll N, K, i, j, c = 0, ans = -1;
cin >> N >> K;
ll A[N], F[N]... | [["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 110], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22]] | 1 | 212 |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inf 999999999999999999
#define N 666666
int arr[N];
vector<int> v;
map<int, int> vis;
signed main() {
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; i++)
cin >> arr[i];
int pos = 1;
v.push_back(1 * 1ll);
vis[1] = 1;
int tem... | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define inf 999999999999999999
#define N 666666
int arr[N];
vector<int> v;
map<int, int> vis;
signed main() {
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; i++)
cin >> arr[i];
int pos = 1;
v.push_back(1 * 1ll);
vis[1] = 1;
int tem... | [["-", 0, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 16, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 242 |
#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 n, k;
cin >> n >> k;
vector<int> a(n);
rep(i, n) {
int atmp;
cin >> atmp;
a.at(i) = atmp - 1;
}
int pos = 0;
vector<int> flag(n, -1);
... | #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 n, k;
cin >> n >> k;
vector<int> a(n);
rep(i, n) {
int atmp;
cin >> atmp;
a.at(i) = atmp - 1;
}
int pos = 0;
vector<int> flag(n, -1);
... | [["+", 0, 1, 0, 2, 3, 4, 0, 2, 63, 22], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 22], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 21], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 25]] | 1 | 197 |
#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 n, k;
cin >> n >> k;
vector<ll> a(n);
rep(i, n) {
cin >> a[i];
a[i]--;
}
int v = 0;
vector<int> visited(n, -1);
ll cnt = 0;
ll r = 0;
... | #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 n, k;
cin >> n >> k;
vector<ll> a(n);
rep(i, n) {
cin >> a[i];
a[i]--;
}
int v = 0;
vector<int> visited(n, -1);
ll cnt = 0;
ll r = 0;
... | [["+", 64, 9, 0, 1, 0, 16, 12, 16, 17, 72], ["+", 64, 9, 0, 1, 0, 16, 12, 16, 12, 13]] | 1 | 221 |
import sys
n,k=map(int,input().split())
A=[int(i) for i in input().split()]
d=dict()
for i,a in enumerate(A):
d[i+1] = a
p=1
li = set()
li.add(1)
for i in range(k):
#print(p,li)
p = d[p]
#print(p,li)
if p in li:
cyc = i+ 1- pidx
q = 1
st=0
while q != p:
q... | import sys
n,k=map(int,input().split())
A=[int(i) for i in input().split()]
d=dict()
for i,a in enumerate(A):
d[i+1] = a
p=1
li = set()
li.add(1)
for i in range(k):
#print(p,li)
p = d[p]
#print(p,li)
if p in li:
cyc = i + 1
q = 1
st=0
while q != p:
q = d[... | [["-", 64, 196, 0, 1, 0, 662, 12, 657, 17, 33], ["-", 64, 196, 0, 1, 0, 662, 12, 657, 12, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 110], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 12, 22]] | 5 | 172 |
n, k = map(int,input().split())
A = list(map(int,input().split()))
A = [a-1 for a in A]
path = []
passed = set([])
p = 0
while 1:
if k ==0:
print(p)
exit()
if p not in passed:
path.append(p)
passed.add(p)
p = A[p]
k -= 1
else:
break
path = path[path.index(p):]
term = len(path)
k %= te... | n, k = map(int,input().split())
A = list(map(int,input().split()))
A = [a-1 for a in A]
path = []
passed = set([])
p = 0
while 1:
if k ==0:
print(p+1)
exit()
if p not in passed:
path.append(p)
passed.add(p)
p = A[p]
k -= 1
else:
break
path = path[path.index(p):]
term = len(path)
k %= ... | [["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]] | 5 | 133 |
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n;
long long k;
int a[N];
int vis[N];
int main() {
scanf("%d %lld", &n, &k);
for (int i = 0; i < n; ++i) {
scanf("%d", &a[i]);
vis[i] = -1;
--a[i];
}
int cur = 0;
int len = 0;
while (vis[cur] == -1) {
vis[cur] = len... | #include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n;
long long k;
int a[N];
int vis[N];
int main() {
scanf("%d %lld", &n, &k);
for (int i = 0; i < n; ++i) {
scanf("%d", &a[i]);
vis[i] = -1;
--a[i];
}
int cur = 0;
int len = 0;
while (vis[cur] == -1) {
vis[cur] = len... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]] | 1 | 199 |
#pragma target("avx")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9... | #pragma target("avx")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9... | [["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]] | 1 | 658 |
/*
No matter how long a night, dawn will always break.
Simular saying ... The darkest hour is just before the dawn.
*************************************** ************************8
**********************************
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
... | /*
No matter how long a night, dawn will always break.
Simular saying ... The darkest hour is just before the dawn.
*************************************** ************************8
**********************************
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
... | [["-", 0, 1, 0, 16, 12, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 16, 12, 69, 341, 342, 0, 22]] | 1 | 414 |
n,k = map(int,input().split())
a = list(map(int,input().split()))
flag = True
went = {1}
go = [1]
i = 0
while flag:
if a[i] not in went:
go.append(a[i])
went.add(a[i])
i = a[i]-1
else:
flag = False
loop = go[go.index(a[i]):]
if len(go) >= k:
print(go[k])
else:
k -= len(go)-len(loop)
ans = k % ... | n,k = map(int,input().split())
a = list(map(int,input().split()))
flag = True
went = {1}
go = [1]
i = 0
while flag:
if a[i] not in went:
go.append(a[i])
went.add(a[i])
i = a[i]-1
else:
flag = False
loop = go[go.index(a[i]):]
if len(go) > k:
print(go[k])
else:
k -= len(go)-len(loop)
ans = k % l... | [["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 20], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 47]] | 5 | 150 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ll n, k, p;
cin >> n >> k;
map<ll, ll> m;
for (ll i = 1; i <= n; i++) {
cin >> p;
m[i] = p;
}
map<ll, vector<ll>> m1;
ll st = 1;
ll count = 1;
while (count < k) {
if (m1.find(st) == m1.end()) {
m1[st].... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ll n, k, p;
cin >> n >> k;
map<ll, ll> m;
for (ll i = 1; i <= n; i++) {
cin >> p;
m[i] = p;
}
map<ll, vector<ll>> m1;
ll st = 1;
ll count = 1;
while (count < k) {
if (m1.find(st) == m1.end()) {
m1[st].... | [["+", 64, 1, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 0, 16, 31, 16, 12, 69, 341, 342, 0, 70], ["+", 0, 16, 31, 16, 12, 69, 341, 342, 0, 73]] | 1 | 229 |
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int N, A[200005];
long long int K;
int used[200005];
vector<int> V, W;
int S;
long long int ans = -1;
void visit(int i, long long int k) {
if (k == K) {
ans = k;
}
used[i] = 1;
V.push_... | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int N, A[200005];
long long int K;
int used[200005];
vector<int> V, W;
int S;
long long int ans = -1;
void visit(int i, long long int k) {
if (k == K) {
ans = i;
}
used[i] = 1;
V.push_... | [["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22]] | 1 | 292 |
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using nam... | #include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using nam... | [["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 270 |
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;
// 插入此處
int main() {
std::ios::sync_with_stdio(false);
cin.tie(0);
LL N, K;
cin >> N >> K;
vector<LL> A(N);
for (LL i = 0; i < N; ++i) {
cin >> A[i];
--A[i];
}
vector<LL> vis(N, -1);
L... | #include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;
// 插入此處
int main() {
std::ios::sync_with_stdio(false);
cin.tie(0);
LL N, K;
cin >> N >> K;
vector<LL> A(N);
for (LL i = 0; i < N; ++i) {
cin >> A[i];
--A[i];
}
vector<LL> vis(N, -1);
L... | [["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 230 |
N, K = map(int, input().split())
As = list(map(int, input().split()))
history = {}
cycle = []
pos = 1
isEnd = False
for i in range(2*N):
if pos in history:
for j in range(len(cycle)):
if cycle[j] == pos:
head = cycle[:j]
cycle = cycle[j:]
isEnd = ... | N, K = map(int, input().split())
As = list(map(int, input().split()))
history = {}
cycle = []
pos = 1
isEnd = False
for i in range(2*N):
if pos in history:
for j in range(len(cycle)):
if cycle[j] == pos:
head = cycle[:j]
cycle = cycle[j:]
isEnd = ... | [["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 19], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 18]] | 5 | 163 |
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
public class Main {
long MOD = (long)1e9 + 7;
InputStream in;
OutputStream out;
public Main() { this(System.in, System.out); }
public Main(InputStream in, OutputStream out) {
this.in = in;
thi... |
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
public class Main {
long MOD = (long)1e9 + 7;
InputStream in;
OutputStream out;
public Main() { this(System.in, System.out); }
public Main(InputStream in, OutputStream out) {
this.in = in;
thi... | [["+", 0, 1, 0, 492, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 492, 3, 4, 0, 16, 12, 499]] | 3 | 385 |
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 2e5 + 5;
ll n, k, a[nax];
vector<ll> v;
int main() {
... | #include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 2e5 + 5;
ll n, k, a[nax];
vector<ll> v;
int main() {
... | [["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 33], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 309 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define erep(i, a, n) for (int i = a; i <= n; i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vect... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define erep(i, a, n) for (int i = a; i <= n; i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vect... | [["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 343 |
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
... | #include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
... | [["+", 0, 57, 75, 76, 0, 9, 0, 93, 0, 94], ["+", 0, 57, 75, 76, 0, 9, 0, 93, 0, 35]] | 1 | 620 |
#include <bits/stdc++.h>
using namespace std;
#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
#define all(x) (x).begin(), (x).end()
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax... | #include <bits/stdc++.h>
using namespace std;
#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
#define all(x) (x).begin(), (x).end()
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax... | [["-", 15, 339, 51, 16, 31, 69, 341, 342, 0, 22], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 23, 0, 24], ["+", 15, 339, 51, 16, 12, 23, 0, 16, 17, 109], ["+", 15, 339, 51, 16, 12, 23, 0, 16, 12, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 23, 0, 25]] | 1 | 408 |
def read_int():
return int(input())
def read_int_map():
return map(int,input().split(' '))
def read_int_list():
return list(map(int,input().split(' ')))
def read_s_list_loop(n):
return [input() for _ in range(n)]
N,K = read_int_map()
An = read_int_list()
memo = [0]*(N+1)
memo_indx = [0]*(N+1)
memo[1... | def read_int():
return int(input())
def read_int_map():
return map(int,input().split(' '))
def read_int_list():
return list(map(int,input().split(' ')))
def read_s_list_loop(n):
return [input() for _ in range(n)]
N,K = read_int_map()
An = read_int_list()
memo = [0]*(N+1)
memo_indx = [0]*(N+1)
memo[1... | [["+", 0, 656, 0, 57, 15, 666, 0, 657, 17, 33], ["+", 0, 656, 0, 57, 15, 666, 0, 657, 12, 612]] | 5 | 235 |
/*#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;
#define ll long long
#define int long long // comment it out when MLE
#define endl "\n"
#define gok ... | /*#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;
#define ll long long
#define int long long // comment it out when MLE
#define endl "\n"
#define gok ... | [["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 72], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 650 |
n,k = map(int,input().split())
a = [0]+list(map(int,input().split()))
b = [0]*(n+1)
cnt = 0
temp = 1
rep = 0
while 1:
cnt += 1
if b[temp] == 0:
b[temp] = cnt
else:
rep = cnt-b[temp]
# print(rep,cnt-1,b[temp])
# print(b)
break
temp = a[temp]
# print((k-b[temp]+1) %... | n,k = map(int,input().split())
a = [0]+list(map(int,input().split()))
b = [0]*(n+1)
cnt = 0
temp = 1
rep = 0
while 1:
cnt += 1
if b[temp] == 0:
b[temp] = cnt
else:
rep = cnt-b[temp]
# print(rep,cnt-1,b[temp])
# print(b)
break
temp = a[temp]
# print((k-b[temp]+1) %... | [["+", 75, 76, 8, 196, 0, 7, 12, 652, 63, 22], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 24], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 25]] | 5 | 163 |
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
... | #include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
... | [["+", 0, 16, 31, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 16, 31, 69, 341, 342, 0, 16, 12, 13]] | 1 | 687 |
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main() {
queue<ll> que;
lo... | #include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main() {
queue<ll> que;
lo... | [["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 33], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 72]] | 1 | 476 |
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
#define FOR(i, l, r) for (int(i) = int(l); int(i) <= i... | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
#define FOR(i, l, r) for (int(i) = int(l); int(i) <= i... | [["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 72], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13], ["-", 0, 7, 10, 43, 49, 50, 51, 69, 28, 22], ["-", 10, 43, 49, 50, 51, 69, 341, 342, 0, 70], ["-", 10, 43, 49, 50, 51, 69, 341, 342, 0, 73]] | 1 | 1,632 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << fi... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << fi... | [["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 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, 12, 16, 12, 13]] | 1 | 337 |
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;
// 插入此處
int a[200005];
int ind[200005];
int main() {
LL n, k;
cin >> n >> k;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
memset(ind, -1, sizeof(ind));
int cur = 1;
ind[cur] = 0;
vector<in... | #include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;
// 插入此處
int a[200005];
int ind[200005];
int main() {
LL n, k;
cin >> n >> k;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
memset(ind, -1, sizeof(ind));
int cur = 1;
ind[cur] = 0;
vector<in... | [["+", 0, 14, 8, 9, 0, 57, 75, 76, 0, 95], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 45], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 46]] | 1 | 225 |
#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <utility>
#include <vector>
#define fir first
#define sec second
#define sz(s) (s).size()
#define pb push_back
#define get(n) scanf("%d", &n);
#... | #include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <utility>
#include <vector>
#define fir first
#define sec second
#define sz(s) (s).size()
#define pb push_back
#define get(n) scanf("%d", &n);
#... | [["-", 0, 1, 0, 16, 31, 16, 31, 2, 63, 22], ["-", 0, 16, 31, 16, 31, 2, 3, 4, 0, 24], ["-", 0, 16, 31, 16, 31, 2, 3, 4, 0, 22], ["-", 0, 16, 31, 16, 31, 2, 3, 4, 0, 25]] | 1 | 2,219 |
N,M,K = map(int,(input().split()))
MOD = 998244353
kaijo_memo = []
def kaijo(n):
if(len(kaijo_memo) > n):
return kaijo_memo[n]
if(len(kaijo_memo) == 0):
kaijo_memo.append(1)
while(len(kaijo_memo) <= n):
kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
return kaijo_memo[n]
gyaku_kaijo_memo... | N,M,K = map(int,(input().split()))
MOD = 998244353
kaijo_memo = []
def kaijo(n):
if(len(kaijo_memo) > n):
return kaijo_memo[n]
if(len(kaijo_memo) == 0):
kaijo_memo.append(1)
while(len(kaijo_memo) <= n):
kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
return kaijo_memo[n]
gyaku_kaijo_memo... | [["+", 0, 1, 0, 662, 12, 657, 31, 23, 0, 25], ["-", 8, 196, 0, 1, 0, 662, 12, 23, 0, 25]] | 5 | 297 |
#include <bits/stdc++.h>
using namespace std;
#define int long long
int N, M, K;
int f[200010] = {1};
int r[200010];
int m[200010] = {1};
int mod = 998244353;
int pow_mod(int a, int b) {
if (b == 0)
return 1;
int ret = pow_mod(a * a % mod, b / 2);
;
if (b % 2 == 1)
ret = ret * a % mod;
return ret;
... | #include <bits/stdc++.h>
using namespace std;
#define int long long
int N, M, K;
int f[200010] = {1};
int r[200010];
int m[200010] = {1};
int mod = 998244353;
int pow_mod(int a, int b) {
if (b == 0)
return 1;
int ret = pow_mod(a * a % mod, b / 2);
;
if (b % 2 == 1)
ret = ret * a % mod;
return ret;
... | [["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 132], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]] | 1 | 307 |
n,m,k=map(int,input().split())
def cmb(n, r, mod):
if ( r<0 or r>n ):
return 0
r = min(r, n-r)
return (g1[n] * (g2[r] * g2[n-r]) % mod)%mod
mod = 998244353
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, n + 1 ):
g1.append( ( g1[-1] * i ) % mod )
... | n,m,k=map(int,input().split())
def cmb(n, r, mod):
if ( r<0 or r>n ):
return 0
r = min(r, n-r)
return (g1[n] * (g2[r] * g2[n-r]) % mod)%mod
mod = 998244353
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, n + 1 ):
g1.append( ( g1[-1] * i ) % mod )
... | [["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 109], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22]] | 5 | 223 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, x, y) for (int i = x; i < y; i++)
#define print(A, x, n) \
rep(I, 0, n) { cout << (I ? " " : "") << A[I] x; } \
cout << endl;
#define pprint(A, y, m, n) ... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, x, y) for (int i = x; i < y; i++)
#define print(A, x, n) \
rep(I, 0, n) { cout << (I ? " " : "") << A[I] x; } \
cout << endl;
#define pprint(A, y, m, n) ... | [["-", 64, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22]] | 1 | 370 |
#ifdef DEBUG
#else
#pragma GCC optimize("O3,no-stack-protector")
#pragma GCC optimize("unroll-loops")
#if __cplusplus < 201703L
#pragma GCC target("avx")
#else
#pragma GCC target("avx2")
#endif
#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _USE_MATH_DEFINE... | #ifdef DEBUG
#else
#pragma GCC optimize("O3,no-stack-protector")
#pragma GCC optimize("unroll-loops")
#if __cplusplus < 201703L
#pragma GCC target("avx")
#else
#pragma GCC target("avx2")
#endif
#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _USE_MATH_DEFINE... | [["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]] | 1 | 661 |
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <math.h>
#define FOR(I, A, B) for (ll I = (A); I <= (B); I++)
#define IOS \
ios::sync_with_stdio(false); ... | #include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <math.h>
#define FOR(I, A, B) for (ll I = (A); I <= (B); I++)
#define IOS \
ios::sync_with_stdio(false); ... | [["+", 0, 16, 31, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 16, 31, 2, 3, 4, 0, 16, 12, 13]] | 1 | 535 |
#include <bits/stdc++.h>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define FILL0(x) memset(x, 0, sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> b... | #include <bits/stdc++.h>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define FILL0(x) memset(x, 0, sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> b... | [["-", 0, 16, 31, 16, 31, 2, 3, 4, 0, 22], ["+", 31, 16, 31, 2, 3, 4, 0, 16, 31, 22], ["+", 31, 16, 31, 2, 3, 4, 0, 16, 17, 33], ["+", 31, 16, 31, 2, 3, 4, 0, 16, 12, 13]] | 1 | 503 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
ll rep_pow(int n, int p) { // n^p
if (p == 0) {
return 1;
}
if (p % 2 == 0) {
ll t = rep_pow(n, p / 2);
return t * t % MOD;
} else {
return n * rep_pow(n, p - 1) % MOD;
}
}
int main() {
ll n, m... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
ll rep_pow(int n, int p) { // n^p
if (p == 0) {
return 1;
}
if (p % 2 == 0) {
ll t = rep_pow(n, p / 2);
return t * t % MOD;
} else {
return n * rep_pow(n, p - 1) % MOD;
}
}
int main() {
ll n, m... | [["+", 31, 16, 12, 23, 0, 16, 31, 16, 12, 13], ["+", 31, 16, 31, 16, 12, 23, 0, 16, 17, 33]] | 1 | 236 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i) >= min((a), (b))) && ((i) <= max((a), (b))))
#define show(x) cout << #x << " is " << x << "\n";
typedef vector<ll> vi;
#define fi first
#define se second
const ll mod ... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i) >= min((a), (b))) && ((i) <= max((a), (b))))
#define show(x) cout << #x << " is " << x << "\n";
typedef vector<ll> vi;
#define fi first
#define se second
const ll mod ... | [["-", 0, 30, 0, 43, 49, 50, 51, 16, 31, 13], ["+", 0, 30, 0, 43, 49, 50, 51, 16, 31, 13]] | 1 | 583 |
#include <bits/stdc++.h>
using namespace std;
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.en... | #include <bits/stdc++.h>
using namespace std;
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.en... | [["-", 12, 16, 12, 2, 3, 4, 0, 16, 31, 22], ["-", 12, 16, 12, 2, 3, 4, 0, 16, 17, 33], ["-", 12, 16, 12, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 11, 12, 16, 12, 2, 3, 4, 0, 22]] | 1 | 677 |
#include <bits/stdc++.h>
using namespace std;
#define lli long long
#define all(i) i.begin(), i.end()
#define rall(i) i.rbegin(), i.rend()
#define rep0(i, j) for (int i = 0; i < j; i++)
#define rep1(i, j) for (int i = 1; i <= j; i++)
#define rep0d(i, j) for (int i = j - 1; i >= 0; i--)
#define MOD 998244353
#define MA... | #include <bits/stdc++.h>
using namespace std;
#define lli long long
#define all(i) i.begin(), i.end()
#define rall(i) i.rbegin(), i.rend()
#define rep0(i, j) for (int i = 0; i < j; i++)
#define rep1(i, j) for (int i = 1; i <= j; i++)
#define rep0d(i, j) for (int i = j - 1; i >= 0; i--)
#define MOD 998244353
#define MA... | [["+", 0, 14, 8, 9, 0, 57, 75, 76, 0, 95]] | 1 | 1,482 |
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <bitset>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#in... | #define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <bitset>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#in... | [["+", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 0, 1, 0, 11, 12, 16, 12, 2, 63, 22], ["+", 0, 1, 0, 11, 12, 16, 12, 2, 63, 22], ["-", 12, 16, 12, 2, 3, 4, 0, 16, 12, 22], ["+", 12, 16, 12, 2, 3, 4, 0, 16, ... | 1 | 588 |
#include <iostream>
#include <vector>
using namespace std;
static const int mod = 998244353;
int fast_power(int a, int b) {
long long p = 1, q = a;
while (b) {
if (b & 1)
p = p * q % mod;
q = q * q % mod;
b >>= 1;
}
return p;
}
int main() {
int n, m, k;
scanf("%d %d %d", &n, &m, &k);
... | #include <iostream>
#include <vector>
using namespace std;
static const int mod = 998244353;
int fast_power(int a, int b) {
long long p = 1, q = a;
while (b) {
if (b & 1)
p = p * q % mod;
q = q * q % mod;
b >>= 1;
}
return p;
}
int main() {
int n, m, k;
scanf("%d %d %d", &n, &m, &k);
... | [["-", 0, 7, 8, 57, 15, 339, 51, 16, 17, 47], ["+", 0, 7, 8, 57, 15, 339, 51, 16, 17, 20]] | 1 | 296 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt, e) for (ll cnt = 0; cnt < e; cnt++)
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
const ll smod = 998244353;
const ll INF = INT64_MAX;
typedef tuple<ll, ll, ll, ll> T;
ll kaijou[200000 + 1];
ll gyakugen[200000 ... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt, e) for (ll cnt = 0; cnt < e; cnt++)
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
const ll smod = 998244353;
const ll INF = INT64_MAX;
typedef tuple<ll, ll, ll, ll> T;
ll kaijou[200000 + 1];
ll gyakugen[200000 ... | [["+", 12, 16, 31, 16, 31, 16, 31, 23, 0, 24], ["+", 12, 16, 31, 16, 31, 16, 31, 23, 0, 25], ["+", 0, 11, 12, 16, 31, 16, 31, 16, 17, 109], ["+", 0, 11, 12, 16, 31, 16, 31, 16, 12, 22]] | 1 | 407 |
def cmb(n, r, mod):
if ( r<0 or r>n ):
return 0
r = min(r, n-r)
return g1[n] * g2[r] * g2[n-r] % mod
import sys
input = sys.stdin.readline
N, M, K = map(int, input().split())
mod = 998244353
ans = 0
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range( 2, N + 1 ):
g1.append( ( g1[-1] * i ) ... | def cmb(n, r, mod):
if ( r<0 or r>n ):
return 0
r = min(r, n-r)
return g1[n] * g2[r] * g2[n-r] % mod
import sys
input = sys.stdin.readline
N, M, K = map(int, input().split())
mod = 998244353
ans = 0
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range( 2, N + 1 ):
g1.append( ( g1[-1] * i ) ... | [["-", 31, 657, 12, 652, 3, 4, 0, 657, 31, 22], ["-", 31, 657, 12, 652, 3, 4, 0, 657, 17, 72]] | 5 | 234 |
def cmb(n, r, mod):
if ( r<0 or r>n ):
return 0
r = min(r, n-r)
return g1[n] * g2[r] * g2[n-r] % mod
mod = 998244353
N = 2*10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, N + 1 ):
g1.append( ( g1[-1] * i ) % mod )
inverse.append( ( -inverse[... | def cmb(n, r, mod):
if ( r<0 or r>n ):
return 0
r = min(r, n-r)
return g1[n] * g2[r] * g2[n-r] % mod
mod = 998244353
N = 2*10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, N + 1 ):
g1.append( ( g1[-1] * i ) % mod )
inverse.append( ( -inverse[... | [["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 109], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 21], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]] | 5 | 259 |
#include <algorithm>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#incl... | #include <algorithm>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#incl... | [["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["-", 36, 36, 0, 30, 0, 14, 39, 86, 0, 96], ["+", 36, 36, 36, 36, 0, 30, 0, 14, 39, 78], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 109], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22]] | 1 | 478 |
#include <bits/stdc++.h>
using namespace std;
#define MODNUMBER 998244353
long long pow_mod(long long a, long long n) { // a^n mod MODNUMBER
long long result = 1;
long long a_i = a;
long long n_tmp = n;
while (n_tmp > 0) {
if (n_tmp & 0b1) {
result = (result * a_i) % MODNUMBER;
// cout << resu... | #include <bits/stdc++.h>
using namespace std;
#define MODNUMBER 998244353
long long pow_mod(long long a, long long n) { // a^n mod MODNUMBER
long long result = 1;
long long a_i = a;
long long n_tmp = n;
while (n_tmp > 0) {
if (n_tmp & 0b1) {
result = (result * a_i) % MODNUMBER;
// cout << resu... | [["-", 12, 2, 3, 4, 0, 16, 31, 16, 31, 22], ["+", 12, 2, 3, 4, 0, 16, 31, 16, 31, 22]] | 1 | 418 |
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define invrepr(i, a, b) for (int i = b - 1; i >= a; i--)
#define invrep(i, n) invrepr(i, 0, n)
#define repitr(itr, a) for (auto itr = a.begin(); itr != a.e... | #include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define invrepr(i, a, b) for (int i = b - 1; i >= a; i--)
#define invrep(i, n) invrepr(i, 0, n)
#define repitr(itr, a) for (auto itr = a.begin(); itr != a.e... | [["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13]] | 1 | 398 |
def COMinit():
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1
for i in range(2,max):
fac[i] = fac[i-1]*i%mod
inv[i] = mod - inv[mod%i]*(mod//i)%mod
finv[i] = finv[i-1]*inv[i]%mod
def COM(n,k):
if n < k:
return 0
if n < 0 or k < 0:
return 0
retur... | def COMinit():
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1
for i in range(2,max):
fac[i] = fac[i-1]*i%mod
inv[i] = mod - inv[mod%i]*(mod//i)%mod
finv[i] = finv[i-1]*inv[i]%mod
def COM(n,k):
if n < k:
return 0
if n < 0 or k < 0:
return 0
retur... | [["+", 0, 1, 0, 662, 12, 657, 31, 657, 17, 72], ["+", 0, 1, 0, 662, 12, 657, 31, 657, 12, 22], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 17, 72], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 12, 22]] | 5 | 258 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 9999999999999999
#define rep(i, m, n) for (ll i = m; i < n; i++)
#define rrep(i, m, n) for (ll i = m - 1; i >= n; i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(), N.end()), N.end());
#define Sort(n) sort(n.begin(), n.e... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 9999999999999999
#define rep(i, m, n) for (ll i = m; i < n; i++)
#define rrep(i, m, n) for (ll i = m - 1; i >= n; i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(), N.end()), N.end());
#define Sort(n) sort(n.begin(), n.e... | [["+", 0, 11, 12, 16, 31, 16, 31, 16, 17, 109], ["+", 0, 11, 12, 16, 31, 16, 31, 16, 12, 22]] | 1 | 377 |
// Hail god Yato
#include <bits/stdc++.h>
using namespace std;
#define hs \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0... | // Hail god Yato
#include <bits/stdc++.h>
using namespace std;
#define hs \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0... | [["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]] | 1 | 905 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, s, n) for (int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define outve(v) \
for (auto i : v) ... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, s, n) for (int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define outve(v) \
for (auto i : v) ... | [["-", 0, 43, 49, 50, 51, 4, 0, 16, 31, 22], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 31, 22]] | 1 | 927 |
fact = [1 for _ in range(100000)]
inv = [1 for _ in range(100000)]
fact_inv = [1 for _ in range(100000)]
mod = 998244353
for i in range(2, 100000):
fact[i] = (fact[i-1]*i) % mod
inv[i] = mod - (inv[mod % i] * (mod // i)) % mod
fact_inv[i] = (fact_inv[i-1] * inv[i]) % mod
N, M, K = map(int, input().split()... | fact = [1 for _ in range(200000)]
inv = [1 for _ in range(200000)]
fact_inv = [1 for _ in range(200000)]
mod = 998244353
for i in range(2, 200000):
fact[i] = (fact[i-1]*i) % mod
inv[i] = mod - (inv[mod % i] * (mod // i)) % mod
fact_inv[i] = (fact_inv[i-1] * inv[i]) % mod
N, M, K = map(int, input().split()... | [["-", 12, 658, 0, 659, 12, 652, 3, 4, 0, 612], ["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 612], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612]] | 5 | 207 |
n, m, k = map(int, input().split())
mod = 998244353
N = 10**5 # N!まで求める
fact = [1, 1] # 階乗の元テーブル
fact_inv = [1, 1] # 階乗の逆元テーブル
inv = [0, 1] # 逆元テーブル計算用テーブル 1,2,,...の逆元を求めてる
# 計算 O(1)
def comb(n, r, mod):
if (r<0 or r>n):
return 0
r = min(r, n-r)
return fact[n] * fact_inv[r] * fact_inv[n-r] % ... | n, m, k = map(int, input().split())
mod = 998244353
N = 10**5 * 2 # N!まで求める
fact = [1, 1] # 階乗の元テーブル
fact_inv = [1, 1] # 階乗の逆元テーブル
inv = [0, 1] # 逆元テーブル計算用テーブル 1,2,,...の逆元を求めてる
# 計算 O(1)
def comb(n, r, mod):
if (r<0 or r>n):
return 0
r = min(r, n-r)
return fact[n] * fact_inv[r] * fact_inv[n-r... | [["+", 0, 656, 0, 1, 0, 662, 12, 657, 17, 48], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 12, 612]] | 5 | 262 |
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define moca(a, s, b) a = ((a)s(b) + MOD) % MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;... | #include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define moca(a, s, b) a = ((a)s(b) + MOD) % MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;... | [["+", 3, 4, 0, 16, 31, 16, 31, 16, 17, 109], ["+", 3, 4, 0, 16, 31, 16, 31, 16, 12, 22]] | 1 | 425 |
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 998244353;
int pw(int n, int k) {
assert(k >= 0);
int res = 1;
while (k) {
if (k & 1)
(res *= n) %= MOD;
(n *= n) %= MOD;
k >>= 1;
}
return res;
}
std::vector<int> Factorial(5e6), Finverse(5e6);
inline void ... | #include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 998244353;
int pw(int n, int k) {
assert(k >= 0);
int res = 1;
while (k) {
if (k & 1)
(res *= n) %= MOD;
(n *= n) %= MOD;
k >>= 1;
}
return res;
}
std::vector<int> Factorial(5e6), Finverse(5e6);
inline void ... | [["+", 0, 11, 31, 23, 0, 16, 31, 16, 17, 109], ["+", 0, 11, 31, 23, 0, 16, 31, 16, 12, 22]] | 1 | 338 |
#!/usr/bin/env python3
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collection... | #!/usr/bin/env python3
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collection... | [["-", 0, 662, 12, 657, 12, 23, 0, 657, 31, 22], ["+", 0, 662, 12, 657, 12, 23, 0, 657, 31, 22], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22]] | 5 | 250 |
import sys
from io import StringIO
import unittest
import os
# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)
def prepare(n, mod=998244353):
f = 1
factorials = [1]
for m in range(1, n + 1):
f *= m
f %= mod
factorials.append(f)
inv = pow(f, mod - 2, mod)
... | import sys
from io import StringIO
import unittest
import os
# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)
def prepare(n, mod=998244353):
f = 1
factorials = [1]
for m in range(1, n + 1):
f *= m
f %= mod
factorials.append(f)
inv = pow(f, mod - 2, mod)
... | [["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 612], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 612]] | 5 | 595 |
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl = lambda: list(map(int, input().split()))
inm = lambda: map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
#R = 10**9 + 7
R = 998244353
def ddprint(x):
if D... | #from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl = lambda: list(map(int, input().split()))
inm = lambda: map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
#R = 10**9 + 7
R = 998244353
def ddprint(x):
if D... | [["+", 0, 656, 0, 57, 15, 666, 0, 664, 17, 33]] | 5 | 364 |
N, M, K = map(int, input().split())
MOD = 998244353
MAX = 2 * 10 ** 5 + 1
# Factorial
fac = [0] * (MAX + 1)
fac[0] = 1
fac[1] = 1
# Inverse
inv = [0] * (MAX + 1)
inv[1] = 1
# Inverse factorial
finv = [0] * (MAX + 1)
finv[0] = 1
finv[1] = 1
for i in range(2, MAX + 1):
fac[i] = fac[i - 1] * i % MOD
inv[i] =... |
N, M, K = map(int, input().split())
MOD = 998244353
MAX = 2 * 10 ** 5 + 1
# Factorial
fac = [0] * (MAX + 1)
fac[0] = 1
fac[1] = 1
# Inverse
inv = [0] * (MAX + 1)
inv[1] = 1
# Inverse factorial
finv = [0] * (MAX + 1)
finv[0] = 1
finv[1] = 1
for i in range(2, MAX + 1):
fac[i] = fac[i - 1] * i % MOD
inv[i] =... | [["+", 0, 7, 8, 196, 0, 1, 0, 677, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 17, 132], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 12, 22]] | 5 | 250 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define per(i, n) for (ll i = n - 1; i >= 0; i--)
#define perl(i, r, l) for (ll i = r - 1; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define ins inse... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define per(i, n) for (ll i = n - 1; i >= 0; i--)
#define perl(i, r, l) for (ll i = r - 1; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define ins inse... | [["-", 12, 16, 31, 16, 31, 2, 3, 4, 0, 22], ["+", 12, 16, 31, 16, 31, 2, 3, 4, 0, 22], ["-", 12, 16, 12, 2, 3, 4, 0, 16, 12, 22], ["+", 12, 16, 12, 2, 3, 4, 0, 16, 12, 22]] | 1 | 1,810 |
class Factorial():
def __init__(self, mod=10**9 + 7):
self.mod = mod
self._factorial = [1]
self._size = 1
self._factorial_inv = [1]
self._size_inv = 1
def __call__(self, n):
return self.fact(n)
def fact(self, n):
''' n! % mod '''
if n... | class Factorial():
def __init__(self, mod=10**9 + 7):
self.mod = mod
self._factorial = [1]
self._size = 1
self._factorial_inv = [1]
self._size_inv = 1
def __call__(self, n):
return self.fact(n)
def fact(self, n):
''' n! % mod '''
if n >= self... | [["-", 8, 196, 0, 1, 0, 652, 63, 319, 319, 22], ["+", 8, 196, 0, 1, 0, 652, 63, 319, 319, 22]] | 5 | 654 |
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#incl... | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#incl... | [["-", 28, 2, 3, 4, 0, 16, 31, 16, 12, 22], ["-", 63, 118, 28, 2, 3, 4, 0, 16, 17, 33], ["+", 51, 2, 3, 4, 0, 16, 31, 16, 17, 33], ["+", 51, 2, 3, 4, 0, 16, 31, 16, 12, 22]] | 1 | 2,055 |
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
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 = 200010, M = 1010, mod = 998244353;
int n, m, k;
int fac... | #include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
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 = 200010, M = 1010, mod = 998244353;
int n, m, k;
int fac... | [["+", 31, 23, 0, 16, 12, 16, 31, 16, 17, 109], ["+", 31, 23, 0, 16, 12, 16, 31, 16, 12, 22]] | 1 | 333 |
#import numpy as np
import math
#from decimal import *
#from numba import njit
#@njit
def main():
(N, M, K) = map(int, input().split())
MOD = 998244353
fact = [1]*(N+1)
factinv = [1]*(N+1)
for i in range(1,K+1):
fact[i] = fact[i-1]*i % MOD
factinv[i] = pow(fact[i], MOD-2, MOD)
... | #import numpy as np
import math
#from decimal import *
#from numba import njit
#@njit
def main():
(N, M, K) = map(int, input().split())
MOD = 998244353
fact = [1]*(N+1)
factinv = [1]*(N+1)
for i in range(1,N+1):
fact[i] = fact[i-1]*i % MOD
factinv[i] = pow(fact[i], MOD-2, MOD)
... | [["-", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22]] | 5 | 181 |
#include <bits/stdc++.h>
using namespace std;
long powm(long x, long a, long m) {
long s = 1;
long p = x % m;
for (int i = 0; i < 32; i++) {
if ((a >> i) & 1) {
s = (s * p) % m;
}
p = p * p % m;
}
return s;
}
long invm(long x, long m) { return powm(x, m - 2, m); }
vector<long> ntbl, dtbl;... | #include <bits/stdc++.h>
using namespace std;
long powm(long x, long a, long m) {
long s = 1;
long p = x % m;
for (int i = 0; i < 32; i++) {
if ((a >> i) & 1) {
s = (s * p) % m;
}
p = p * p % m;
}
return s;
}
long invm(long x, long m) { return powm(x, m - 2, m); }
vector<long> ntbl, dtbl;... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]] | 1 | 409 |
def main():
n, m, k = map(int, input().split())
mod = 998244353
ans = 0
m1 = [None]*(n+1)
kaizyo = [None]*(n+1)
nm1 = 1
kai = 1
for i in range(n+1):
m1[i] = nm1
nm1 *= m-1
nm1 %= mod
kaizyo[i] = kai
kai *= i+1
kai %= mod
def comb(a... | def main():
n, m, k = map(int, input().split())
mod = 998244353
ans = 0
m1 = [None]*(n+1)
kaizyo = [None]*(n+1)
nm1 = 1
kai = 1
for i in range(n+1):
m1[i] = nm1
nm1 *= m-1
nm1 %= mod
kaizyo[i] = kai
kai *= i+1
kai %= mod
def comb(a... | [["-", 31, 657, 12, 206, 206, 657, 31, 657, 12, 22], ["+", 31, 657, 12, 206, 206, 657, 31, 657, 12, 22], ["+", 12, 657, 12, 652, 3, 4, 0, 657, 17, 33], ["+", 12, 657, 12, 652, 3, 4, 0, 657, 12, 612], ["-", 0, 677, 12, 657, 12, 652, 3, 4, 0, 22], ["+", 0, 677, 12, 657, 12, 652, 3, 4, 0, 22]] | 5 | 262 |
# -*- coding: utf-8 -*-
class FactMod():
'''
modの値が素数の時のfactと組み合わせを求める
フェルマーの小定理を用いているため、modが素数以外の時は使えない
'''
def __init__(self, n, mod):
'''
コンストラクタ
f:nまでの i!の値を 配列に入れる
inv: (i!)^-1 の値を配列に入れる
'''
self.mod = mod
self.f = [1]*(n+1)
for... | # -*- coding: utf-8 -*-
class FactMod():
'''
modの値が素数の時のfactと組み合わせを求める
フェルマーの小定理を用いているため、modが素数以外の時は使えない
'''
def __init__(self, n, mod):
'''
コンストラクタ
f:nまでの i!の値を 配列に入れる
inv: (i!)^-1 の値を配列に入れる
'''
self.mod = mod
self.f = [1]*(n+1)
for... | [["-", 12, 652, 3, 4, 0, 657, 31, 657, 12, 22], ["+", 12, 652, 3, 4, 0, 657, 31, 657, 12, 22]] | 5 | 317 |
def main():
n, m, k = map(int, input().split())
mod = 998244353
kai = [None]*n
m1 = [None]*n
num = 1
ki = 1
for i in range(n):
m1[i] = num
num *= m-1
num %= mod
kai[i] = ki
ki *= i+1
ki %= mod
def comb(a, b):
return kai[a]*ferm... | def main():
n, m, k = map(int, input().split())
mod = 998244353
kai = [None]*n
m1 = [None]*n
num = 1
ki = 1
for i in range(n):
m1[i] = num
num *= m-1
num %= mod
kai[i] = ki
ki *= i+1
ki %= mod
def comb(a, b):
return kai[a]*ferm... | [["-", 12, 657, 31, 657, 12, 206, 206, 657, 12, 22], ["+", 12, 657, 31, 657, 12, 206, 206, 657, 12, 22]] | 5 | 250 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.