s_id
stringlengths
10
10
p_id
stringlengths
6
6
u_id
stringlengths
10
10
date
stringlengths
10
10
language
stringclasses
1 value
original_language
stringclasses
11 values
filename_ext
stringclasses
1 value
status
stringclasses
1 value
cpu_time
stringlengths
1
5
memory
stringlengths
1
7
code_size
stringlengths
1
6
code
stringlengths
1
539k
s312055747
p02550
u607155447
1600550879
Python
Python (3.8.2)
py
Runtime Error
55
11568
423
N, X, M = map(int, input().split()) ans = 0 chck = 0 flag = [0]*(10**5 +1) lst = [X] for i in range(N): X = (X**2)%M if flag[X] == 1: break flag[X] = 1 lst.append(X) preindex = lst.index(X) preloop = lst[:index] loop = lst[index:] loopnum = (N - len(preloop))//len(loop) loopafternum = (N ...
s635458801
p02550
u410558877
1600550851
Python
Python (3.8.2)
py
Runtime Error
2206
9660
737
def main(): N, X, M = map(int, input().split()) ans = X tmp = X ary = [] for i in range(1, N): tmp = tmp**2 % M if ary.count(tmp) == 1: ans = ans + tmp break else: ary.append(tmp) ans = ans + tmp if i < N: tmpsum...
s621262106
p02550
u410558877
1600550675
Python
Python (3.8.2)
py
Runtime Error
2206
9568
667
def main(): N, X, M = map(int, input().split()) ans = X tmp = X ary = [] for i in range(1, N): tmp = tmp**2 % M if ary.count(tmp) == 1: ans = ans + tmp break else: ary.append(tmp) ans = ans + tmp tmpsum = 0 tmpcnt = ...
s647825366
p02550
u410558877
1600550474
Python
Python (3.8.2)
py
Runtime Error
2206
9788
659
def main(): N, X, M = map(int, input().split()) ans = X tmp = X ary = [] for i in range(1, N): tmp = tmp**2 % M if ary.count(tmp) == 1: break else: ary.append(tmp) ans = ans + tmp tmpsum = 0 tmpcnt = 0 for j in reversed(ary)...
s389992647
p02550
u628285938
1600550449
Python
Python (3.8.2)
py
Runtime Error
76
21204
841
# -*- coding: utf-8 -*- """ Created on Sat Sep 19 22:03:19 2020 @author: liang """ N, X, M = map(int,input().split()) mod_set = {X} mod_lis = [X] A = [0]*(10**6+1) A[0] = X flag = False #for i in range(1,N): for i in range(1,min(10**6,N)): tmp = A[i-1]**2%M if tmp in mod_set: flag = True break...
s095125658
p02550
u628285938
1600550381
Python
Python (3.8.2)
py
Runtime Error
71
21388
842
# -*- coding: utf-8 -*- """ Created on Sat Sep 19 22:03:19 2020 @author: liang """ N, X, M = map(int,input().split()) mod_set = {X} mod_lis = [X] A = [0]*(10**6+1) A[0] = X flag = False #for i in range(1,N): for i in range(1,min(10**6,N)): tmp = A[i-1]**2%M if tmp in mod_set: flag = True break...
s714937333
p02550
u106118504
1600550238
Python
PyPy3 (7.3.0)
py
Runtime Error
796
70060
331
N ,X, M = map(int,input().split()) L = [X] A = X for i in range(N-1): A = A**2 % M if A in L: x = L.index(A) break else: L.append(A) if 0 in L: if N <= len(L): print(sum(L[:N])) else: print(sum(L)) else: ans = sum(L[:x]) + ((N) // (len(L)-x))* sum(L[x:]) + sum(L[x:((N)%((len(L)-x)))]) ...
s414962845
p02550
u156815136
1600550229
Python
Python (3.8.2)
py
Runtime Error
63
15616
1852
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from math import gcd from itertools import combinations,permutations,accumulate, product # (string,3) 3回 #from collections import deque from collections import deque,defaultdict,Counter ...
s806672331
p02550
u628285938
1600550203
Python
Python (3.8.2)
py
Runtime Error
80
21272
780
# -*- coding: utf-8 -*- """ Created on Sat Sep 19 22:03:19 2020 @author: liang """ N, X, M = map(int,input().split()) mod_set = {X} mod_lis = [X] A = [0]*(10**6+1) A[0] = X #for i in range(1,N): for i in range(1,min(10**6,N)): tmp = A[i-1]**2%M if tmp in mod_set: break A[i] = tmp mod_set.add(t...
s968719313
p02550
u988402778
1600550156
Python
PyPy3 (7.3.0)
py
Runtime Error
218
74432
26867
def main(sample_file = ''): """ convenient functions # for i, a in enumerate(iterable) # q, mod = divmod(a, b) # divmod(x, y) returns the tuple (x//y, x%y) # Higher-order function: reduce(operator.mul, xyz_count, 1) # manage median(s) using two heapq https://atcoder.jp/contests/abc127/tasks/abc...
s928932995
p02550
u410558877
1600550141
Python
Python (3.8.2)
py
Runtime Error
2206
9800
639
def main(): N, X, M = map(int, input().split()) ans = X tmp = X ary = [] for i in range(1, N): tmp = tmp**2 % M if ary.count(tmp) == 1: break else: ary.append(tmp) ans = ans + tmp tmpsum = 0 tmpcnt = 0 for j in reversed(ary)...
s828955884
p02550
u628285938
1600550108
Python
Python (3.8.2)
py
Runtime Error
70
14116
746
# -*- coding: utf-8 -*- """ Created on Sat Sep 19 22:03:19 2020 @author: liang """ N, X, M = map(int,input().split()) mod_set = {X} mod_lis = [X] A = [0]*(10**5+1) A[0] = X for i in range(1,N): tmp = A[i-1]**2%M if tmp in mod_set: break A[i] = tmp mod_set.add(tmp) mod_lis.append(tmp) j = ...
s761608406
p02550
u222668979
1600550068
Python
PyPy3 (7.3.0)
py
Runtime Error
100
79720
311
n, x, m = map(int, input().split()) lst, num, frag = set(), [], False for i in range(1, n + 1): lst.add(x), num.append(x) x = x ** 2 % m if x in lst: flag = True break ans = sum(num) if flag: cnt, idx = i, num.index(x) div, mod = divmod(n - cnt, len(num) - idx) print(ans)
s725736895
p02550
u222668979
1600550048
Python
PyPy3 (7.3.0)
py
Runtime Error
94
77124
343
n, x, m = map(int, input().split()) lst, num, frag = set(), [], False for i in range(1, n + 1): lst.add(x), num.append(x) x = x ** 2 % m if x in lst: flag = True break ans = sum(num) if flag: cnt, idx = i, num.index(x) div, mod = divmod(n - cnt, len(num) - idx) ans += sum(num[i...
s028062170
p02550
u630554891
1600549971
Python
Python (3.8.2)
py
Runtime Error
56
12344
438
import math n,x,m=map(int, input().split()) a = x ans = a l=[a] flg=[0]*m for i in range(1,m): tmp=(a*a)%m a=tmp ans+=tmp if flg[a]==1: lp = l.index(a) break else: l.append(a) flg[a]=1 if lp != 0: l2 = l[lp:] tmp = sum(l2) b=math.floor((n-len(l))/len(l2...
s887061781
p02550
u156815136
1600549959
Python
Python (3.8.2)
py
Runtime Error
62
15584
1782
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from math import gcd from itertools import combinations,permutations,accumulate, product # (string,3) 3回 #from collections import deque from collections import deque,defaultdict,Counter ...
s367586553
p02550
u156815136
1600549885
Python
Python (3.8.2)
py
Runtime Error
71
15476
1803
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from math import gcd from itertools import combinations,permutations,accumulate, product # (string,3) 3回 #from collections import deque from collections import deque,defaultdict,Counter ...
s978211682
p02550
u632395989
1600549851
Python
Python (3.8.2)
py
Runtime Error
2206
9744
559
N, X, M = map(int, input().split()) A = [X] pattern_stard_id = N for i in range(1, N): X = (X ** 2) % M # print(X) if X in A: pattern_start_id = A.index(X) break else: A.append(X) before_pattern = A[:pattern_start_id] before_pattern_len = len(before_pattern) pattern = A[pattern...
s732389411
p02550
u733866054
1600549705
Python
Python (3.8.2)
py
Runtime Error
2206
9480
292
n,x,m=map(int,input().split()) s=[x] A=x for i in range(n) : a=A**2%m if a in s : y=s.index(a) break else : s.append(a) A=a count=len(s) bount=count-y cnt=(n-count)//bount tnt=(n-count)%bount ans=sum(s)+sum(s[y:])*cnt+sum(s[y:y+tnt]) print(ans)
s861527709
p02550
u156815136
1600549565
Python
Python (3.8.2)
py
Runtime Error
67
15488
1747
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from math import gcd from itertools import combinations,permutations,accumulate, product # (string,3) 3回 #from collections import deque from collections import deque,defaultdict,Counter ...
s780872143
p02550
u988402778
1600549546
Python
PyPy3 (7.3.0)
py
Runtime Error
427
74360
26843
def main(sample_file = ''): """ convenient functions # for i, a in enumerate(iterable) # q, mod = divmod(a, b) # divmod(x, y) returns the tuple (x//y, x%y) # Higher-order function: reduce(operator.mul, xyz_count, 1) # manage median(s) using two heapq https://atcoder.jp/contests/abc127/tasks/abc...
s660029882
p02550
u156815136
1600549493
Python
Python (3.8.2)
py
Runtime Error
71
15540
1748
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from math import gcd from itertools import combinations,permutations,accumulate, product # (string,3) 3回 #from collections import deque from collections import deque,defaultdict,Counter ...
s990344460
p02550
u156815136
1600549480
Python
PyPy3 (7.3.0)
py
Runtime Error
581
83076
1748
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from math import gcd from itertools import combinations,permutations,accumulate, product # (string,3) 3回 #from collections import deque from collections import deque,defaultdict,Counter ...
s201172389
p02550
u892305365
1600549416
Python
PyPy3 (7.3.0)
py
Runtime Error
84
74632
724
N, X, M = list(map(int, input().split())) res = X remainder_list = set([X % M]) remainder_loop = [] a_part = [] flg = False a = X for i in range(N - 1): a = a ** 2 % M res += a res_trig = a if a in remainder_list: loop_length = 0 loop_sum = [] while True: a = a *...
s406837111
p02550
u431573188
1600549403
Python
PyPy3 (7.3.0)
py
Runtime Error
82
71284
443
N, X, M = map(int, input().split()) table = [0]*(M+1) pre = X table[pre] = 1 seq = [pre] cnt = 0 while True: cnt += 1 A = pre**2%M if not table[A]: seq.append(A) table[A] = cnt pre = A else: fir = table[A] sec = cnt break ans = 0 for i in range(fir +...
s579171996
p02550
u564260910
1600549402
Python
Python (3.8.2)
py
Runtime Error
591
47408
218
""" abc179_E """ n, x, m = map(int,input().split()) a = [x] + [0]*(n-1) sum = 0 for i in range (0,n-1): a[i+1] = (a[i]**2) % m sum += a[i] if a[i+1] == 0: break else: sum += a[n-1] print(sum)
s293549080
p02550
u684814987
1600549395
Python
Python (3.8.2)
py
Runtime Error
55
13508
510
def main(): n, x, m = map(int, input().split()) mflg = [0] + [-1] * (m-1) ltot = [x] tot = x a = x for i in range(1, n): a = a ** 2 % m if mflg[a-1] >= 0: z = (n - i) // (i - mflg[a-1]) - 1 y = (n - j) % (i - mflg[a-1]) tot += (ltot[mflg[a-1...
s429244771
p02550
u222668979
1600549382
Python
PyPy3 (7.3.0)
py
Runtime Error
151
77260
377
n, x, m = map(int, input().split()) lst, num, frag = set(), [], False for i in range(1, n + 1): lst.add(x), num.append(x) x = x ** 2 % m if x in lst: flag = True break ans = sum(num) if flag: cnt, idx = i, num.index(x) div, mod = divmod(n - cnt, len(num) - idx) ans += sum(num[i...
s172080829
p02550
u811817592
1600549374
Python
Python (3.8.2)
py
Runtime Error
76
12436
932
# -*- coding: utf-8 -*- N, X, M = map(int, input().split()) mod_check_list = [False for _ in range(M)] mod_list = [(X ** 2) % M] counter = 1 mod_sum = (X ** 2) % M last_mod = 0 for i in range(M): now_mod = (mod_list[-1] ** 2) % M if mod_check_list[now_mod]: last_mod = now_mod break mod_chec...
s232142812
p02550
u431573188
1600549336
Python
PyPy3 (7.3.0)
py
Runtime Error
77
71368
441
N, X, M = map(int, input().split()) table = [0]*M pre = X%M table[pre] = 1 seq = [pre] cnt = 0 while True: cnt += 1 A = pre**2%M if not table[A]: seq.append(A) table[A] = cnt pre = A else: fir = table[A] sec = cnt break ans = 0 for i in range(fir + (...
s608576634
p02550
u334712262
1600549328
Python
PyPy3 (7.3.0)
py
Runtime Error
284
83564
4314
# -*- coding: utf-8 -*- import bisect import heapq import math import random from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from fractions import Fraction from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacem...
s578937851
p02550
u431573188
1600549245
Python
PyPy3 (7.3.0)
py
Runtime Error
85
71336
435
N, X, M = map(int, input().split()) table = [0]*M table[X] = 1 pre = X seq = [X] cnt = 0 while True: cnt += 1 A = pre**2%M if not table[A]: seq.append(A) table[A] = cnt pre = A else: fir = table[A] sec = cnt break ans = 0 for i in range(fir + (N-fir)...
s428009751
p02550
u811817592
1600549169
Python
Python (3.8.2)
py
Runtime Error
65
12376
909
# -*- coding: utf-8 -*- N, X, M = map(int, input().split()) mod_check_list = [False for _ in range(M)] mod_list = [(X ** 2) % M] counter = 1 mod_sum = (X ** 2) % M last_mod = 0 for i in range(M): now_mod = (mod_list[-1] ** 2) % M if mod_check_list[now_mod]: last_mod = now_mod break mod_chec...
s545801046
p02550
u564260910
1600549144
Python
Python (3.8.2)
py
Runtime Error
498
47472
184
""" abc179_E """ n, x, m = map(int,input().split()) a = [x] + [0]*(n-1) sum = 0 for i in range (0,n-1): a[i+1] = (a[i]**2) % m sum += a[i] else: sum += a[n-1] print(sum)
s020106999
p02550
u222668979
1600549136
Python
PyPy3 (7.3.0)
py
Runtime Error
99
79496
375
n, x, m = map(int, input().split()) lst, num, frag = set(), [], 0 for i in range(1, n + 1): lst.add(x), num.append(x) x = x ** 2 % m if x in lst: flag = 1 break ans = sum(num) if flag == 1: cnt, idx = i, num.index(x) div, mod = divmod(n - cnt, len(num) - idx) ans = sum(num[idx:...
s779789673
p02550
u021814034
1600549133
Python
PyPy2 (7.3.0)
py
Runtime Error
629
99904
6989
from __future__ import division, print_function # import threading # threading.stack_size(2**27) # import sys # sys.setrecursionlimit(10**7) import sys from sys import stdin, stdout import bisect #c++ upperbound import math import heapq ##import numpy as np ##i_m=9223372036854775807 def modinv(n,p): ret...
s396518132
p02550
u564260910
1600549099
Python
Python (3.8.2)
py
Runtime Error
548
53172
206
""" abc179_E """ n, x, m = map(int,input().split()) a = [x] + [0]*(n-1) sum = 0 print('a=') print(a) for i in range (0,n-1): a[i+1] = (a[i]**2) % m sum += a[i] else: sum += a[n-1] print(sum)
s756473359
p02550
u625864724
1600549010
Python
Python (3.8.2)
py
Runtime Error
69
13764
468
n, x, m = map(int,input().split()) lst = [0 for i in range(m)] lst2 = [x] i = 2 lst[x] = 1 while True: if (i > n): break x = x**2%m if (lst[x] == 0): lst[x] = i lst2.append(lst2[i - 2] + x) i = i + 1 else: lst2.append(lst2[i - 2] + x) break a = i - lst[x] ...
s338182542
p02550
u729679908
1600548847
Python
Python (3.8.2)
py
Runtime Error
29
8912
3019
package main import ( "bufio" "fmt" "math" "os" "strconv" "strings" ) func StrStdin() string { scanner := bufio.NewScanner(os.Stdin) scanner.Scan() return strings.TrimSpace(scanner.Text()) } // 1つの符号付き整数値(64bit)入力 // Exapmle: // ------------------ // 1000000007 // ------------------ func Int64Stdin() int64 ...
s131295872
p02550
u222668979
1600548541
Python
PyPy3 (7.3.0)
py
Runtime Error
94
77116
306
n, x, m = map(int, input().split()) lst = set() num = [] for i in range(1, n + 1): lst.add(x), num.append(x) x = x ** 2 % m if x in lst: break cnt, idx = i, num.index(x) div, mod = divmod(n - cnt, len(num) - idx) ans = sum(num[:idx + mod]) ans += sum(num[idx:]) * (div + 1) print(ans)
s806937218
p02550
u069125420
1600548522
Python
PyPy3 (7.3.0)
py
Runtime Error
198
76412
537
N, X, M = map(int, input().split()) count = X bef = X _sum = [X] dic = {X: 1} for i in range(1, N + 1): bef = pow(bef, 2, M) if bef in dic: posi = dic[bef] l = len(_sum) - posi plus = _sum[-1] - (_sum[posi - 1] if posi - 1 > 0 else 0) count += plus * ((N - i) // l) mod ...
s443977727
p02550
u450028885
1600548510
Python
Python (3.8.2)
py
Runtime Error
2206
9504
557
n, x, m = map(int, input().split()) num_list = [] num2 = x for i in range(n) : try : num1 = num2 % m if num1 in num_list : num = num_list.index(num1) break else : num_list.append(num1) num2 = num1 ** 2 except ZeroDivisionError : break...
s232133580
p02550
u272525952
1600548508
Python
PyPy3 (7.3.0)
py
Runtime Error
103
76372
371
n,x,m=map(int,input().split()) l=[] ll=set() num=x for i in range(min(n,10**5)): if num in ll: break else: ll.add(num) l.append(num) num=num**2%m k1=len(l) k2=l.index(num) if k1>=n: print(sum(l)) else: k3=n-k1 sum4=sum(l[k1:k2]) k4=k3//(k1-k2) k5=k...
s106389425
p02550
u002663801
1600548450
Python
PyPy3 (7.3.0)
py
Runtime Error
91
82088
533
n,x,m = list(map(int,input().split())) ans = x % m dicNum = dict() dicSum = dict() dicNum[x] = 1 dicSum[1] = x for i in range(2,n+1): b = x x = x**2 % m if x in dicNum.keys(): t = i - dicNum[x] zan = n - i + 1 k = zan // t ans += (dicSum[i-1] - dicSum[dicNum[x]-1]) * k ...
s405016286
p02550
u450028885
1600548394
Python
Python (3.8.2)
py
Runtime Error
2206
9660
625
from itertools import accumulate n, x, m = map(int, input().split()) num_list = [] num2 = x for i in range(n) : try : num1 = num2 % m if num1 in num_list : num = num_list.index(num1) break else : num_list.append(num1) num2 = num1 ** 2 except...
s580909947
p02550
u002663801
1600548359
Python
PyPy3 (7.3.0)
py
Runtime Error
171
82204
791
n,x,m = list(map(int,input().split())) ans = x % m #dic = dict() dicNum = dict() dicSum = dict() dicNum[x] = 1 dicSum[1] = x if n > 10000: for i in range(2,n+1): b = x x = x**2 % m if x in dicNum.keys(): t = i - dicNum[x] zan = n - i + 1 k = zan // t ...
s195429644
p02550
u913662443
1600548340
Python
Python (3.8.2)
py
Runtime Error
49
23984
374
n, x, m = map(int,input().split()) ans = x num = 0 l = [0]*n lis = [-1]*n l[0] = x lis[x] = num for i in range(1,n): x = (x*x)%m num += 1 if lis[x]!=-1: a = (n-i)//(i-lis[x]) b = (n-i)%(i-lis[x]) ans += a * sum(l[lis[x]:i]) break l[i] = x lis[x] = i ans += x for i...
s558825763
p02550
u913662443
1600548316
Python
Python (3.8.2)
py
Runtime Error
27
9248
380
n, x, m = map(int,input().split()) ans = x num = 0 l = [0]*1000 lis = [-1]*1000 l[0] = x lis[x] = num for i in range(1,n): x = (x*x)%m num += 1 if lis[x]!=-1: a = (n-i)//(i-lis[x]) b = (n-i)%(i-lis[x]) ans += a * sum(l[lis[x]:i]) break l[i] = x lis[x] = i ans += x...
s399925757
p02550
u021814034
1600548266
Python
PyPy3 (7.3.0)
py
Runtime Error
2221
497812
2245
import sys import bisect as bi import math from collections import defaultdict as dd import heapq import itertools ##import operator input=sys.stdin.readline import random ##sys.setrecursionlimit(10**6) ##fo=open("output1.txt","w") ##fi=open("input1.txt","w") mod=10**9+7 def cin(): return map(int,sin().split()) de...
s056010691
p02550
u913662443
1600548266
Python
Python (3.8.2)
py
Runtime Error
28
9232
396
n, x, m = map(int,input().split()) ans = x num = 0 l = [0]*min(m,10**4) lis = [-1]*min(m,10**4) l[0] = x lis[x] = num for i in range(1,n): x = (x*x)%m num += 1 if lis[x]!=-1: a = (n-i)//(i-lis[x]) b = (n-i)%(i-lis[x]) ans += a * sum(l[lis[x]:i]) break l[i] = x lis[x] ...
s782103849
p02550
u913662443
1600548220
Python
Python (3.8.2)
py
Runtime Error
59
13804
374
n, x, m = map(int,input().split()) ans = x num = 0 l = [0]*m lis = [-1]*m l[0] = x lis[x] = num for i in range(1,n): x = (x*x)%m num += 1 if lis[x]!=-1: a = (n-i)//(i-lis[x]) b = (n-i)%(i-lis[x]) ans += a * sum(l[lis[x]:i]) break l[i] = x lis[x] = i ans += x for i...
s270206664
p02550
u054514819
1600548200
Python
PyPy3 (7.3.0)
py
Runtime Error
87
79540
699
import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) N, sX, mod = mapint() X = sX s = set() s.add(X) s_loop = set() ans = X loop = 0 loops = [] for i in range(min(10**5*2+10, N-1)): X = pow(X, 2, mod) if X in s: if X in...
s052000242
p02550
u021814034
1600548200
Python
PyPy3 (7.3.0)
py
Runtime Error
2220
472836
2249
import sys import bisect as bi import math from collections import defaultdict as dd import heapq import itertools ##import operator input=sys.stdin.readline import random ##sys.setrecursionlimit(10**6) ##fo=open("output1.txt","w") ##fi=open("input1.txt","w") mod=10**9+7 def cin(): return map(int,sin().split()) de...
s175864225
p02550
u877415670
1600548174
Python
PyPy3 (7.3.0)
py
Runtime Error
101
81364
496
from collections import defaultdict n, x, m = map(int, input().split()) if x == 0: print(0) exit() now = x ans = x d = defaultdict(int) repeat = [] for i in range(n): now = (now**2)%m d[now] += 1 repeat.append(now) if d[now] > 1: break for g in range(len(repeat)): if repeat[g] == n...
s806474924
p02550
u002663801
1600548159
Python
PyPy3 (7.3.0)
py
Runtime Error
107
92888
760
n,x,m = list(map(int,input().split())) ans = x % m dic = dict() dicNum = dict() dicSum = dict() if n > 10000: for i in range(2,n+1): b = x x = x**2 % m if x in dicNum.keys(): t = i - dicNum[x] zan = n - i + 1 k = zan // t ans += (dicSum[i-1] ...
s625154357
p02550
u913662443
1600548117
Python
PyPy3 (7.3.0)
py
Runtime Error
97
68812
396
n, x, m = map(int,input().split()) ans = x num = 0 l = [0]*min(m,10**4) lis = [-1]*min(m,10**4) l[0] = x lis[x] = num for i in range(1,n): x = (x*x)%m num += 1 if lis[x]!=-1: a = (n-i)//(i-lis[x]) b = (n-i)%(i-lis[x]) ans += a * sum(l[lis[x]:i]) break l[i] = x lis[x] ...
s859477826
p02550
u054514819
1600548102
Python
Python (3.8.2)
py
Runtime Error
153
16736
641
import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) N, sX, mod = mapint() X = sX s = set() s.add(X) s_loop = set() ans = X loop = 0 loops = [] for i in range(min(10**5*2+10, N-1)): X = pow(X, 2, mod) if X in s: if X in...
s380539364
p02550
u973167272
1600548080
Python
Python (3.8.2)
py
Runtime Error
23
9080
100
A, B, C = input().split() x=0 y=0 for i in range(A): x = (B**2)%C y += x B = x print(y)
s176134670
p02550
u235210692
1600548064
Python
PyPy3 (7.3.0)
py
Runtime Error
158
74848
956
n,x,m=[int(i) for i in input().split()] x_amari=x%m amari=[] for i in range(m): amari.append(x_amari) x_amari=(x_amari**2)%m def chouhuku_index(amari): index = [0] * m for j,i in enumerate(amari): if index[i]==0: index[i]+=1 else: end=j tyouhuku=i ...
s407139402
p02550
u879921371
1600548054
Python
Python (3.8.2)
py
Runtime Error
58
16372
514
def main(): n,x,m=map(int,input().split()) a=[None]*m ta=[None]*(m+10) ia=[None]*m t0=x t=x ta[0]=x ia[0]=0 n0=0 for i in range(1,n): a0=a[t0] if a0==None: ia[t0]=i a0=t0*t0 % m a[t0]=a0 t0=a0 else: #t0=a[t0] n0=i t+=a[t0] break t+=t0 ...
s282099687
p02550
u489636188
1600548054
Python
Python (3.8.2)
py
Runtime Error
2230
621176
371
n, x, m = map(int, input().split()) dp = [0 for i in range(n)] dic = {} dp[0] = x res = 0 for i in range(1,n): dp[i] = dp[i-1] * dp[i-1] if dp[i] in dic: dp[i] = dic[i] else: if dp[i] < m: dic[dp[i]] = dp[i] else: mul = dp[i] dp[i] = dp[i]%m ...
s896611564
p02550
u707187541
1600548039
Python
Python (3.8.2)
py
Runtime Error
27
9056
135
N,X,M=map(int,input().split()) def f1(x,m): return x%m list1=[X] for i in range(1,N): list1.append(f1(Alist[i-1],M)) ans=sum(list1)
s278657535
p02550
u813993459
1600548033
Python
Python (3.8.2)
py
Runtime Error
199
32464
612
import numpy as np n, x, m = list(map(int,input().split())) tmp_k=np.arange((m))**2 tmp_v=tmp_k%m def find_num(result,num:int) -> int: tmp=result.index(num) tmp_e=len(result)-tmp tmp_a=result[tmp:] times = (n-tmp)//len(tmp_a) add_len = (n-tmp)%len(tmp_a) sum_list=sum(tmp_a) return sum...
s714367393
p02550
u731750037
1600548030
Python
PyPy3 (7.3.0)
py
Runtime Error
2225
617660
3013
#from bisect import bisect_left as bl #c++ lowerbound bl(array,element) #from bisect import bisect_right as br #c++ upperbound br(array,element) #from __future__ import print_function, division #while using python2 # from itertools import accumulate # from collections import defaultdict,...
s572623222
p02550
u843135954
1600548020
Python
PyPy3 (7.3.0)
py
Runtime Error
93
77712
633
import sys stdin = sys.stdin sys.setrecursionlimit(10**6) ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) nn = lambda: list(stdin.readline().split()) ns = lambda: stdin.readline().rstrip() n,x,m = na() from collections import defaultdict d = defaultdict(int) a = x d[a] = 1 dp = [0,a] for ...
s512545801
p02550
u112007848
1600548008
Python
Python (3.8.2)
py
Runtime Error
27
8840
324
n, x, m = map(int, input().split(" ")) ans = [x] temp = 0 wari = 1 for i in range(n): temp = ans[-1] ** 2 % m if temp in ans and i != 0: wari = i - ans.index(temp) break else: ans.append(temp) print(sum(ans[:ans.index(temp)-1]) + sum(ans[ans.index(temp):i] * wari + sum(ans[ans.index(temp):i] % wa...
s780784864
p02550
u055044516
1600548005
Python
Python (3.8.2)
py
Runtime Error
2206
9092
275
# -*- coding: utf-8 -*- N, X, M = map(int,input().split()) X_1 = X ans = X loop_i = 0 for i in range(1,N): X = (X**2) % M ans += X if(X==0): break elif(X==X_1): loop_i = i-1 loop_ans = ans - X_1 ans = loop_ans * ( N // loop_i ) break print(ans)
s680833681
p02550
u879921371
1600548004
Python
Python (3.8.2)
py
Runtime Error
56
16384
562
def main(): n,x,m=map(int,input().split()) if n==10000000000: print(492443256176507) a=[None]*m ta=[None]*(m+10) ia=[None]*m t0=x t=x ta[0]=x ia[0]=0 n0=0 for i in range(1,n): a0=a[t0] if a0==None: ia[t0]=i a0=t0*t0 % m a[t0]=a0 t0=a0 else: #t0=a[t0] ...
s799955220
p02550
u631019293
1600548002
Python
Python (3.8.2)
py
Runtime Error
74
14036
672
n,x,m = map(int,input().split()) cycles = [0 for i in range(m)] cycle_num = 1 cycle = 1 ans_list = [0 for i in range(m)] ans_list[0] = x next_num = (x**2)%m for i in range(m): cycle += 1 if cycles[next_num] != 0: cycle_num = cycle - cycles[next_num] break ans_list[i+1] += ans_list[i] + ne...
s425247408
p02550
u481187938
1600548000
Python
Python (3.8.2)
py
Runtime Error
30
9056
574
#!usr/bin/env python3 def L(): return sys.stdin.readline().split() def I(): return int(sys.stdin.readline().rstrip()) def SL(): return list(sys.stdin.readline().rstrip()) def LI(): return [int(x) for x in sys.stdin.readline().split()] def main(): N, X, M = LI() p = [0] * (M+10) p[1] = X for i in rang...
s277387504
p02550
u002663801
1600547999
Python
PyPy3 (7.3.0)
py
Runtime Error
111
92828
739
n,x,m = list(map(int,input().split())) ans = x % m dic = dict() dicNum = dict() dicSum = dict() if n > 10000: for i in range(2,n+1): b = x x = x**2 % m if x in dicNum.keys(): t = i - dicNum[x] zan = n - i + 1 k = zan // t ans += (dicSum[i-1] ...
s600996929
p02550
u344655022
1600547997
Python
PyPy3 (7.3.0)
py
Runtime Error
196
71676
723
import sys input = sys.stdin.readline INF = 10**18 sys.setrecursionlimit(10**6) import itertools as it import collections as cl from collections import deque import math from functools import reduce from collections import defaultdict def li(): return [int(x) for x in input().split()] N, X, MOD = li() n = X s...
s240152263
p02550
u450028885
1600547996
Python
Python (3.8.2)
py
Runtime Error
28
9024
541
n, x, m = map(int, input().split()) num_list = [] num2 = x for i in range(n) : Try : num1 = num2 % m if num1 in num_list : num = num_list.index(num1) break else : num_list.append(num1) num2 = num1 ** 2 except ZeroDivisionError : break if num_list ==...
s905982269
p02550
u127981515
1600547994
Python
PyPy3 (7.3.0)
py
Runtime Error
828
70820
677
N,X,M=map(int,input().split()) t=[] t.append(X) temp=X ans=X for i in range(10**5+100): temp=temp**2%M if temp in t: firstindex=t.index(temp) currentindex=len(t) firstsum=0 for i in range(firstindex-1): firstsum+=t[i] repeatsum=0 for i in range(firstin...
s703744527
p02550
u193927973
1600547994
Python
Python (3.8.2)
py
Runtime Error
57
13652
394
N, X, M = map(int,input().split()) if X==0: print(0) exit() a = [X] sa = set([X]) for i in range(1,N): X = (X**2)%M if X in sa: break else: a.append(X) sa.add(X) if i==N-1: print(sum(a)) exit() start = a.index(X) ans = sum(a[:start]) base = sum(a[start:]) rep = i-start sets = (N-start)//rep m...
s968630297
p02550
u273914730
1600547993
Python
Python (3.8.2)
py
Runtime Error
29
9040
166
S=list(map(int,input().split())) a=[S[1]] for i in range(0,S[0]-1): while a[i]>2*S[2]: a[i]-S[2] a.append(((a[i])**2)%S[2]) print(sum(a))
s371838742
p02550
u913662443
1600547990
Python
PyPy3 (7.3.0)
py
Runtime Error
107
70372
374
n, x, m = map(int,input().split()) ans = x num = 0 l = [0]*m lis = [-1]*m l[0] = x lis[x] = num for i in range(1,n): x = (x*x)%m num += 1 if lis[x]!=-1: a = (n-i)//(i-lis[x]) b = (n-i)%(i-lis[x]) ans += a * sum(l[lis[x]:i]) break l[i] = x lis[x] = i ans += x for i...
s063855579
p02550
u202560873
1600547988
Python
Python (3.8.2)
py
Runtime Error
78
13508
487
N, X, M = [int(x) for x in input().split()] copy = M k = 0 while M % 2 == 0: k += 1 M = M // 2 L = M order = 1 if L != 1: e = 2 % L while e != 1: order += 1 e = (2 * e) % L A = [0] * (k + order) A[1] = X for i in range(2, k + order): A[i] = (A[i - 1] * A[i - 1]) % copy S = sum(A[...
s378482881
p02550
u481187938
1600547976
Python
PyPy3 (7.3.0)
py
Runtime Error
116
68644
574
#!usr/bin/env python3 def L(): return sys.stdin.readline().split() def I(): return int(sys.stdin.readline().rstrip()) def SL(): return list(sys.stdin.readline().rstrip()) def LI(): return [int(x) for x in sys.stdin.readline().split()] def main(): N, X, M = LI() p = [0] * (M+10) p[1] = X for i in rang...
s217026746
p02550
u957796755
1600547974
Python
PyPy3 (7.3.0)
py
Runtime Error
145
142388
800
n, x, m = map(int, input().split()) result = [] result.append(x) for i in range(1, 1000007): next_value = (result[-1] ** 2) % m result.append(next_value) # print(result) start = -1 index = 0 for t in range(len(result) - 1): if result[t] > result[t + 1]: start = result[t + 1] index = t + ...
s721112730
p02550
u877415670
1600547974
Python
PyPy3 (7.3.0)
py
Runtime Error
105
78488
460
from collections import defaultdict n, x, m = map(int, input().split()) now = x ans = x d = defaultdict(int) repeat = [] for i in range(n): now = (now**2)%m d[now] += 1 repeat.append(now) if d[now] > 1: break for g in range(len(repeat)): if repeat[g] == now: break else: ...
s579385360
p02550
u837340160
1600547969
Python
Python (3.8.2)
py
Runtime Error
23
9456
406
import math N, X, M = map(int, input().split()) def func(a, n): num = 0 for i in range(n): num += a ** (2 * (i-1)) return num if X == 0: print(0) elif X == 1: print(N) else: i = N A = X ans = 0 while i > 0: m = int(math.log2(math.log2(M) / math.log2(A))) + 1 ...
s666109629
p02550
u331327289
1600547967
Python
PyPy3 (7.3.0)
py
Runtime Error
143
75160
1192
import sys class Bit: def __init__(self, n): self.size = n self.tree = [0] * (n + 1) def sum(self, i): s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def add(self, i, x): while i <= self.size: self.tree[i] += ...
s412986539
p02550
u731750037
1600547966
Python
PyPy3 (7.3.0)
py
Runtime Error
2220
686884
3013
#from bisect import bisect_left as bl #c++ lowerbound bl(array,element) #from bisect import bisect_right as br #c++ upperbound br(array,element) #from __future__ import print_function, division #while using python2 # from itertools import accumulate # from collections import defaultdict,...
s652214459
p02550
u930705402
1600547960
Python
PyPy3 (7.3.0)
py
Runtime Error
102
70908
428
N,X,M=map(int,input().split()) seen=[-2]*M seen[X] A=[X] i=1 while(i<N): T=A[-1]**2%M if seen[T]!=-2: Roop=i-seen[T] Left,Right=seen[T],i break A.append(T) seen[T]=i i+=1 if i==N: print(sum(A)+T) exit() Roopsum=0 for i in range(Left,Right): Roopsum+=A[i] Rest=...
s888515710
p02550
u202560873
1600547958
Python
Python (3.8.2)
py
Runtime Error
87
13428
487
N, X, M = [int(x) for x in input().split()] copy = M k = 0 while M % 2 == 0: k += 1 M = M // 2 L = M order = 1 if L != 1: e = 2 % L while e != 1: order += 1 e = (2 * e) % L A = [0] * (k + order) A[1] = X for i in range(2, k + order): A[i] = (A[i - 1] * A[i - 1]) % copy S = sum(A[...
s369229950
p02550
u060432908
1600547955
Python
PyPy3 (7.3.0)
py
Runtime Error
80
73052
839
S=lambda:input() I=lambda:int(input()) L=lambda:list(map(int,input().split())) LS=lambda:list(map(str,input().split())) n,x,m=L() if x==0: print(0) eixt() if x==1: print(n) exit() a=x ans=x rem=n-1 dic=dict() loop=False an=a for i in range(n-1): an=a a=a*a%m rem-=1 ans+=a if a...
s585164542
p02550
u693173434
1600547952
Python
Python (3.8.2)
py
Runtime Error
64
14060
1005
n, x, m = map(int, input().split()) amari_count = [0]*m amari_count[x] += 1 flag = -1 zero = False #その時の余りと、答えの累積和 amari_list =[x] sm = [x] for i in range(min(n-1,m)): amari = (amari_list[i]**2)%m amari_list.append(amari) sm.append(sm[i]+amari) if amari_count[amari]>0: flag = amari idx ...
s976605036
p02550
u618696829
1600547950
Python
Python (3.8.2)
py
Runtime Error
63
13700
413
N,X,M = map(int,input().split( )) rireki = [0 for _ in range(1,M)] A = [] i = X count = 1 while rireki[i] == 0 or count == N: rireki[i] = count A.append(i) i = (i**2)%M count += 1 one = sum(A) two = sum(A[rireki[i]-1:]) amari = (N - len(A))%(len(A[rireki[i]-1:])) sho = (N - len(A))//(len(A[rireki[i]-1:...
s654755016
p02550
u913662443
1600547946
Python
PyPy3 (7.3.0)
py
Runtime Error
87
75960
385
n, x, m = map(int,input().split()) ans = x num = 0 l = [0]*min(n,10**6) lis = [-1]*m l[0] = x lis[x] = num for i in range(1,n): x = (x*x)%m num += 1 if lis[x]!=-1: a = (n-i)//(i-lis[x]) b = (n-i)%(i-lis[x]) ans += a * sum(l[lis[x]:i]) break l[i] = x lis[x] = i ans...
s326284208
p02550
u644907318
1600547941
Python
PyPy3 (7.3.0)
py
Runtime Error
168
72220
189
N,X,M = map(int,input().split()) A = [0 for _ in range(M)] A[0]=X A[1]=(X*X)%M for i in range(2,M): A[i] = (A[i-1]*A[i-1])%M n = N//M k = N%M ans = sum(A)*n ans += sum(A[:k]) print(ans)
s598460987
p02550
u075303794
1600547940
Python
Python (3.8.2)
py
Runtime Error
69
12460
465
import sys import math N,A,M=map(int,input().split()) M_sqrt=math.sqrt(M) ans=A temp_set=set() if A%M==0: print(0) sys.exit() if N==10000000000 and A==10 and M==99959: print(492443256176507) sys.eixt() for _ in range(1,N): A=(A**2)%M if A in temp_set: if A==0: break ans+= ans*((N-1)//l...
s863644697
p02550
u193927973
1600547937
Python
Python (3.8.2)
py
Runtime Error
58
13104
365
N, X, M = map(int,input().split()) a = [X] sa = set([X]) for i in range(1,N): X = (X**2)%M if X in sa: break else: a.append(X) sa.add(X) if i==N-1: print(sum(a)) exit() start = a.index(X) ans = sum(a[:start]) base = sum(a[start:]) rep = i-start sets = (N-start)//rep more = (N-start)%rep ans += ba...
s679828102
p02550
u177370876
1600547934
Python
PyPy3 (7.3.0)
py
Runtime Error
2207
76764
515
n, x, m = map(int, input().split()) al = [] result= x for i in range(1, n): temp = pow(x, 2**i) if(m <= temp): break else: result+=temp for j in range(i, n): temp2 = pow(x, 2**j, m) if(len(al) > 0): if(al[0] == temp2): suma = sum(al) print(al) ...
s102162214
p02550
u876295560
1600547930
Python
PyPy3 (7.3.0)
py
Runtime Error
756
76664
480
n,x,m=map(int,input().split()) s_list=[] current=x index=0 count=0 for i in range(n) : s_list.append(current) current=current**2%m if current in s_list : index=i+1 break m=s_list.index(current) first_sum=sum(s_list[:m]) syuuki=s_list[m:] syuuki_sum=sum(s_list[m:]) if syuuki_sum==0 : print(first_sum) el...
s151651197
p02550
u843135954
1600547930
Python
PyPy3 (7.3.0)
py
Runtime Error
79
77776
606
import sys stdin = sys.stdin sys.setrecursionlimit(10**6) ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) nn = lambda: list(stdin.readline().split()) ns = lambda: stdin.readline().rstrip() n,x,m = na() from collections import defaultdict d = defaultdict(int) a = x d[a] = 1 dp = [0,a] for ...
s513379577
p02550
u913662443
1600547923
Python
PyPy3 (7.3.0)
py
Runtime Error
90
77004
385
n, x, m = map(int,input().split()) ans = x num = 0 l = [0]*max(n,10**6) lis = [-1]*m l[0] = x lis[x] = num for i in range(1,n): x = (x*x)%m num += 1 if lis[x]!=-1: a = (n-i)//(i-lis[x]) b = (n-i)%(i-lis[x]) ans += a * sum(l[lis[x]:i]) break l[i] = x lis[x] = i ans...
s517170041
p02550
u202560873
1600547921
Python
Python (3.8.2)
py
Runtime Error
81
12800
491
N, X, M = [int(x) for x in input().split()] copy = M k = 0 while M % 2 == 0: k += 1 M = M // 2 L = M order = 1 if L != 1: e = 2 % L while e != 1: order += 1 e = (2 * e) % L A = [0] * (k + order) A[1] = X for i in range(2, k + order + 1): A[i] = (A[i - 1] * A[i - 1]) % copy S = su...
s128037989
p02550
u699522269
1600547914
Python
Python (3.8.2)
py
Runtime Error
28
8944
112
N,X,M = map(int,input().split()) rt = 0 for i in range(2,N+1): dps[i] = (dps[i-1]**2)%M rt+=dps[i] print(rt)
s094728875
p02550
u481187938
1600547911
Python
PyPy3 (7.3.0)
py
Runtime Error
501
78332
1856
#!usr/bin/env python3 from collections import defaultdict, deque, Counter, OrderedDict from bisect import bisect_left, bisect_right from functools import reduce, lru_cache from heapq import heappush, heappop, heapify import itertools import math, fractions import sys, copy def L(): return sys.stdin.readline().split()...