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 <numeric> #include <functional>
#include <array>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <vector> #include <string>
#define rep(i, n) for (auto i = 0; i < (n); i++)
using namespace std;
#define ll long long
#define all(v) v.begin(), v.end()
#define... | #include <algorithm> #include <numeric> #include <functional>
#include <array>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <vector> #include <string>
#define rep(i, n) for (auto i = 0; i < (n); i++)
using namespace std;
#define ll long long
#define all(v) v.begin(), v.end()
#define... | [["-", 31, 16, 12, 23, 0, 41, 15, 16, 17, 47], ["+", 31, 16, 12, 23, 0, 41, 15, 16, 17, 20]] | 1 | 391 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
const ll mod = 998244353;
typedef pair<int, int> P;
int main() {
int n, k;
cin >> n >> k;
vector<int> l(k), r(k);
rep(i, k) cin >> l[i] >> r[i];
vector<ll> dp(n + 1);
vector<ll> dpsum(n + 1); ... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
const ll mod = 998244353;
typedef pair<int, int> P;
int main() {
int n, k;
cin >> n >> k;
vector<int> l(k), r(k);
rep(i, k) cin >> l[i] >> r[i];
vector<ll> dp(n + 1);
vector<ll> dpsum(n + 1); ... | [["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 12, 22]] | 1 | 247 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 998244353;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, k;
cin >> n >> k;
vector<pair<int, int>> segments;
;
for (int i = 0; i < k; ++i) {
int l, r;
cin >> l >> r;
segments.push_back({l, r});
... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 998244353;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, k;
cin >> n >> k;
vector<pair<int, int>> segments;
;
for (int i = 0; i < k; ++i) {
int l, r;
cin >> l >> r;
segments.push_back({l, r});
... | [["+", 0, 16, 12, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 16, 12, 16, 31, 23, 0, 16, 12, 22]] | 1 | 267 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <ctype.h>
#include <iostream>
#include <string>
typedef long long ll;
using namespace std;
int main() {
int mod = 998244353;
int n, k, a, b, l, r;
cin >> n >> k;
vector<int> sum(n + 1, 0);
vector<int> ans(n + 1, 0);
... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <ctype.h>
#include <iostream>
#include <string>
typedef long long ll;
using namespace std;
int main() {
int mod = 998244353;
int n, k, a, b, l, r;
cin >> n >> k;
vector<ll> sum(n + 1, 0);
vector<ll> ans(n + 1, 0);
ve... | [["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78], ["+", 0, 7, 8, 9, 0, 14, 8, 9, 0, 46], ["-", 0, 7, 8, 9, 0, 14, 8, 9, 0, 46]] | 1 | 277 |
// https://atcoder.jp/contests/abc179/tasks/abc179_d
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
const int MAXN = 2e5 + 4;
long long ans[MAXN]; //递推答案
long long sum[MAXN]; //前缀和
const int MAXK = 10 + 4;
pair<int, int> seg[MAXK]; //区间
const int MO = 998244353;
... | // https://atcoder.jp/contests/abc179/tasks/abc179_d
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
const int MAXN = 2e5 + 4;
long long ans[MAXN]; //递推答案
long long sum[MAXN]; //前缀和
const int MAXK = 10 + 4;
pair<int, int> seg[MAXK]; //区间
const int MO = 998244353;
... | [["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 12, 22]] | 1 | 254 |
N, X, M = map(int, input().split())
x = X
nums = []
isSearched = [False] * (M+1)
isSearchedNums = [-1] * (M+1)
n = 0
looped = 0
while True:
x = (x*x) % M
if isSearched[x]:
looped = isSearchedNums[x]
break
isSearched[x] = True
isSearchedNums[x] = n
nums.append(x)
n+=1
if (isSearch... | N, X, M = map(int, input().split())
x = X
nums = []
isSearched = [False] * (M+1)
isSearchedNums = [-1] * (M+1)
n = 0
looped = 0
while True:
x = (x*x) % M
if isSearched[x]:
looped = isSearchedNums[x]
break
isSearched[x] = True
isSearchedNums[x] = n
nums.append(x)
n+=1
if (isSearch... | [["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 21]] | 5 | 261 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using LL = long long;
using P = pair<int, int>;
int main() {
LL N, X, M;
cin >> N >> X >> M;
vector<LL> A(M + 2), sum(M + 2);
vector<LL> app(M + 1);
A[1] = X, sum[1] = X, app[X] = 1;
LL ans = 0;
LL dif = 0... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using LL = long long;
using P = pair<int, int>;
int main() {
LL N, X, M;
cin >> N >> X >> M;
vector<LL> A(M + 2), sum(M + 2);
vector<LL> app(M + 1);
A[1] = X, sum[1] = X, app[X] = 1;
LL ans = 0;
LL dif = 0... | [["+", 341, 342, 0, 69, 341, 342, 0, 16, 17, 72], ["+", 341, 342, 0, 69, 341, 342, 0, 16, 12, 13]] | 1 | 291 |
#include <algorithm>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define REP(i, m, n) for (int i... | #include <algorithm>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define REP(i, m, n) for (int i... | [["+", 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 | 654 |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define M 1000000007
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, x, m;
cin >> n >> x >> m;
int dp[2][m + 1];
memset(dp, 0, sizeof(dp));
dp[0][x] = 0;
dp[1][x] = 1;
int sum = 2, lst = ... | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define M 1000000007
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, x, m;
cin >> n >> x >> m;
int dp[2][m + 1];
memset(dp, 0, sizeof(dp));
dp[0][x] = 0;
dp[1][x] = 1;
int sum = x, lst = ... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 22]] | 1 | 347 |
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
#define... | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
#define... | [["-", 8, 9, 0, 52, 15, 339, 51, 16, 31, 13], ["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 106]] | 1 | 431 |
n,x,m = map(int,input().split())
if x == 0:
print(0)
exit()
li = [-1] * (m+1)
v = [False] * (m+1)
v2 = [False] * (m+1)
v[x] = True
tmp = x
ans = x
loop = 0
cnt = 0
cnt_l = 0
loop_li = [0]
ans_li = [x]
for i in range(m):
li[i] = (i ** 2) % m
while True:
tmp = li[tmp]
ans += tmp
v[tmp] = True
... | n,x,m = map(int,input().split())
if x == 0:
print(0)
exit()
li = [-1] * (m+1)
v = [False] * (m+1)
v2 = [False] * (m+1)
v[x] = True
tmp = x
ans = x
loop = 0
cnt = 0
cnt_l = 0
loop_li = [0]
ans_li = [x]
for i in range(m):
li[i] = (i ** 2) % m
while True:
tmp = li[tmp]
ans += tmp
v[tmp] = True
... | [["-", 0, 656, 0, 1, 0, 662, 12, 206, 0, 70], ["-", 0, 1, 0, 662, 12, 206, 206, 663, 0, 102], ["-", 0, 1, 0, 662, 12, 206, 206, 663, 0, 22], ["-", 0, 656, 0, 1, 0, 662, 12, 206, 0, 73], ["+", 0, 652, 3, 4, 0, 206, 206, 657, 31, 22]] | 5 | 349 |
N, X, M = map(int, input().split())
if X == 0:
print(0)
exit()
if N == 1:
print(X)
exit()
d = [-1] * (M + 1)
out = [0]
a = X
ans = 0
for i in range(1, N + 1):
ans += a
d[a] = i
out.append(a)
a = a ** 2 % M
if a == 0:
print(ans)
exit()
if d[a] != -1:
lo... | N, X, M = map(int, input().split())
if X == 0:
print(0)
exit()
if N == 1:
print(X)
exit()
d = [-1] * (M + 1)
out = [0]
a = X
ans = 0
for i in range(1, N + 1):
ans += a
d[a] = i
out.append(a)
a = a ** 2 % M
if a == 0:
print(ans)
exit()
if d[a] != -1:
lo... | [["-", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94]] | 5 | 188 |
/*
* Author: Utkal Sinha
* Created on: 2020-09-19, Sat, 17:48
* Problem:
* Platfrom: General
* */
#if USE_BOOST2
#include <boost/multiprecision/cpp_bin_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace bst = boost::multiprecision;
typedef bst::int1024_t vll; // int512_t or //int128_t
typedef bst::cp... | /*
* Author: Utkal Sinha
* Created on: 2020-09-19, Sat, 17:48
* Problem:
* Platfrom: General
* */
#if USE_BOOST2
#include <boost/multiprecision/cpp_bin_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace bst = boost::multiprecision;
typedef bst::int1024_t vll; // int512_t or //int128_t
typedef bst::cp... | [["-", 0, 57, 64, 1, 0, 11, 12, 16, 17, 109], ["-", 0, 57, 64, 1, 0, 11, 12, 16, 12, 22]] | 1 | 489 |
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN = 2E5 + 5;
LL n, x, m;
LL sum[MAXN], a[MAXN], last[MAXN], st, ed;
int main() {
// freopen("1.in", "r", stdin);
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> n >> x >> m;
a[1] = x, sum[1] = a[1];
for (int i ... | #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN = 2E5 + 5;
LL n, x, m;
LL sum[MAXN], a[MAXN], last[MAXN], st, ed;
int main() {
// freopen("1.in", "r", stdin);
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> n >> x >> m;
a[1] = x, sum[1] = a[1];
for (int i ... | [["+", 12, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 12, 16, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 312 |
n,x,m=map(int,input().split())
l=[0 for i in range(m)]
ans=0
y=[]
i=1
flag=0
ys=n
while i<n:
if flag==0:
ans+=x
l[x]+=1
x=x*x%m
i+=1
if l[x]==2 and flag==0:
flag=1
ys=i
if flag:
if l[x]==3:
break
y.append(x)
if len(y):
p,pp=divmod(n-ys,len(... | n,x,m=map(int,input().split())
l=[0 for i in range(m)]
ans=0
y=[]
i=1
flag=0
ys=n
while i<n+1:
if flag==0:
ans+=x
l[x]+=1
x=x*x%m
i+=1
if l[x]==2 and flag==0:
flag=1
ys=i
if flag:
if l[x]==3:
break
y.append(x)
if len(y):
p,pp=divmod(n-ys,le... | [["+", 0, 656, 0, 52, 15, 666, 0, 657, 17, 72], ["+", 0, 656, 0, 52, 15, 666, 0, 657, 12, 612]] | 5 | 161 |
#include <bits/stdc++.h>
#define N 200007
using namespace std;
typedef long long ll;
inline ll rd() {
ll x = 0;
char c = getchar();
while (!isdigit(c))
c = getchar();
while (isdigit(c)) {
x = x * 10 + (c ^ 48);
c = getchar();
}
return x;
}
ll n, x, m, p, ans, cnt[N];
inline int phi(int x) {
... | #include <bits/stdc++.h>
#define N 200007
using namespace std;
typedef long long ll;
inline ll rd() {
ll x = 0;
char c = getchar();
while (!isdigit(c))
c = getchar();
while (isdigit(c)) {
x = x * 10 + (c ^ 48);
c = getchar();
}
return x;
}
ll n, x, m, p, ans, cnt[N];
inline int phi(int x) {
... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]] | 1 | 529 |
//#define _GLIBCXX_DEBUG
#include <algorithm>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
using namespace std;
// using Graph = vector<vector<int>>;
typedef long long ll;
using Graph = vector<vector<pair<ll, ll>>>;
const int mod = 1e+9 + 7;
const int d... | //#define _GLIBCXX_DEBUG
#include <algorithm>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
using namespace std;
// using Graph = vector<vector<int>>;
typedef long long ll;
using Graph = vector<vector<pair<ll, ll>>>;
const int mod = 1e+9 + 7;
const int d... | [["-", 49, 50, 51, 16, 12, 23, 0, 16, 17, 33], ["+", 49, 50, 51, 16, 12, 23, 0, 16, 17, 72]] | 1 | 356 |
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// DEEP
using namespace std;
#define boost \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); ... | #include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// DEEP
using namespace std;
#define boost \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); ... | [["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 18]] | 1 | 702 |
N,X,M = map(int, input().split())
A = [-1]*M
A[0] = X
i = 0
tmpans = 0
flag = False
check = [-1]*(M+1)
slice = -1
while i< N-1:
newa = A[i]**2%M
i+= 1
if check[newa] != -1:
flag = True
slice = check[newa]
break
A[i] = newa
check[newa] = i
if not flag:
print(sum(A[:i+1]... | N,X,M = map(int, input().split())
A = [-1]*(M+100)
A[0] = X
i = 0
tmpans = 0
flag = False
check = [-1]*(M+1)
slice = -1
while i< N-1:
newa = A[i]**2%M
i+= 1
if check[newa] != -1:
flag = True
slice = check[newa]
break
A[i] = newa
check[newa] = i
if not flag:
print(sum(A... | [["+", 0, 1, 0, 662, 12, 657, 12, 23, 0, 24], ["+", 0, 662, 12, 657, 12, 23, 0, 657, 17, 72], ["+", 0, 662, 12, 657, 12, 23, 0, 657, 12, 612], ["+", 0, 1, 0, 662, 12, 657, 12, 23, 0, 25], ["+", 3, 4, 0, 206, 206, 663, 0, 657, 31, 22], ["+", 3, 4, 0, 206, 206, 663, 0, 657, 17, 72]] | 5 | 182 |
#include <bits/stdc++.h>
#define endl '\n'
#define PB push_back
#define PF push_front
#define MP make_pair
#define fi first
#define se second
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<l... | #include <bits/stdc++.h>
#define endl '\n'
#define PB push_back
#define PF push_front
#define MP make_pair
#define fi first
#define se second
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<l... | [["-", 0, 7, 10, 43, 49, 50, 51, 16, 17, 72], ["-", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]] | 1 | 372 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, x, m;
cin >> n >> x >> m;
set<long long> s;
vector<long long> v;
while (1) {
if (s.find(x) != s.end())
break;
s.insert(x);
v.push_back(x);
x = x * x;
x %= m;
}
long long cnt = 0;
if (v.size() >= n) {
fo... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, x, m;
cin >> n >> x >> m;
set<long long> s;
vector<long long> v;
while (1) {
if (s.find(x) != s.end())
break;
s.insert(x);
v.push_back(x);
x = x * x;
x %= m;
}
long long cnt = 0;
if (v.size() >= n) {
fo... | [["-", 0, 57, 64, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 17, 18]] | 1 | 439 |
#include <bits/stdc++.h>
#define int long long
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<long long,null_type,less<long
long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
s.find_by_order(x) xth element in set
x.order_of_key(x) number of elemen... | #include <bits/stdc++.h>
#define int long long
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<long long,null_type,less<long
long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
s.find_by_order(x) xth element in set
x.order_of_key(x) number of elemen... | [["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]] | 1 | 417 |
N, X, M = map(int, input().split())
lim = 10**5*2+1
f = [0]*(lim)
a = [0]*(lim)
x = X
f[x] = 1
a[1] = x
ans = x
i = 1
l = N
while i < l:
i += 1
x **= 2
x %= M
if not x:
break
if f[x]:
lp_len = (i-f[x])
z = (l-i+1)//lp_len
if z:
ls = ans - a[f[x]-1]
... | N, X, M = map(int, input().split())
lim = 10**5*2+1
f = [0]*(lim)
a = [0]*(lim)
x = X
f[x] = 1
a[1] = x
ans = x
i = 1
l = N
while i < l:
i += 1
x **= 2
x %= M
if not x:
break
if f[x]:
lp_len = (i-f[x])
z = (l-i+1)//lp_len
if z:
ls = ans - a[f[x]-1]
... | [["+", 0, 656, 0, 52, 8, 196, 0, 57, 0, 121], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 667, 19], ["+", 0, 656, 0, 52, 8, 196, 0, 57, 0, 102]] | 5 | 165 |
def main():
n, x, m = map(int, input().split())
inlis = list()
inlis.append(x)
mae = x
kaisuu = 0
for j in range(n-1):
tsugi = mae ** 2 % m
#print(tsugi)
if tsugi not in inlis:
inlis.append(tsugi)
mae = tsugi
else:
inlis.append... | def main():
n, x, m = map(int, input().split())
inlis = list()
inlis.append(x)
mae = x
kaisuu = 0
for j in range(n-1):
tsugi = mae ** 2 % m
#print(tsugi)
if tsugi not in inlis:
inlis.append(tsugi)
mae = tsugi
else:
inlis.append... | [["-", 0, 662, 12, 657, 31, 23, 0, 657, 17, 72], ["-", 0, 662, 12, 657, 31, 23, 0, 657, 12, 612], ["-", 3, 4, 0, 206, 206, 663, 0, 657, 17, 33], ["-", 3, 4, 0, 206, 206, 663, 0, 657, 12, 612]] | 5 | 224 |
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, m, n) for (ll i = m; i < (ll)(n); i++)
#define rrep(i, n, m) for (ll i ... | #include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, m, n) for (ll i = m; i < (ll)(n); i++)
#define rrep(i, n, m) for (ll i ... | [["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 0, 2, 3, 4, 0, 16, 12, 23, 0, 24], ["+", 0, 2, 3, 4, 0, 16, 12, 23, 0, 25]] | 1 | 482 |
N, X, M = gets.split.map(&:to_i)
as = Array.new(M, nil)
c = X
m = 0
i = 0
g = false
while true do
i += 1
m += c
if i == N then
g = true
puts m
break
end
if as[c] == nil then
as[c] = [i, m]
else
aa = as[c]
ro = i - aa[0]
rb = m - aa[1]
loc = (N - i) / ro
# pp [aa, i, m]
... | N, X, M = gets.split.map(&:to_i)
as = Array.new(M, nil)
c = X
m = 0
i = 0
g = false
while true do
i += 1
m += c
if i == N then
g = true
puts m
break
end
if as[c] == nil then
as[c] = [i, m]
else
aa = as[c]
ro = i - aa[0]
rb = m - aa[1]
loc = (N - i) / ro
# pp [aa, i, m]
... | [["+", 0, 493, 0, 121, 15, 738, 31, 748, 17, 111], ["+", 0, 493, 0, 121, 15, 738, 31, 748, 439, 22], ["+", 36, 36, 0, 493, 0, 121, 15, 738, 17, 98], ["-", 36, 36, 36, 36, 0, 493, 0, 747, 0, 747], ["+", 36, 36, 36, 36, 0, 493, 0, 121, 0, 121], ["+", 36, 36, 0, 493, 0, 121, 15, 748, 17, 111]] | 4 | 171 |
import sys,queue,math,copy,itertools,bisect,collections,heapq
def main():
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
N,X,M = LI()
d = [0] * (M+1)
t = [0] * (M+1)
aa = X
i = 0
s = 0
while d[aa] == 0:
i += 1
d[aa] = i
s += aa
t[i] = s
... | import sys,queue,math,copy,itertools,bisect,collections,heapq
def main():
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
N,X,M = LI()
d = [0] * (M+1)
t = [0] * (M+1)
aa = X
i = 0
s = 0
while d[aa] == 0:
i += 1
d[aa] = i
s += aa
t[i] = s
... | [["+", 0, 1, 0, 662, 12, 657, 31, 23, 0, 24], ["+", 0, 1, 0, 662, 12, 657, 31, 23, 0, 25], ["-", 64, 196, 0, 1, 0, 662, 12, 206, 206, 22], ["+", 64, 196, 0, 1, 0, 662, 12, 206, 206, 22], ["+", 0, 1, 0, 662, 12, 657, 12, 23, 0, 24], ["+", 0, 1, 0, 662, 12, 657, 12, 23, 0, 25]] | 5 | 222 |
import sys
def input(): return sys.stdin.readline().strip()
def main():
n, x, m = map(int, input().split())
if x == 0:
print(0)
return
if x == 1:
print(n)
return
d = {}
d_idx = {}
d_unit = {}
idx = 0
pow_x = x
unit = 0
while idx < n and pow_x not... | import sys
def input(): return sys.stdin.readline().strip()
def main():
n, x, m = map(int, input().split())
if x == 0:
print(0)
return
if x == 1:
print(n)
return
d = {}
d_idx = {}
d_unit = {}
idx = 0
pow_x = x
unit = 0
while idx < n and pow_x not... | [["-", 8, 196, 0, 57, 15, 666, 0, 657, 17, 33], ["-", 8, 196, 0, 57, 15, 666, 0, 657, 12, 612]] | 5 | 217 |
#ifdef __APPLE__
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <ctgmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#... | #ifdef __APPLE__
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <ctgmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#... | [["-", 8, 9, 0, 57, 15, 339, 51, 91, 17, 111], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 9, 0, 7, 15, 16, 12, 23, 0, 24], ["+", 0, 9, 0, 7, 15, 16, 12, 23, 0, 25]] | 1 | 647 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll N, X, M;
cin >> N >> X >> M;
vector<ll> A(2 * M + 20);
set<ll> S;
S.insert(X);
A[0] = X;
ll l = 0, r = 0;
for (ll i = 1;; i++) {
A[i] = (A[i - 1] % M) * (A[i - 1] % M);
if (S.find(A[i]) != S.end()) {
for (... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll N, X, M;
cin >> N >> X >> M;
vector<ll> A(2 * M + 20);
set<ll> S;
S.insert(X);
A[0] = X;
ll l = 0, r = 0;
for (ll i = 1;; i++) {
A[i] = ((A[i - 1] % M) * (A[i - 1] % M)) % M;
if (S.find(A[i]) != S.end()) {
... | [["+", 12, 16, 31, 23, 0, 16, 31, 23, 0, 24], ["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 25], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]] | 1 | 326 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
long long n, x, m;
cin >> n >> x >> m;
long long N = min(n + 1, m + 100);
vector<long long> a(N);
vector<int> vis(m);
a[1] = x;
vis[x] = 1;
long long ans = 0;
for (int i = 2; i < N; i++) {
... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
long long n, x, m;
cin >> n >> x >> m;
long long N = min(n + 1, m + 2);
vector<long long> a(N);
vector<int> vis(m);
a[1] = x;
vis[x] = 1;
long long ans = 0;
for (int i = 2; i < N; i++) {
a... | [["-", 49, 50, 51, 2, 3, 4, 0, 16, 12, 13], ["+", 49, 50, 51, 2, 3, 4, 0, 16, 12, 13], ["-", 51, 2, 3, 4, 0, 16, 31, 16, 17, 72], ["-", 51, 2, 3, 4, 0, 16, 31, 16, 12, 13]] | 1 | 347 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll n, x, m;
cin >> n >> x >> m;
set<ll> s;
vector<ll> v;
v.push_back(x);
s.insert(x);
ll lsz;
vector<ll>::iterator it;
while (true) {
ll a = (v.back() * v.back()) % m;
ll sz = s.size();
s.insert(a);
if (s... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll n, x, m;
cin >> n >> x >> m;
set<ll> s;
vector<ll> v;
v.push_back(x);
s.insert(x);
ll lsz;
vector<ll>::iterator it;
while (true) {
ll a = (v.back() * v.back()) % m;
ll sz = s.size();
s.insert(a);
if (s... | [["-", 31, 16, 12, 2, 3, 4, 0, 16, 17, 72], ["-", 31, 16, 12, 2, 3, 4, 0, 16, 12, 13]] | 1 | 327 |
n,x,m = map(int,input().split())
check = set()
hazimari = -1
owari = 0
y = x
check.add(x)
for i in range(n-1):
owari = y
y = y**2 % m
if y in check:
hazimari = y
break
check.add(y)
if hazimari == -1:#ループするまでもなくnが小さかったとき
print(sum(check))
exit()
ans = 0
count = 0
lp = []
y = x... | n,x,m = map(int,input().split())
check = set()
hazimari = -1
owari = 0
y = x
check.add(x)
for i in range(n-1):
owari = y
y = y**2 % m
if y in check:
hazimari = y
break
check.add(y)
if hazimari == -1:#ループするまでもなくnが小さかったとき
print(sum(check))
exit()
ans = 0
count = 0
lp = []
y = x... | [["-", 12, 657, 31, 657, 31, 23, 0, 657, 12, 612], ["+", 12, 657, 31, 657, 31, 23, 0, 657, 12, 22], ["-", 206, 663, 0, 657, 31, 23, 0, 657, 12, 612], ["+", 206, 663, 0, 657, 31, 23, 0, 657, 12, 22]] | 5 | 211 |
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
for (ll i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__) /... | #include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
for (ll i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__) /... | [["-", 0, 1, 0, 34, 12, 34, 31, 11, 12, 13], ["+", 0, 1, 0, 34, 12, 34, 31, 11, 12, 13]] | 1 | 320 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll a;
cin >> a;
ll b, c;
cin >> b >> c;
ll g = b;
ll h = -1;
if (a == 1 || b == 0) {
cout << g << endl;
return 0;
}
for (ll i = 0; i < min(a, c) - 1; i++) {
b = b * b % c;
if (b == 0) {
cout << g <... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll a;
cin >> a;
ll b, c;
cin >> b >> c;
ll g = b;
ll h = -1;
if (a == 1 || b == 0) {
cout << g << endl;
return 0;
}
for (ll i = 0; i < min(a, c) - 1; i++) {
b = b * b % c;
if (b == 0) {
cout << g <... | [["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 72], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["-", 49, 50, 51, 16, 31, 23, 0, 16, 12, 13], ["+", 49, 50, 51, 16, 31, 23, 0, 16, 12, 13], ["-", 64, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 64, 9, 0, 7, 15, 16, 12, 16, 12, 13]] | 1 | 321 |
#include <algorithm>
#include <iostream>
using namespace std;
int main(void) {
long long int n, x, m, ans = 0;
;
long long int i, j, k, d[1000000], dis, l1, l2;
bool c[1000000];
for (i = 0; i < 1000000; i++) {
c[i] = 0;
d[i] = 0;
}
cin >> n >> x >> m;
c[x] = 1;
d[1] = x;
if (n < 1000000) {
... | #include <algorithm>
#include <iostream>
using namespace std;
int main(void) {
long long int n, x, m, ans = 0;
;
int i, j, k, d[1000000], dis, l1, l2;
bool c[1000000];
for (i = 0; i < 1000000; i++) {
c[i] = 0;
d[i] = 0;
}
cin >> n >> x >> m;
c[x] = 1;
d[1] = x;
if (n < 10000000) {
for (... | [["-", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]] | 1 | 363 |
#define LOCAL
#include <bits/stdc++.h>
using namespace std;
#define IOS \
ios::sync_with_stdio(false); \
cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define LLINF... | #define LOCAL
#include <bits/stdc++.h>
using namespace std;
#define IOS \
ios::sync_with_stdio(false); \
cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define LLINF... | [["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13]] | 1 | 1,165 |
#include <bits/stdc++.h>
#include <iostream>
#include <iterator>
#include <math.h>
#include <numeric>
#define ll long long
#define ull long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll, ll>
#define dd long long
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#defin... | #include <bits/stdc++.h>
#include <iostream>
#include <iterator>
#include <math.h>
#include <numeric>
#define ll long long
#define ull long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll, ll>
#define dd long long
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#defin... | [["-", 0, 57, 64, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 17, 18]] | 1 | 366 |
// include
//------------------------------------------
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#in... | // include
//------------------------------------------
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#in... | [["-", 0, 43, 49, 50, 51, 23, 0, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 23, 0, 16, 17, 33]] | 1 | 2,377 |
n,x,m=map(int,input().split())
l=[x]
c=1
d=-1
f=0
while(x>1 and c<n):
g=(x*x)%m
d=g
if(g in l):
f=1
break
l.append(g)
x=g
c+=1
s=sum(l)
if(f==1):
r=l.index(g)
o=(n-c)//(c-r)
t=(n-c)%(c-r)
s+=o*(sum(l[r:]))+sum(l[r:r+t])
print(s)
| n,x,m=map(int,input().split())
l=[x]
c=1
d=-1
f=0
while(x>0 and c<n):
g=(x*x)%m
d=g
if(g in l):
f=1
break
l.append(g)
x=g
c+=1
s=sum(l)
if(f==1):
r=l.index(g)
o=(n-c)//(c-r)
t=(n-c)%(c-r)
s+=o*(sum(l[r:]))+sum(l[r:r+t])
print(s)
| [["-", 0, 52, 15, 23, 0, 679, 31, 666, 0, 612], ["+", 0, 52, 15, 23, 0, 679, 31, 666, 0, 612]] | 5 | 156 |
#include <algorithm>
#include <bits/stdc++.h>
#include <string>
#include <vector>
using namespace std;
vector<string> split(const string &s, char delim) {
vector<string> elems;
string item;
for (char ch : s) {
if (ch == delim) {
if (!item.empty()) {
elems.push_back(item);
}
item.cl... | #include <algorithm>
#include <bits/stdc++.h>
#include <string>
#include <vector>
using namespace std;
vector<string> split(const string &s, char delim) {
vector<string> elems;
string item;
for (char ch : s) {
if (ch == delim) {
if (!item.empty()) {
elems.push_back(item);
}
item.cl... | [["+", 12, 23, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 12, 23, 0, 16, 31, 23, 0, 16, 12, 13], ["+", 31, 23, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 31, 23, 0, 16, 31, 23, 0, 16, 12, 13]] | 1 | 1,387 |
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN = 2E5 + 5;
const int MOD = 998244353;
int n, k;
int l[20], r[20];
LL dp[MAXN], sum[MAXN];
int main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> n >> k;
for (int i = 1; i <= k; i++)
cin >> l[i] >> r[i];... | #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN = 2E5 + 5;
const int MOD = 998244353;
int n, k;
int l[20], r[20];
LL dp[MAXN], sum[MAXN];
int main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> n >> k;
for (int i = 1; i <= k; i++)
cin >> l[i] >> r[i];... | [["+", 8, 7, 8, 9, 0, 57, 64, 9, 0, 46], ["-", 8, 7, 8, 9, 0, 57, 64, 9, 0, 46]] | 1 | 249 |
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <class T, class T2> inline bool chkmax(T &x, const T2 &y) {
return x < y ? x = y, 1 : 0;
}
template <class ... | #include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <class T, class T2> inline bool chkmax(T &x, const T2 &y) {
return x < y ? x = y, 1 : 0;
}
template <class ... | [["+", 0, 16, 12, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 16, 12, 16, 31, 23, 0, 16, 12, 22]] | 1 | 432 |
# 繰り返しの始まり + 繰り返し + 途中で終わった繰り返し分
N,X,M = map(int,input().split())
p = [0] * (M+2)
sum = [0] * (M+2)
p[X] = 1
sum[1] = X
repeat_start = 0
repeat_end = 0
for i in range(2,N+1):
X = (X**2) % M
if p[X] != 0:
repeat_start = p[X]
repeat_end = i
break
else:
sum[i] = sum[i-1] + X
p[X] += i
if repea... | # 繰り返しの始まり + 繰り返し + 途中で終わった繰り返し分
N,X,M = map(int,input().split())
p = [0] * (M+2)
sum = [0] * (M+2)
p[X] = 1
sum[1] = X
repeat_start = 0
repeat_end = 0
for i in range(2,N+1):
X = (X**2) % M
if p[X] != 0:
repeat_start = p[X]
repeat_end = i
break
else:
sum[i] = sum[i-1] + X
p[X] += i
if repea... | [["-", 0, 662, 12, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 662, 12, 652, 3, 4, 0, 657, 12, 22], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 12, 22], ["-", 0, 652, 3, 4, 0, 657, 31, 657, 31, 22], ["+", 0, 652, 3, 4, 0, 657, 31, 657, 31, 22]] | 5 | 178 |
#include <bits/stdc++.h>
using namespace std;
#define repi(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(v) begin(v), end(v)
using ll = long long;
int main() {
// freopen("1.txt", "rb", stdin);
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
ll N;
cin >> N;
... | #include <bits/stdc++.h>
using namespace std;
#define repi(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(v) begin(v), end(v)
using ll = long long;
int main() {
// freopen("1.txt", "rb", stdin);
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
ll N;
cin >> N;
... | [["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 22], ["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 21], ["-", 51, 2, 3, 4, 0, 74, 39, 77, 39, 40], ["+", 51, 2, 3, 4, 0, 74, 39, 77, 39, 78], ["+", 49, 50, 51, 2, 3, 4, 0, 74, 51, 22], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 21]] | 1 | 288 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
ll n, x, m;
cin >> n >> x >> m;
vector<bool> check(m + 1, false);
vector<ll> a;
ll rs;
check[x] = true;
a.push_back(x);
while (1) {
ll f = (x * x) % m;
if (check[f] ==... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
ll n, x, m;
cin >> n >> x >> m;
vector<bool> check(m + 1, false);
vector<ll> a;
ll rs;
check[x] = true;
a.push_back(x);
while (1) {
ll f = (x * x) % m;
if (check[f] ==... | [["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]] | 1 | 343 |
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define hell 998244353
#define PI 3.14159265358979323846
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin>>t;
// int c=0;
while (t--) {
ll n, x, m, i, j;
cin >> n >> x... | #include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define hell 998244353
#define PI 3.14159265358979323846
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin>>t;
// int c=0;
while (t--) {
ll n, x, m, i, j;
cin >> n >> x... | [["+", 8, 9, 0, 52, 8, 9, 0, 57, 0, 121], ["+", 0, 52, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 0, 52, 8, 9, 0, 57, 15, 339, 51, 22], ["+", 0, 52, 8, 9, 0, 57, 15, 339, 0, 25]] | 1 | 378 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0, _n = (int)(n); i < _n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define CLR(t, v) memset(t, (v), sizeof(t))
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &a) {
return os << "(" ... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0, _n = (int)(n); i < _n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define CLR(t, v) memset(t, (v), sizeof(t))
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &a) {
return os << "(" ... | [["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]] | 1 | 542 |
N, X, M = map(int, input().split())
flag = [False for _ in range(M)]
record = list()
record.append(X)
flag[X] = 1
An = X
for i in range(M + 1):
An = pow(An, 2, M)
if flag[An]:
start = flag[An]
cnt = i + 2 - start
cost = record[-1] - record[start - 2] if start > 1 else record[-1]
... | N, X, M = map(int, input().split())
flag = [False for _ in range(M)]
record = list()
record.append(X)
flag[X] = 1
An = X
for i in range(M + 1):
An = pow(An, 2, M)
if flag[An]:
start = flag[An]
cnt = i + 2 - start
cost = record[-1] - record[start - 2] if start > 1 else record[-1]
... | [["-", 75, 76, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 185 |
N,X,M=map(int,input().split())
a=[0]*(M)
A=X%M
a[A]=1
ans=A
Ans=[A]
flag=0
for i in range(N):
A=A*A%M
if A==0:
break
if a[A]==1:
flag=1
break
a[A]=1
ans+=A
Ans.append(A)
if flag==1:
for num in range(len(Ans)):
if A==Ans[num]:
break
n=len(Ans)-n... | N,X,M=map(int,input().split())
a=[0]*(M)
A=X%M
a[A]=1
ans=A
Ans=[A]
flag=0
for i in range(N-1):
A=A*A%M
if A==0:
break
if a[A]==1:
flag=1
break
a[A]=1
ans+=A
Ans.append(A)
if flag==1:
for num in range(len(Ans)):
if A==Ans[num]:
break
n=len(Ans)... | [["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]] | 5 | 195 |
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int main() {
int n, x, m;
cin >> n >> x >> m;
unordered_map<int, int> mp, sum;
int a = 0, b = 0, c = 0;
int i = 0;
while (mp.count(x) == 0) {
mp[x] = i;
b += x;
sum[i] = b;
i++;
x = (x * x) % m;
}
a = sum[mp[x] - 1];... | #include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main() {
int n, x, m;
cin >> n >> x >> m;
unordered_map<int, int> mp, sum;
int a = 0, b = 0, c = 0;
int i = 0;
while (mp.count(x) == 0) {
mp[x] = i;
b += x;
sum[i] = b;
i++;
x = (x * x) % m;
}
a = sum[mp[x] ... | [["-", 36, 36, 36, 36, 0, 30, 0, 58, 141, 22], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 141, 22], ["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40]] | 1 | 199 |
#include <bits/stdc++.h>
#define rep(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define irep(i, a, b) for (ll i = ll(a); i >= ll(b); i--)
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
... | #include <bits/stdc++.h>
#define rep(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define irep(i, a, b) for (ll i = ll(a); i >= ll(b); i--)
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
... | [["-", 0, 52, 15, 339, 51, 16, 12, 16, 17, 19], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 17, 18]] | 1 | 417 |
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, n) for (int i = 1; i < (n); i++)
typedef long long ll;
ll gcd(ll a, ll b) {
if (a < b)
swap(a, b);
if (a % b == ... | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, n) for (int i = 1; i < (n); i++)
typedef long long ll;
ll gcd(ll a, ll b) {
if (a < b)
swap(a, b);
if (a % b == ... | [["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["-", 64, 9, 0, 7, 10, 43, 49, 50, 51, 22], ["+", 64, 9, 0, 7, 10, 43, 49, 50, 51, 22], ["-", 64, 9, 0, 7, 15, 16, 12, 16, 31, 22], ["+", 64, 9, 0, 7, 15, 16, 12, 16, 31, 22]] | 1 | 344 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long N, X, M;
cin >> N >> X >> M;
vector next(60, vector(M, 0L));
auto sum = next;
for (int i = 0; i < M; i++) {
next.at(0).at(i) = i * i % M;
sum.at(0).at(i) = i;
}
for (int i = 0; i + 1 < 60; i++) {
for (int j = 0; j < M; j++) {
... | #include <bits/stdc++.h>
using namespace std;
int main() {
long N, X, M;
cin >> N >> X >> M;
vector next(60, vector(M, 0L));
auto sum = next;
for (int i = 0; i < M; i++) {
next.at(0).at(i) = (long)i * i % M;
sum.at(0).at(i) = i;
}
for (int i = 0; i + 1 < 60; i++) {
for (int j = 0; j < M; j+... | [["+", 0, 11, 12, 16, 31, 16, 31, 74, 0, 24], ["+", 31, 16, 31, 74, 39, 77, 39, 86, 0, 96], ["+", 0, 11, 12, 16, 31, 16, 31, 74, 0, 25]] | 1 | 278 |
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
/*
struct Edge
{
int to;
ll weight;
Edge(int t, ll w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/
using Graph = vector<vector<... | #include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
/*
struct Edge
{
int to;
ll weight;
Edge(int t, ll w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/
using Graph = vector<vector<... | [["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13]] | 1 | 470 |
#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()... | [["-", 0, 57, 75, 76, 0, 9, 0, 43, 39, 40], ["+", 0, 57, 75, 76, 0, 9, 0, 43, 39, 78]] | 1 | 447 |
#include "bits/stdc++.h"
using namespace std;
#define endl "\n"
#define sz(x) (int)(x.size())
#define all(v) v.begin(), v.end()
#define isOdd(n) (n & 1)
#define pow(n, m) (ll) powl(n, m)
#define clr(x, val) memset(x, val, sizeof(x))
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef ve... | #include "bits/stdc++.h"
using namespace std;
#define endl "\n"
#define sz(x) (int)(x.size())
#define all(v) v.begin(), v.end()
#define isOdd(n) (n & 1)
#define pow(n, m) (ll) powl(n, m)
#define clr(x, val) memset(x, val, sizeof(x))
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef ve... | [["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 22], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]] | 1 | 357 |
#include "bits/stdc++.h"
using namespace std;
#define endl "\n"
#define sz(x) (int)(x.size())
#define all(v) v.begin(), v.end()
#define isOdd(n) (n & 1)
#define pow(n, m) (ll) powl(n, m)
#define clr(x, val) memset(x, val, sizeof(x))
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef ve... | #include "bits/stdc++.h"
using namespace std;
#define endl "\n"
#define sz(x) (int)(x.size())
#define all(v) v.begin(), v.end()
#define isOdd(n) (n & 1)
#define pow(n, m) (ll) powl(n, m)
#define clr(x, val) memset(x, val, sizeof(x))
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef ve... | [["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 22]] | 1 | 397 |
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
#define reps(i, s, n) for (int(i) = (s); (i) < (n); (i)++)
#define rep(i, n) reps(i, 0, n)
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi ... | #include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
#define reps(i, s, n) for (long long(i) = (s); (i) < (n); (i)++)
#define rep(i, n) reps(i, 0, n)
using namespace std;
using ll = long long;
using pii = pair<int, int>;
usi... | [["-", 36, 36, 36, 36, 0, 30, 0, 112, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 112, 51, 59], ["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]] | 1 | 332 |
def f(x, m):
return (x ** 2) % m
def main():
n, x, m = map(int, input().split())
lst = [[False, 0] for _ in range((m + 1))]
lst[x] = [True, 1]
res = [x]
loop = 0
for i in range(2, m + 1):
x = f(x, m)
if lst[x][0] == False:
lst[x][0] = True
lst[x][1]... | def f(x, m):
return (x ** 2) % m
def main():
n, x, m = map(int, input().split())
lst = [[False, 0] for _ in range((m + 1))]
lst[x] = [True, 1]
res = [x]
loop = 0
for i in range(2, m + 1):
x = f(x, m)
if lst[x][0] == False:
lst[x][0] = True
lst[x][1]... | [["-", 12, 657, 31, 657, 31, 23, 0, 657, 12, 612], ["+", 12, 657, 31, 657, 31, 23, 0, 657, 12, 22], ["-", 0, 657, 12, 657, 31, 23, 0, 657, 12, 612], ["+", 0, 657, 12, 657, 31, 23, 0, 657, 12, 22]] | 5 | 237 |
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <math.h>
#include <numeric>
#include <sstream>
//---------------------------------------------------------------
#define rep(i, n) for (int i = ... | //---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <math.h>
#include <numeric>
#include <sstream>
//---------------------------------------------------------------
#define rep(i, n) for (int i = ... | [["-", 0, 9, 0, 1, 0, 11, 12, 69, 28, 22], ["+", 0, 9, 0, 1, 0, 11, 12, 69, 28, 22]] | 1 | 456 |
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define speed \
ios_base::sync_with_stdio(0); ... | #include <bits/stdc++.h>
#include <iostream>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define speed \
ios_base::sync_with_stdio(0); ... | [["-", 8, 9, 0, 7, 15, 16, 12, 2, 63, 22], ["-", 0, 7, 15, 16, 12, 2, 3, 4, 0, 24], ["-", 0, 7, 15, 16, 12, 2, 3, 4, 0, 22], ["-", 0, 7, 15, 16, 12, 2, 3, 4, 0, 21], ["-", 0, 7, 15, 16, 12, 2, 3, 4, 0, 25]] | 1 | 492 |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define fo(a, b) for (int a = 0; a < b; a++)
#define Sort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())
#define fi first
#define se second
#define sz size()
#define bgn begin()
#define en end()
#defin... | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define fo(a, b) for (int a = 0; a < b; a++)
#define Sort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())
#define fi first
#define se second
#define sz size()
#define bgn begin()
#define en end()
#defin... | [["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13]] | 1 | 4,269 |
#include <bits/stdc++.h>
#define elif else if
#define ALL(a) a.begin(), a.end()
#define INN(n) \
int n; \
cin >> n;
#define INNVEC(n, a) ... | #include <bits/stdc++.h>
#define elif else if
#define ALL(a) a.begin(), a.end()
#define INN(n) \
int n; \
cin >> n;
#define INNVEC(n, a) ... | [["+", 0, 57, 64, 9, 0, 57, 15, 339, 51, 22], ["+", 0, 57, 64, 9, 0, 57, 15, 339, 0, 25], ["+", 0, 57, 64, 9, 0, 57, 64, 9, 0, 45], ["+", 64, 9, 0, 57, 64, 9, 0, 57, 0, 121], ["+", 0, 57, 64, 9, 0, 57, 15, 339, 0, 24], ["+", 64, 9, 0, 57, 75, 76, 0, 9, 0, 46]] | 1 | 2,474 |
#include <bits/stdc++.h>
//#include "atcoder/all"
typedef long long int ll;
using namespace std;
// using namespace atcoder;
//#define mod 998244353
#define MAXM 100001
ll first[MAXM];
bool used[MAXM];
ll ans[MAXM];
int main() {
ll n, x, m;
cin >> n >> x >> m;
int count = 1; //周期
memset(used, false, sizeof(used... | #include <bits/stdc++.h>
//#include "atcoder/all"
typedef long long int ll;
using namespace std;
// using namespace atcoder;
//#define mod 998244353
#define MAXM 100001
ll first[MAXM];
bool used[MAXM];
ll ans[MAXM];
int main() {
ll n, x, m;
cin >> n >> x >> m;
int count = 1; //周期
memset(used, false, sizeof(used... | [["-", 31, 23, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 31, 23, 0, 16, 31, 23, 0, 16, 17, 72]] | 1 | 266 |
#include <bits/stdc++.h>
using namespace std;
#define gc() getchar()
#define pc(a) putchar(a)
#define int long long
#define inf (1ll << 60)
inline int read() {
int x = 0, f = 1;
char c = gc();
while (c > '9' || c < '0') {
if (c == '-')
f = -f;
c = gc();
}
while (c >= '0' && c <= '9')
x = x *... | #include <bits/stdc++.h>
using namespace std;
#define gc() getchar()
#define pc(a) putchar(a)
#define int long long
#define inf (1ll << 60)
inline int read() {
int x = 0, f = 1;
char c = gc();
while (c > '9' || c < '0') {
if (c == '-')
f = -f;
c = gc();
}
while (c >= '0' && c <= '9')
x = x *... | [["-", 12, 16, 12, 23, 0, 16, 31, 69, 28, 22], ["-", 12, 23, 0, 16, 31, 69, 341, 342, 0, 70], ["-", 0, 16, 31, 69, 341, 342, 0, 16, 31, 22], ["-", 0, 16, 31, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 16, 31, 69, 341, 342, 0, 16, 12, 13], ["-", 12, 23, 0, 16, 31, 69, 341, 342, 0, 73], ["+", 31, 16, 12, 16, 12, 23, 0, 16, 3... | 1 | 424 |
l=input().split()
n=int(l[0])
x=int(l[1])
m=int(l[2])
hashi=dict()
pref=0
count=0
prefix=[]
for i in range(n):
if(i==0):
ans=x%m
else:
ans=ans*ans
ans%=m
if(ans in hashi):
period=i-(hashi[ans][0])
num1=hashi[ans][0]
k=(n-num1)//period
rem=(n-(num1+k*pe... | l=input().split()
n=int(l[0])
x=int(l[1])
m=int(l[2])
hashi=dict()
pref=0
count=0
prefix=[]
for i in range(n):
if(i==0):
ans=x%m
else:
ans=ans*ans
ans%=m
if(ans in hashi):
period=i-(hashi[ans][0])
num1=hashi[ans][0]
k=(n-num1)//period
rem=(n-(num1+k*pe... | [["-", 0, 1, 0, 662, 12, 657, 12, 206, 206, 22], ["+", 0, 1, 0, 662, 12, 657, 12, 206, 206, 22]] | 5 | 212 |
import copy
n, x, m = map(int,input().split())
visited = [-1]*(m+1)
when = [-1]*(m+1)
ans = 0
i = 1
while i <= n:
ans += x
if x == 0:
break
if visited[x] > -1:
cycle = (n - i) // (i - when[x])
ans += cycle*(ans - visited[x])
i += cycle*(i - when[x])
visited = [-1]*(... | import copy
n, x, m = map(int,input().split())
visited = [-1]*(m+1)
when = [-1]*(m+1)
ans = 0
i = 1
while i <= n:
ans += x
if x == 0:
break
if visited[x] > -1:
cycle = (n - i) // (i - when[x])
ans += cycle*(ans - visited[x])
i += cycle*(i - when[x]) + 1
visited = [-... | [["+", 64, 196, 0, 1, 0, 677, 12, 657, 17, 72], ["+", 64, 196, 0, 1, 0, 677, 12, 657, 12, 612]] | 5 | 179 |
#include <algorithm>
#include <chrono>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fastInp ... | #include <algorithm>
#include <chrono>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fastInp ... | [["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]] | 1 | 451 |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
//定数
//円周率
const double pi = 3.141592653589793238462643383279;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 100000000000000000; // = 10^17
// ABC文字列
const string ABC = "ABCDEFGHIJ... | #include <bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
//定数
//円周率
const double pi = 3.141592653589793238462643383279;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 100000000000000000; // = 10^17
// ABC文字列
const string ABC = "ABCDEFGHIJ... | [["-", 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, 31, 22], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 31, 22], ["-", 0, 14, 8, 9, 0, 7, 10, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 7, 10, 43, 39, 78], ["+", 0, 16, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 16, ... | 1 | 938 |
#include <bits/stdc++.h>
using namespace std;
template <class T> void ckmin(T &a, T b) { a = min(a, b); }
template <class T> void ckmax(T &a, T b) { a = max(a, b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#defin... | #include <bits/stdc++.h>
using namespace std;
template <class T> void ckmin(T &a, T b) { a = min(a, b); }
template <class T> void ckmax(T &a, T b) { a = max(a, b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#defin... | [["-", 0, 57, 64, 1, 0, 16, 12, 69, 28, 22], ["+", 0, 57, 64, 1, 0, 16, 12, 69, 28, 22]] | 1 | 770 |
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#inc... | #include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#inc... | [["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]] | 1 | 710 |
#n = int(input())
#n,m = map (int,input().split())
#a = list(map (int,input().split()))
n,x,m = map (int,input().split())
next=[0] * (m+1)
memo = [-1] * (m+1)
memo[x] = 0
a = 0
now = x
unti = [x]
flag = True
b = -1
for i in range(m):
next[now] = (now **2) % m
#print(1,next)
if memo[next[now]]!=-1:
... | n,x,m = map (int,input().split())
next=[0] * (m+1)
memo = [-1] * (m+1)
memo[x] = 0
a = 0
now = x
unti = [x]
flag = True
b = -1
for i in range(m):
next[now] = (now **2) % m
#print(1,next)
if memo[next[now]]!=-1:
b = memo[next[now]]
break
elif next[now] == 0:
flag =False
b... | [["+", 12, 652, 3, 4, 0, 206, 206, 663, 0, 22], ["+", 3, 4, 0, 206, 206, 663, 0, 657, 31, 22], ["+", 3, 4, 0, 206, 206, 663, 0, 657, 17, 72]] | 5 | 388 |
N, X, M = map(int, input().split())
rec = []
s = set()
rec.append(X)
s.add(X)
r = X
idx = -1
idx1 = -1
for i in range(N+1):
r = (r**2)%M
if(r not in s):
rec.append(r)
s.add(r)
else:
rec.append(r)
idx = i+1
break
for i in range(len(rec)):
if(rec[i] == rec[idx... | N, X, M = map(int, input().split())
rec = []
s = set()
rec.append(X)
s.add(X)
r = X
idx = -1
idx1 = -1
for i in range(N+1):
r = (r**2)%M
if(r not in s):
rec.append(r)
s.add(r)
else:
rec.append(r)
idx = i+1
break
for i in range(len(rec)):
if(rec[i] == rec[idx... | [["-", 0, 656, 0, 57, 15, 23, 0, 679, 17, 355], ["+", 0, 656, 0, 57, 15, 23, 0, 679, 17, 354], ["+", 3, 4, 0, 652, 3, 4, 0, 206, 0, 70], ["+", 0, 652, 3, 4, 0, 206, 206, 663, 0, 102], ["+", 0, 652, 3, 4, 0, 206, 206, 663, 0, 22], ["+", 3, 4, 0, 652, 3, 4, 0, 206, 0, 73]] | 5 | 249 |
// why tle lol
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef complex<double> pnt;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, pii> pp;
typedef double ld;
typedef long double lld;
#define ... | // why tle lol
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef complex<double> pnt;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, pii> pp;
typedef double ld;
typedef long double lld;
#define ... | [["-", 0, 14, 8, 9, 0, 52, 15, 339, 51, 13], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 12, 13]] | 1 | 612 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
constexpr ll mod = 1000000007;
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll, ll>>
#define VVL vector<vector<ll>>
#define ... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
constexpr ll mod = 1000000007;
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll, ll>>
#define VVL vector<vector<ll>>
#define ... | [["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 21], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13]] | 1 | 377 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;
#define reps(i, s, n) for (int i = s; i < n; i++)
#define rep(i, n) reps(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((ll)(x).size())
const double PI = acos(-1.0);
const ll INF = 1e18 +... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;
#define reps(i, s, n) for (int i = s; i < n; i++)
#define rep(i, n) reps(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((ll)(x).size())
const double PI = acos(-1.0);
const ll INF = 1e18 +... | [["+", 3, 4, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 3, 4, 0, 16, 31, 23, 0, 16, 12, 22]] | 1 | 484 |
import sys
import re
import random
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)
# input aliases
input = sys.stdin.readline
getS = la... | import sys
import re
import random
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)
# input aliases
input = sys.stdin.readline
getS = la... | [["-", 64, 196, 0, 1, 0, 662, 12, 657, 17, 33], ["-", 64, 196, 0, 1, 0, 662, 12, 657, 12, 22]] | 5 | 348 |
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
pub... | import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
pub... | [["+", 51, 227, 497, 505, 0, 16, 31, 16, 31, 499], ["+", 51, 227, 497, 505, 0, 16, 31, 16, 17, 48], ["-", 8, 196, 0, 1, 0, 492, 3, 4, 0, 499], ["+", 8, 196, 0, 1, 0, 492, 3, 4, 0, 499]] | 3 | 1,094 |
n,x,m=map(int,input().split())
p=[x]
A=set([x])
f=0
for i in range(n-1):
p.append(p[-1]**2%m)
if p[-1] in A:
f=1
break
else:
A.add(p[-1])
if f==0:
print(sum(p))
else:
for i in range(len(p)):
if p[i]==p[-1]:
loop=len(p)-i-1
break
SUM=sum(p[i:-1])
ans=sum(p)
n-=len(p)-1
ans+=SUM*(n//loop)+sum(p[i:i... | n,x,m=map(int,input().split())
p=[x]
A=set([x])
f=0
for i in range(n-1):
p.append(p[-1]**2%m)
if p[-1] in A:
f=1
break
else:
A.add(p[-1])
if f==0:
print(sum(p))
else:
for i in range(len(p)):
if p[i]==p[-1]:
loop=len(p)-i-1
break
SUM=sum(p[i:-1])
ans=sum(p)-p[-1]
n-=len(p)-1
ans+=SUM*(n//loop)+sum... | [["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 33], ["+", 0, 1, 0, 662, 12, 657, 12, 206, 51, 22], ["+", 0, 1, 0, 662, 12, 657, 12, 206, 0, 70], ["+", 0, 662, 12, 657, 12, 206, 206, 664, 17, 33], ["+", 0, 662, 12, 657, 12, 206, 206, 664, 28, 612], ["+", 0, 1, 0, 662, 12, 657, 12, 206, 0, 73]] | 5 | 184 |
n,x,m=map(int,input().split())
cnt2=set()
cnt2.add(x)
cnt3=[x]
cnt4=0
cnt5=0
cnt6=x
for i in range(1,m+10):
num2=pow(cnt6,2,m)
if num2 in cnt2:
for j in range(len(cnt3)):
if cnt3[j]==num2:
cnt7=j
break
cnt10=len(cnt3)-cnt7
num4=sum(cnt3[:cnt7])... | n,x,m=map(int,input().split())
cnt2=set()
cnt2.add(x)
cnt3=[x]
cnt4=0
cnt5=0
cnt6=x
for i in range(1,m+10):
num2=pow(cnt6,2,m)
if num2 in cnt2:
for j in range(len(cnt3)):
if cnt3[j]==num2:
cnt7=j
break
cnt10=len(cnt3)-cnt7
num4=sum(cnt3[:cnt7])... | [["+", 36, 36, 0, 656, 0, 57, 15, 679, 17, 355], ["+", 0, 656, 0, 57, 15, 679, 12, 666, 0, 22], ["+", 0, 656, 0, 57, 15, 679, 12, 666, 667, 47]] | 5 | 211 |
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;
int main() {
ll N, X, M;
cin >> N >> X >> M;
ll A = X;
int s = -1, t = -1;
vector<ll> sums(M + 1, 0);
vector<int> index(M + 1... | #include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;
int main() {
ll N, X, M;
cin >> N >> X >> M;
ll A = X;
int s = -1, t = -1;
vector<ll> sums(M + 1, 0);
vector<int> index(M + 1... | [["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["-", 12, 16, 12, 23, 0, 41, 15, 16, 17, 47], ["+", 12, 16, 12, 23, 0, 41, 15, 16, 17, 20]] | 1 | 346 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll f(ll n, ll x, ll m) {
ll ref = x;
ll now = x * x % m;
int cnt = 1;
vector<ll> d(m + 1);
d[0] = 0;
while (now != x) {
d[cnt] = ref;
ref += now;
now = now * now % m;
++cnt;
}
ref = n / cnt * ref + d[n % cnt];
return ... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll f(ll n, ll x, ll m) {
ll ref = x;
ll now = x * x % m;
int cnt = 1;
vector<ll> d(m + 1);
d[0] = 0;
while (now != x) {
d[cnt] = ref;
ref += now;
now = now * now % m;
++cnt;
}
ref = n / cnt * ref + d[n % cnt];
return ... | [["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78]] | 1 | 212 |
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
template <typename T> void print_vec(const vector<T> &v) {
int n = v.size();
for (int i = 0; i < n; ++i) {
if (i > 0)
... | #include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
template <typename T> void print_vec(const vector<T> &v) {
int n = v.size();
for (int i = 0; i < n; ++i) {
if (i > 0)
... | [["+", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13], ["-", 8, 9, 0, 1, 0, 11, 31, 69, 28, 22], ["+", 8, 9, 0, 1, 0, 11, 31, 69, 28, 22]] | 1 | 399 |
#pragma region Macros
#pragma GCC optimize("O3")
#pragma GCC target("avx2,avx")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for (ll i = a; i <= b; ++i)
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i ... | #pragma region Macros
#pragma GCC optimize("O3")
#pragma GCC target("avx2,avx")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for (ll i = a; i <= b; ++i)
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i ... | [["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]] | 1 | 2,713 |
n,x,m = map(int,input().split())
if x == 1:
print(n)
u = [0 for _ in range(m)]
rs = [0 for _ in range(m+1)]
s = x
u[x] = 1
rs[1] = x
i = 2
while True:
x = (x*x)%m
if u[x] == 0:
u[x] = i
s += x
rs[i] = s
i += 1
else:
ls = u[x]
le = i-1
break
if n <= le:
print(rs[n])
exit()
ans = r... | n,x,m = map(int,input().split())
if x == 1:
print(n)
exit()
u = [0 for _ in range(m)]
rs = [0 for _ in range(m+1)]
s = x
u[x] = 1
rs[1] = x
i = 2
while True:
x = (x*x)%m
if u[x] == 0:
u[x] = i
s += x
rs[i] = s
i += 1
else:
ls = u[x]
le = i-1
break
if n <= le:
print(rs[n])
exit(... | [["+", 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 | 209 |
from collections import deque
N,X,M = map(int, input().split())
nodeset = set()
nodeset.add(X)
nodeq = deque()
nodeq.append(X)
is_finish = False
s,e = 0, N
for i in range(N):
X = (X*X) % M
if X in nodeset:
is_finish = True
for p, start in enumerate(nodeq):
if X == start:
... | from collections import deque
N,X,M = map(int, input().split())
nodeset = set()
nodeset.add(X)
nodeq = deque()
nodeq.append(X)
is_finish = False
s,e = 0, N
for i in range(N-1):
X = (X*X) % M
if X in nodeset:
is_finish = True
for p, start in enumerate(nodeq):
if X == start... | [["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]] | 5 | 200 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll N, X, M;
cin >> N >> X >> M;
vector<int> hoge(M);
vector<ll> sum = {0};
ll x = X;
int s, t;
for (int i = 1;; ++i) {
sum.push_back(sum.back() + x);
if (hoge[x]) {
s = hoge[x];
t = i;
break;
}
... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll N, X, M;
cin >> N >> X >> M;
vector<int> hoge(M);
vector<ll> sum = {0};
ll x = X;
int s, t;
for (int i = 1;; ++i) {
sum.push_back(sum.back() + x);
if (hoge[x]) {
s = hoge[x];
t = i;
break;
}
... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]] | 1 | 236 |
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#define int long long
#define N 200010
using namespace std;
inline int read() {
int neg = 1, num = 0;
char c = getchar();
for (; !isdigit(c); c = getchar())
if (c == '-')
neg = ... | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#define int long long
#define N 200010
using namespace std;
inline int read() {
int neg = 1, num = 0;
char c = getchar();
for (; !isdigit(c); c = getchar())
if (c == '-')
neg = ... | [["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22]] | 1 | 395 |
#include <algorithm>
#include <cmath>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
long long mod = 998244353;
int main() {
long lo... | #include <algorithm>
#include <cmath>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
long long mod = 998244353;
int main() {
long lo... | [["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 72], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 22]] | 1 | 342 |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, m, n) for (int i = (m); i < (n); i++)
#define rep(i, n) REP(i, 0, n)
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(c) (c).rbegin(), (c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define ma... | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, m, n) for (int i = (m); i < (n); i++)
#define rep(i, n) REP(i, 0, n)
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(c) (c).rbegin(), (c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define ma... | [["-", 8, 9, 0, 57, 64, 1, 0, 11, 17, 107], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 17, 32], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 31, 22], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 31, 22], ["-", 0, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 0, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 0, 9, ... | 1 | 365 |
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
imp... | import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
imp... | [["-", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 0, 195, 8, 196, 0, 1, 0, 11, 17, 107], ["-", 0, 195, 8, 196, 0, 1, 0, 11, 12, 22], ["-", 8, 498, 0, 195, 8, 196, 0, 1, 0, 35]] | 3 | 857 |
#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
#define pb push_back
#define ll long long int
#define pll pair<ll, ll>
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n, x, m;
cin >> n >> x >> m;
ll ans = 0;
if (n <= m) {
for (in... | #include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
#define pb push_back
#define ll long long int
#define pll pair<ll, ll>
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n, x, m;
cin >> n >> x >> m;
ll ans = 0;
if (n <= m) {
for (in... | [["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 72], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22]] | 1 | 259 |
n, x, m = [int(e) for e in input().split()]
s = set()
l = []
a = x % m
total = a
for i in range(1, n):
a = (a * a) % m
if a == 0:
break
if a in s:
r = n - i
p = l.index(a)
lo_total = 0
for j in range(p, len(l)):
lo_total += l[j]
tot... | n, x, m = [int(e) for e in input().split()]
s = set()
l = []
a = x % m
total = a
for i in range(1, n):
a = (a * a) % m
if a == 0:
break
if a in s:
r = n - i
p = l.index(a)
lo_total = 0
for j in range(p, len(l)):
lo_total += l[j]
tot... | [["-", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107], ["+", 0, 1, 0, 677, 12, 657, 12, 23, 0, 24], ["+", 12, 657, 12, 23, 0, 657, 12, 23, 0, 25]] | 5 | 166 |
#include <iostream>
#include <vector>
using namespace std;
int main() {
long long N, X, M;
cin >> N >> X >> M;
vector<bool> appeared(M, false);
long long ans = 0;
vector<long long> A;
for (long long i = 0; i < N; ++i) {
ans += X;
A.push_back(X);
appeared[X] = true;
X = (X * X) % M;
if (... | #include <iostream>
#include <vector>
using namespace std;
int main() {
long long N, X, M;
cin >> N >> X >> M;
vector<bool> appeared(M, false);
long long ans = 0;
vector<long long> A;
for (long long i = 0; i < N; ++i) {
ans += X;
A.push_back(X);
appeared[X] = true;
X = (X * X) % M;
if (... | [["+", 49, 50, 51, 16, 31, 23, 0, 16, 17, 33], ["+", 49, 50, 51, 16, 31, 23, 0, 16, 12, 13]] | 1 | 209 |
#include <bits/stdc++.h>
using namespace std;
#define LL long long
const int Maxn = 100010;
const int inf = 2147483647;
LL read() {
LL x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
x = x * 10ll + ch -... | #include <bits/stdc++.h>
using namespace std;
#define LL long long
const int Maxn = 100010;
const int inf = 2147483647;
LL read() {
LL x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
x = x * 10ll + ch -... | [["+", 0, 14, 8, 9, 0, 7, 15, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]] | 1 | 359 |
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll n, x, m;
cin >> n >> x >> m;
if (m == 0 || x == 0)
return cout << 0, 0;
ll ans = 0;
ll a = x % m;
vector<ll> v;
set<ll> s;
while (n > 0) {
if (s.f... | #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll n, x, m;
cin >> n >> x >> m;
if (m == 0 || x == 0)
return cout << 0, 0;
ll ans = 0;
ll a = x % m;
vector<ll> v;
set<ll> s;
while (n > 0) {
if (s.f... | [["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]] | 1 | 302 |
#include <bits/stdc++.h>
#define IOS \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0)
#define max(a, b) (a > b ? a : b)
#def... | #include <bits/stdc++.h>
#define IOS \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0)
#define max(a, b) (a > b ? a : b)
#def... | [["+", 0, 14, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 27, 17, 68], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]] | 1 | 339 |
#include <iostream>
#include <set>
using namespace std;
typedef long long ll;
int main() {
ll n;
int q;
cin >> n >> q;
set<ll> st1, st2;
st1.insert(n);
st2.insert(n);
ll c1[100005]{0}, c2[100005]{0};
ll ans = (n - 2) * (n - 2);
while (q--) {
int c;
ll x;
cin >> c >> x;
if (c == 1) {
... | #include <iostream>
#include <set>
using namespace std;
typedef long long ll;
int main() {
ll n;
int q;
cin >> n >> q;
set<ll> st1, st2;
st1.insert(n);
st2.insert(n);
ll c1[200005]{0}, c2[200005]{0};
ll ans = (n - 2) * (n - 2);
while (q--) {
int c;
ll x;
cin >> c >> x;
if (c == 1) {
... | [["-", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13]] | 1 | 241 |
n,x,m=map(int,input().split())
r=[]
s=set()
ans=x
a=x
for i in range(n-1):
b=a*a%m
if b in s:
j = r.index(b)
N = n-j
T = i-j
S = sum(r[j:i])
ans += N//T*S
N %= T
ans += sum(r[j:j+N])
break
else:
ans+=b
s.add(b)
r.append(... | n,x,m=map(int,input().split())
r=[]
s=set()
ans=x
a=x
for i in range(n-1):
b=a*a%m
if b in s:
j = r.index(b)
N = n-1-i
T = i-j
S = sum(r[j:])
ans += N//T*S
N %= T
ans += sum(r[j:j+N])
break
else:
ans+=b
s.add(b)
r.append... | [["-", 64, 196, 0, 1, 0, 662, 12, 657, 12, 22], ["+", 0, 1, 0, 662, 12, 657, 31, 657, 12, 612], ["+", 64, 196, 0, 1, 0, 662, 12, 657, 17, 33], ["+", 64, 196, 0, 1, 0, 662, 12, 657, 12, 22], ["-", 12, 652, 3, 4, 0, 206, 206, 663, 0, 22]] | 5 | 132 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.