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
s524498037
p03674
u768951609
1498971460
Python
Python (2.7.6)
py
Runtime Error
2104
12900
876
def c(a,b): if b==0: return 0 elif a==b: return 1 s=1.0 if a-b>=b: for i in range(b): s*=a-i s/=b-i else: s=c(a,a-b) return int(s) n=int(raw_input()) a=map(int,raw_input().split(' ')) if a.index(a[-1])!=len(a)-1: indexes=[a.index(a[-...
s937478675
p03674
u768951609
1498971277
Python
Python (2.7.6)
py
Runtime Error
2104
13024
870
def c(a,b): if b==0: return 0 elif a==b: return 1 s=1.0 if a-b>=b: for i in range(b): s*=a-i s/=b-i else: s=c(a,a-b) return int(s) n=int(raw_input()) a=map(int,raw_input().split(' ')) if a.index(a[-1])!=len(a)-1: indexes=[len(a)-2,le...
s551648552
p03674
u768951609
1498970876
Python
Python (2.7.6)
py
Runtime Error
2104
12876
858
def c(a,b): if b==0: return 0 elif a==b: return 1 s=1.0 if a-b>=b: for i in range(b): s*=a-i s/=b-i else: s=c(a,a-b) return int(s) n=int(raw_input()) a=map(int,raw_input().split(' ')) if a[-2]==a[-1]: indexes=[len(a)-2,len(a)-1] else...
s559508777
p03674
u741323288
1498969480
Python
Python (3.4.3)
py
Runtime Error
47
13812
388
import sys import math N = int(input()) a_array = list(map(int, input().split())) def combination(n,k): if k == 0: return 1 elif k == n: return 1 else: return 2 indexes = [i for i, x in enumerate(a_array) if x == 1] r = indexes[0] + N-indexes[1] for i in range(1,N+2): if r >= i-1: print(int(combination(...
s068085864
p03674
u741323288
1498969435
Python
Python (3.4.3)
py
Runtime Error
46
13812
442
import sys import math N = int(input()) a_array = list(map(int, input().split())) def combination(n,k): if k == 0: return 1 elif k == n: return 1 else: return math.factorial(n)/math.factorial(n-k)/math.factorial(k) indexes = [i for i, x in enumerate(a_array) if x == 1] r = indexes[0] + N-indexes[1] for i i...
s124695163
p03674
u741323288
1498969369
Python
Python (3.4.3)
py
Runtime Error
46
14008
627
import sys #import math N = int(input()) a_array = list(map(int, input().split())) def combination(n,k): if k == 0: return 1 elif k == n: return 1 else: return math.factorial(n)/math.factorial(n-k)/math.factorial(k) #hoge = "1 2 1 3" #a_array = list(map(int,hoge.split(" "))) #a_array = [2,3,1,4,5,1,6,7] #a_...
s593998315
p03674
u741323288
1498969324
Python
Python (3.4.3)
py
Runtime Error
17
2940
633
import sys #import math N = int(input()) a = list(map(int, input().split())) def combination(n,k): if k == 0: return 1 elif k == n: return 1 else: return 1: #return math.factorial(n)/math.factorial(n-k)/math.factorial(k) #hoge = "1 2 1 3" #a_array = list(map(int,hoge.split(" "))) #a_array = [2,3,1,4,5,1,6,...
s784726849
p03674
u741323288
1498969197
Python
Python (3.4.3)
py
Runtime Error
42
13812
620
import sys import math N = int(input()) a = list(map(int, input().split())) def combination(n,k): if k == 0: return 1 elif k == n: return 1 else: return math.factorial(n)/math.factorial(n-k)/math.factorial(k) #hoge = "1 2 1 3" #a_array = list(map(int,hoge.split(" "))) #a_array = [2,3,1,4,5,1,6,7] #a_array =...
s127372497
p03674
u741323288
1498969089
Python
Python (3.4.3)
py
Runtime Error
40
13812
620
import sys import math N = int(input()) a = list(map(int, input().split())) def combination(n,k): if k == 0: return 1 elif k == n: return 1 else: return math.factorial(n)/math.factorial(n-k)/math.factorial(k) #hoge = "1 2 1 3" #a_array = list(map(int,hoge.split(" "))) #a_array = [2,3,1,4,5,1,6,7] #a_array =...
s186403633
p03674
u713711297
1498967909
Python
PyPy2 (5.6.0)
py
Runtime Error
154
44344
897
def get_repeating_indexes(ax): elements = [-1] * (len(ax)) for i, a in enumerate(ax): if elements[a] != -1: return elements[a], i else: elements[a] = i MOD = 10 ** 9 + 7 memo = {} def nck(a, b): if (a, b) in memo: return memo[(a,b)] elif b > a: ...
s701596784
p03674
u706884679
1498965940
Python
Python (3.4.3)
py
Runtime Error
17
3064
544
from math import factorial from collections import Counter n = int(input()) a = list(map(int, input().split())) F = [(factorial(i) % (pow(10, 9)+7)) for i in range(n+2)] G = [(pow(F[i], (pow(10, 9)+5)) % (pow(10, 9)+7)) for i in range(n+2)] b = [key for key,val in Counter(a).items() if val > 1] c = [i for i, x in enum...
s638432198
p03674
u709121282
1498964370
Python
Python (2.7.6)
py
Runtime Error
65
12644
480
N = input() s = map(int, raw_input().split(" ")) sd=list(set(s)) daburi=sum(s)-sum(sd) o = [ i for i, v in enumerate(s) if v == daburi] a=[] out=o[0]+N-o[1] def nck(n, k): if n-k<k: k=n-k ko=1 haha=1 if k>0: for i in range(k): ko*=n n-=1 haha*=(i+1...
s603659393
p03674
u709121282
1498964073
Python
Python (2.7.6)
py
Runtime Error
68
12660
451
N = input() s = map(int, raw_input().split(" ")) sd=list(set(s)) daburi=sum(s)-sum(sd) o = [ i for i, v in enumerate(s) if v == daburi] a=[] out=o[0]+N-o[1] def nck(n, k): if n-k<k: k=n-k ko=1 haha=1 for i in range(k): ko*=n n-=1 haha*=(i+1) return ko/haha for i ...
s060492483
p03674
u709121282
1498963966
Python
Python (2.7.6)
py
Runtime Error
75
12660
451
N = input() s = map(int, raw_input().split(" ")) sd=list(set(s)) daburi=sum(s)-sum(sd) o = [ i for i, v in enumerate(s) if v == daburi] a=[] out=o[0]+N-o[1] def nck(n, k): if n-k<k: k=n-k ko=1 haha=1 for i in range(k): ko*=n n-=1 haha*=(i+1) return ko/haha for i ...
s661668623
p03674
u677421794
1498963910
Python
Python (2.7.6)
py
Runtime Error
437
30832
498
# -*- coding: utf-8 -*- import scipy.misc as scm n = input() a = map(int, raw_input().split()) mod = 10**9+7 acnt =[0]*(n+1) for i in range(n+1): acnt[a[i]] += 1 if(acnt[a[i]]==2): same = a[i] break lr = [] for i in range(n+1): if(a[i]==same): lr.append(i) left = lr[0] right = ...
s382359895
p03674
u677421794
1498963752
Python
Python (2.7.6)
py
Runtime Error
385
29760
576
# -*- coding: utf-8 -*- import numpy as np import scipy.misc as scm n = input() a = map(int, raw_input().split()) mod = 10**9+7 acnt =[0]*(n+1) for i in range(n+1): acnt[a[i]] += 1 if(acnt[a[i]]==2): same = a[i] break lr = [] for i in range(n+1): if(a[i]==same): lr.append(i) le...
s012469793
p03674
u825324821
1498963297
Python
Python (3.4.3)
py
Runtime Error
2109
23996
261
from scipy.misc import comb n = int(input()) a = [int(i) for i in input().split(' ')] b = [] for i in range(1, n+1): if a[i] in b: l = a[i] break b.append(a[i]) for i in range(1, n+1): print((comb(n, i) - comb(l, i-1)) / (10**9+7))
s462716710
p03674
u846372029
1498963224
Python
Python (3.4.3)
py
Runtime Error
2104
14008
474
#11 n = int(input()) a = list(map(int, input().split())) import math flag = [a.count(a[i])-1 for i in range(n+1) ] cc = [ math.factorial(n+1)/math.factorial(i+1)/math.factorial(n-i) for i in range( n//2 )] cc = cc + list(reversed(cc)) +[1] for i in range(n+1): p = flag.index(1) + list(reversed(flag)).index(1) ...
s285183576
p03674
u049595114
1498963191
Python
Python (3.4.3)
py
Runtime Error
2104
13748
1150
import itertools def nCr(n, r): """ Calculate the number of combination (nCr = nPr/r!). The parameters need to meet the condition of n >= r >= 0. It returns 1 if r == 0, which means there is one pattern to choice 0 items out of the number of n. """ # 10C7 = 10C3 r = min(r, n-r) # C...
s397542554
p03674
u846372029
1498963161
Python
Python (3.4.3)
py
Runtime Error
2104
14008
469
#11 n = int(input()) a = list(map(int, input().split())) import math flag = [a.count(a[i])-1 for i in range(n+1) ] cc = [ math.factorial(n+1)/math.factorial(i+1)/math.factorial(n-i) for i in range( n//2 )] cc + list(reversed(cc)) +[1] for i in range(n+1): p = flag.index(1) + list(reversed(flag)).index(1) ...
s799680347
p03674
u712187387
1498962870
Python
Python (3.4.3)
py
Runtime Error
466
36064
336
INF = 10**9+7 import scipy.misc as scm n = int(input()) a = list(map(int, input().split())) s = set() result = [x for x in a if x in s or s.add(x)] indexes = [i for i, x in enumerate(a) if x == result[0]] l0 = indexes[0]+1 l1 = indexes[1] +1 for i in range(1,n+2): print(int((scm.comb(n+1,i)-scm.comb(n-(l1-l...
s397338868
p03674
u800272486
1498962740
Python
Python (3.4.3)
py
Runtime Error
77
13880
407
n = int(input()) a = map(int, input().split()) occur = [0 for i in range(100005)] x = 0 cnt = 0 for i in a: cnt += 1 if occur[i] > 0: x = n + 1 - cnt + occur[i] else: occur[i] = cnt print(n) res1 = n + 1 res2 = 1 for i in range(1, n + 1): res1 = res1 * (n + 1 - i) / (i + 1) if res2 >...
s941349769
p03674
u712187387
1498962660
Python
Python (3.4.3)
py
Runtime Error
222
24484
333
INF = 10e9+7 import scipy.misc as scm n = int(input()) a = list(map(int, input().split())) s = set() result = [x for x in a if x in s or s.add(x)] indexes = [i for i, x in enumerate(a) if x == result[0]] l0 = indexes[0]+1 l1 = indexes[1] +1 for i in range(1,n+2): print(int((scm.comb(n+1,i)-scm.comb(n-(l1-l0),...
s100709640
p03674
u024804656
1498962647
Python
Python (3.4.3)
py
Runtime Error
274
22252
512
import math def nCr(n,r): f = math.factorial return f(n) / f(r) / f(n-r) div = 10**9+7 n = int(input()) al = input().split() s = {} for i,ai in enumerate(al): if (ai in s): k1 = s[ai] k2 = i+1 break else: s[ai] = i + 1 for m in range(1,n+2): if(m == 1): ...
s546111787
p03674
u024804656
1498962541
Python
Python (3.4.3)
py
Runtime Error
273
22252
512
import math def nCr(n,r): f = math.factorial return f(n) / f(r) / f(n-r) div = 10**9+7 n = int(input()) al = input().split() s = {} for i,ai in enumerate(al): if (ai in s): k1 = s[ai] k2 = i+1 break else: s[ai] = i + 1 for m in range(1,n+2): if(m == 1): ...
s163887744
p03674
u800272486
1498962458
Python
Python (3.4.3)
py
Runtime Error
71
13880
410
n = int(input()) a = map(int, input().split()) occur = [0 for i in range(n + 1)] x = 0 cnt = 0 for i in a: cnt += 1 if (occur[i] > 0): x = n + 1 - cnt + occur[i] else: occur[i] = cnt print(n) res1 = n + 1 res2 = 1 for i in range(1, n + 1): res1 = res1 * (n + 1 - i) / (i + 1) if (res2...
s672937171
p03674
u800272486
1498962168
Python
Python (3.4.3)
py
Runtime Error
73
13812
403
n = int(input()) a = map(int, input().split()) occur = [0 for i in range(n + 1)] x = 0 cnt = 0 for i in a: cnt += 1 if (occur[i] > 0): x = n + 1 - cnt + occur[i] else: occur[i] = cnt print(n) res1 = n + 1 res2 = 1 for i in range(1, n + 1): res1 = int(res1 * (n + 1 - i) / (i + 1)) res...
s372996925
p03674
u800272486
1498962025
Python
Python (3.4.3)
py
Runtime Error
74
13880
399
n = int(input()) a = map(int, input().split()) occur = [0 for i in range(n + 1)] x = 0 cnt = 1 for i in a: cnt += 1 if (occur[i] > 0): x = n + 1 - cnt + occur[i] else: occur[i] = cnt print(n) res1 = n + 1 res2 = 1 for i in range(1, n + 1): res1 = res1 * (n + 1 - i) / (i + 1) res2 = r...
s183289883
p03675
u388971072
1597889290
Python
PyPy3 (7.3.0)
py
Runtime Error
135
104328
326
N = int(input()) a = list(map(int,input().split())) check = N%2==0 for i,j in enumerate(a[1:]): if(check): if(i%2==0): ans.insert(0,j) else: ans.append(j) else: if(i%2==1): ans.insert(0,j) else: ans.append(j) print(" ".join(map(str,...
s718954259
p03675
u587589241
1594588922
Python
PyPy3 (7.3.0)
py
Runtime Error
135
104364
212
n=int(input()) a=list(map(int,input().split())) b=deque() for i in range(n): if i%2==0: b.append(a[i]) else: b.appendleft(a[i]) b=list(b) if n%2==0: print(*b) else: print(*b[::-1])
s843422839
p03675
u222668979
1590608701
Python
Python (3.4.3)
py
Runtime Error
216
25412
271
from collections import deque n = int(input()) a = list(map(int, input().split())) b = deque([]) rev = 1 for i in a: if rev == 1: b.append(i) rev = -1 elif rev == -1: b.appendleft(i) rev = 1 print(*(b if rev == 1 else b[::-1]))
s735511894
p03675
u780475861
1590259134
Python
Python (3.4.3)
py
Runtime Error
71
25180
201
import sys n, *alst = map(int, sys.stdin.read().split()) lst1 = alst[::2] lst2 = alst[1::2] if n % 2: lst1.reverse() print(''.join(lst1 + lst2)) else: lst2.reverse() print(''.join(lst2 + lst1))
s512478214
p03675
u371990949
1576589424
Python
Python (3.4.3)
py
Runtime Error
17
2940
1
a
s209552425
p03675
u123648284
1569244715
Python
Python (3.4.3)
py
Runtime Error
168
29124
251
from collections import deque N = int(input()) A = list(map(int, input().split())) q = deque() q.append(A[0]) q.append(A[1]) for i in range(2, N): a = A[i] if i % 2 == 1: q.appendleft(a) else: q.append(a) print(" ".join(map(str, q)))
s107945912
p03675
u500297289
1558162428
Python
Python (3.4.3)
py
Runtime Error
2106
25156
167
n = int(input()) a = list(map(int, input().split())) b = [] for aa in a: b.append(aa) b.reverse() ans = '' for bb in b: ans += bb + ' ' print(ans[:-1])
s562383515
p03675
u379692329
1553717241
Python
Python (3.4.3)
py
Runtime Error
18
2940
143
n = int(input()) a = [int(_) for _ in input().split()] if (n % 2) == 0: print(*a[n-1::-2], *a[::2]) else: print(*a[n-1::-2], *a[1::2])
s813467424
p03675
u379692329
1553717079
Python
Python (3.4.3)
py
Runtime Error
17
2940
141
n = int(input()) a = [int(_) for _ in input().split()] if n % 2 == 0: print(*a[n-1::-2], *a[::2]) else: print(*a[n-1::-2], *a[1::2])
s206826702
p03675
u375616706
1548791232
Python
Python (3.4.3)
py
Runtime Error
77
26360
201
N = int(input()) A = list(map(int, input().split())) ans = [] l1 = A[0::2] l2 = A[1::2] if N % 2 == 0: l2 = l2[::-1] ans = l2+l1 else: l1 = l1[::-1] ans = l1+l2 print(" ".join(ans))
s987702829
p03675
u536113865
1548394313
Python
Python (3.4.3)
py
Runtime Error
202
35648
823
ai = lambda: list(map(int,input().split())) ai_ = lambda: [int(x)-1 for x in input().split()] n = int(input()) a = ai() MOD = 10**9+7 from collections import Counter dup = list(Counter(sorted(a)).values()).index(2)+1 ant = a.index(dup) post = a[::-1].index(dup) def nCb(n, r): fac = [1, 1] + [0] * n finv = ...
s437431139
p03675
u384679440
1532106728
Python
Python (3.4.3)
py
Runtime Error
121
26180
323
n = int(input()) a = list(map(int, input().split())) b_1 = [] b_2 = [] b = [] for i in reversed(range(len(a))): if i % 2 != 0: b_1.append(a[i]) else: b_2.append(a[i]) if len(a) % 2 == 0: b_2.reverse() b.extend(b_1) b.extend(b_2) else: b_1.reverse() b.extend(b_2) b.extend(b_1) for b_num in b: print("".join(...
s927733953
p03675
u035336908
1502672314
Python
Python (3.4.3)
py
Runtime Error
2105
20184
199
N = int(input()) a = input().split() b = [] for i in range(len(a)): if i % 2 == 1: b.insert(0, a[i]) else: b.append(a[i]) if N % 2 == 1: b = b.reverse() print(b) line = " ".join(b) print(line)
s209292824
p03675
u582577761
1501350058
Python
PyPy3 (2.4.0)
py
Runtime Error
2188
443672
300
import itertools n,m,*a=map(int,open(0).read().split()) s=[0]*(2*m+2) tot=0 for l,r in zip(a,a[1:]): tot+=(r-l)%m if l>r: r+=m dif=r-l if dif>1: s[l+2]+=1 s[r+1]-=dif s[r+2]+=dif-1 s=list(itertools.accumulate(list(itertools.accumulate(s)))) print(tot-max(s[i]+s[m+i] for i in range(1,m)))
s950517481
p03675
u207056619
1500414905
Python
Python (3.4.3)
py
Runtime Error
17
2940
145
#!/usr/bin/env python3 n = int(input()) a = input().split() l = [] r = [] for a_i in a: r += [ a_i ] l, r = r, l print(*reversed(l), *r)
s055943871
p03675
u498141549
1499663697
Python
Python (3.4.3)
py
Runtime Error
18
3060
189
n = int(input()) a = map(int,raw_input().split()) b = [] for i in range(n): if i % 2 != n % 2: b.insert(0,a[i]) else: b.append(a[i]) print(' '.join(map(str,b)))
s248432011
p03675
u498141549
1499662973
Python
Python (3.4.3)
py
Runtime Error
17
3060
245
n = int(input()) a = map(int,raw_input().split()) b = [] flag = True for i in xrange(n): if flag: b.insert(0,a[i]) else: b.append(a[i]) flag = not flag if n % 2 == 0: b.reverse() print(' '.join(map(str,b)))
s791415374
p03675
u498141549
1499662372
Python
Python (3.4.3)
py
Runtime Error
17
3060
145
n = int(input()) a = map(int,raw_input().split()) b = [] for i in xrange(n): b.append(a[i]) b.reverse() print(' '.join(map(str,b)))
s030111089
p03675
u413107439
1499212551
Python
Python (2.7.6)
py
Runtime Error
111
22008
1619
input_line_1 = raw_input() input_line_2 = raw_input() #N = int(input_line_1) input_array = [int(i) for i in input_line_2.split(" ")] M = int(input_line_1.split(" ")[1]) def count(base_val, input_array, M): return sum([min((input_array[i + 1] - input_array[i]) % M, (input_array[i + 1] - base_val) % M + 1 ) for i...
s422076584
p03675
u800272486
1499035191
Python
Python (3.4.3)
py
Runtime Error
80
26180
705
n = int(input()) a = list(map(int, input().split())) occur = [0 for i in range(n + 1)] MOD = 1000000007 for i in range(n + 1): if occur[a[i]] > 0: val = n - 1 - i + occur[a[i]] else: occur[a[i]] = i + 1 inv = [0 if i > 2 else 1 for i in range(n + 2)] pinv = [0 if i > 2 else 1 for i in range(n + 2)] perm = [0 if...
s377813845
p03675
u226155577
1498967662
Python
Python (3.4.3)
py
Runtime Error
17
2940
61
n=int(input());A=input().split();print(*A[-1::-2],*A[n%2::2])
s754158008
p03675
u391331433
1498963908
Python
Python (2.7.6)
py
Runtime Error
13
2936
1369
import sys from collections import deque from math import * def get_read_func(fileobject): if fileobject == None : return raw_input else: return fileobject.readline def main(): if len(sys.argv) > 1: f = open(sys.argv[1]) else: f = None read_func = get_read_func(f); ...
s882324388
p03675
u391331433
1498963799
Python
Python (2.7.6)
py
Runtime Error
15
2816
1369
import sys from collections import deque from math import * def get_read_func(fileobject): if fileobject == None : return raw_input else: return fileobject.readline def main(): if len(sys.argv) > 1: f = open(sys.argv[1]) else: f = None read_func = get_read_func(f); ...
s617021597
p03675
u402189762
1498963391
Python
Python (3.4.3)
py
Runtime Error
18
3064
719
c=input().split() for i in range(2): c[i]=int(c[i]) n=c[0] m=c[1] a=input().split() for i in range(len(a)): a[i]=int(a[i]) b=[0 for i in range(m+1)] for i in range(n-1): if(a[i]<a[i+1]): for j in range(a[i+1]-a[i]): b[a[i]+1+j]+=1 else: for j in range(a[i+1]): ...
s293998693
p03675
u402189762
1498963265
Python
Python (3.4.3)
py
Runtime Error
18
3064
717
c=input().split for i in range(2): c[i]=int(c[i]) n=c[0] m=c[1] a=input().split() for i in range(len(a)): a[i]=int(a[i]) b=[0 for i in range(m+1)] for i in range(n-1): if(a[i]<a[i+1]): for j in range(a[i+1]-a[i]): b[a[i]+1+j]+=1 else: for j in range(a[i+1]): b[...
s114345239
p03675
u177481830
1498963023
Python
Python (3.4.3)
py
Runtime Error
400
43148
852
import numpy as np import math def comb(n, k): if k<0 or n<k: return 0 if n-k<k: k=n-k return round(math.factorial(n)/math.factorial(k)/math.factorial(n-k)) n=int(input()) a=np.array([int(i) for i in input().split()]) count_lst=[[] for _ in range(n)] for i in range(n+1): count_lst[a[...
s958433426
p03675
u382748202
1498962885
Python
Python (3.4.3)
py
Runtime Error
79
25776
735
from operator import mul from functools import reduce n = int(input()) a = list(map(int, input().split())) def com(n, k): if n == 0 or k == 0: return 1 return int(reduce(mul, range(n + 1 - k, n + 1)) / reduce(mul, range(1, k + 1))) idx_list = [-1] * (n + 2) l = 0 r = 0 for i, a_i in enumerate(a): ...
s769623945
p03675
u667084803
1498960542
Python
Python (3.4.3)
py
Runtime Error
2104
25156
524
import math N=int(input()) a=list(map(int,input().split())) c=[] for i in range(N+1): if a[i] in c: b=a[i] j=c.index(a[i]) k=i L=j+N-k break c+=[a[i]] Base=N+1 Minu=1 for i in range(0,min(L+1,N+1)): print((Base-Minu)%(10**9+7)) Base=int(Base*(N-i)/(i+2)) Minu=int(Minu*(L-i)/(i+1)) #print...
s550603160
p03675
u821262411
1498960258
Python
Python (3.4.3)
py
Runtime Error
235
26360
189
n=int(input()) a=list(map(int,input().split())) b=[] for i in range(n): if n-i*2-1 > 0: b.append(a[n-i*2-1]) else: k=abs(n-i*2) b.append(a[k]) print(*b)
s462448296
p03675
u346308892
1498959812
Python
Python (3.4.3)
py
Runtime Error
193
26176
350
n=int(input()) a=list(map(int,input().split(" "))) a.insert(0,-1) m=len(a)-1 res="" k=m if m%2==0: aa=0 else: aa=1 for i in range(int(m/2)+1): res+=str(a[k])+" " k-=2 if k<=0: break if m%2==0: s=1 else: s=2 k=s for i in range(int(m/2)+1): res+=str(a[k])+" " k+=2 if k...
s845259521
p03675
u346308892
1498959708
Python
Python (3.4.3)
py
Runtime Error
196
26180
349
n=int(input()) a=list(map(int,input().split(" "))) a.insert(0,-1) m=len(a)-1 res="" k=m if m%2==0: aa=0 else: aa=1 for i in range(int(m/2)+1): res+=str(a[k])+" " k-=2 if k<=0: break if m%2==0: s=1 else: s=2 k=s for i in range(int(m/2)+1): res+=str(a[k])+" " k+=2 if k...
s073316201
p03675
u817026203
1498959217
Python
PyPy3 (2.4.0)
py
Runtime Error
1803
118928
772
from collections import Counter n = int(input()) xs = [int(c) for c in input().split()] mod = (10 ** 9) + 7 c = Counter(xs) for k, v in c.items(): if v == 2: dup = k dup_idx = [i for i, v in enumerate(xs) if v == dup] facts = [1] for i in range(1, n + 3): facts.append(facts[-1] * i % mod) def inv...
s455151426
p03675
u243492642
1498957813
Python
Python (3.4.3)
py
Runtime Error
70
25412
390
import collections n = int(input()) a = list(map(int, input().split())) b = collections.deque(list) if n % 2 == 0: for i, ele in enumerate(a): if i % 2 == 0: b.append(ele) else: b.appendleft(ele) else: for i, ele in enumerate(a): if i % 2 == 0: b.appen...
s576521344
p03676
u969708690
1597454696
Python
Python (3.8.2)
py
Runtime Error
272
38524
843
import collections def cmb(n, r, mod): if ( r<0 or r>n ): return 0 r = min(r, n-r) return g1[n] * g2[r] * g2[n-r] % mod mod = 10**9+7 #出力の制限 K = 10**5 g1 = [1, 1] # 元テーブル g2 = [1, 1] #逆元テーブル inverse = [0, 1] #逆元テーブル計算用テーブル for i in range( 2, K + 1 ): g1.append( ( g1[-1] * i ) % mod ) inve...
s024219716
p03676
u671861352
1590022193
Python
Python (3.4.3)
py
Runtime Error
364
42332
963
#!python3 def LI(): return list(map(int, input().split())) # input N = int(input()) A = LI() MOD = 10 ** 9 + 7 MAX = 10 ** 5 + 1 fac, finv, inv = [None] * MAX, [None] * MAX, [None] * MAX def comb_init(): fac[0] = fac[1] = 1 finv[0] = finv[1] = 1 inv[1] = 1 for i in range(2, MAX): fac[i]...
s482256921
p03676
u285358283
1589990306
Python
Python (3.4.3)
py
Runtime Error
17
2940
1713
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep1(i, n) for (int i = 1; i <= (int)(n); i++) typedef int64_t Int; struct Combination{ Int MOD, MAX_N; vector<Int> f, f_inv; //---------- 初期化 ---------- Combination(Int mod = 1e9+7, Int max_n = ...
s486923973
p03676
u572142121
1587411004
Python
Python (3.4.3)
py
Runtime Error
382
21600
634
n=int(input()) A=list(map(int, input().split())) B=sorted(A) for i in range(n+1): if B[i]!=i+1: a=i break d=[i for i, x in enumerate(A) if x==a] x=d[0] y=d[1] def cmb(n,r,mod): if (r<0 or r>n): return 0 r=min(r,n-r) return g1[n]*g2[r]*g2[n-r]%mod mod=10**9+7 #出力の制限 N=10**5 g1=[1,1] # 元テーブル...
s489222787
p03676
u572142121
1587409911
Python
Python (3.4.3)
py
Runtime Error
115
14008
634
n=int(input()) A=list(map(int, input().split())) B=sorted(A) for i in range(n+1): if B[i]!=i+1: a=i break d=[i for i, x in enumerate(A) if x==a] x=d[0] y=d[1] def cmb(n,r,mod): if (r<0 or r>n): return 0 r=min(r,n-r) return g1[n]*g2[r]*g2[n-r]%mod mod=10**9+7 #出力の制限 N=10**4 g1=[1,1] # 元テーブル...
s632512553
p03676
u353919145
1580496635
Python
Python (3.4.3)
py
Runtime Error
17
3064
543
mod = 10 ** 9 + 7 f = [0 for _ in range(200000)] f[0] = 1 for i in range(1, 200000): f[i] = f[i - 1] * i % mod inv = [pow(f[i], mod - 2, mod) for i in range(200000)] def C(n, m): if n < m: return 0 return f[n] * inv[m] * inv[n - m] n = int(input()) a = [*map(lambda x: int(x) - 1, input().split())] pos =...
s401890821
p03676
u863370423
1580496367
Python
Python (3.4.3)
py
Runtime Error
17
3064
542
mod = 10 ** 9 + 7 f = [0 for _ in range(100000)] f[0] = 1 for i in range(1, 100000): f[i] = f[i - 1] * i % mod inv = [pow(f[i], mod - 2, mod) for i in range(100000)] def C(n, m): if n < m: return 0 return f[n] * inv[m] * inv[n - m] n = int(input()) a = [*map(lambda x: int(x) - 1, input().split())] pos =...
s073809818
p03676
u863370423
1580496330
Python
PyPy3 (2.4.0)
py
Runtime Error
166
38256
543
mod = 10 ** 9 + 7 f = [0 for _ in range(100000)] f[0] = 1 for i in range(1, 100000): f[i] = f[i - 1] * i % mod inv = [pow(f[i], mod - 2, mod) for i in range(100000)] def C(n, m): if n < m: return 0 return f[n] * inv[m] * inv[n - m] n = int(input()) a = [*map(lambda x: int(x) - 1, input().split())] pos =...
s951568936
p03676
u941407962
1580314565
Python
PyPy3 (2.4.0)
py
Runtime Error
399
67492
775
import sys mod = pow(10, 9) + 7 sys.setrecursionlimit(pow(10, 8)) def mul(a, b): return ((a % mod) * (b % mod)) % mod def cmb(n, r): if ( r<0 or r>n ): return 0 r = min(r, n-r) return g1[n] * g2[r] * g2[n-r] % mod NNN = (10**5) g1 = [1, 1] g2 = [1, 1] inverse = [0, 1] for i in range( 2, NNN ...
s210899447
p03676
u827202523
1574109603
Python
PyPy3 (2.4.0)
py
Runtime Error
387
58640
1280
import sys input = sys.stdin.readline sys.setrecursionlimit(1000000) from collections import deque def getN(): return int(input()) def getList(): return list(map(int, input().split())) import math from collections import deque class SegTree(): def __init__(self, n): self.value = [0 for i in range(n...
s051693096
p03676
u585482323
1566945965
Python
PyPy3 (2.4.0)
py
Runtime Error
343
66332
3059
#!usr/bin/env python3 from collections import defaultdict,deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS():return [list(x) for x in sys.stdin.readline().split()]...
s882422136
p03676
u236127431
1551472456
Python
PyPy3 (2.4.0)
py
Runtime Error
463
99180
1015
N=int(input()) a=[int(i)-1 for i in input().split()] count=[0]*N for i in range(N): count[a[i]]+=1 if count[a[i]]==2: D=a[i] break flag=False k=0 mod=10**9+7 for i in range(N+1): if a[i]==D and not flag: flag=True elif a[i]==D and flag: break elif flag: k+=1 Factorial=[1]*(N+1) for i ...
s227522718
p03676
u858136677
1551392068
Python
Python (3.4.3)
py
Runtime Error
112
19932
1129
import collections def comb(n, r): if n - r < r: r = n - r if r == 0: return 1 if r == 1: return n numerator = [n - r + k + 1 for k in range(r)] denominator = [k + 1 for k in range(r)] for p in range(2,r+1): pivot = denominator[p - 1] if pivot > 1: offset = (n - r)...
s770826903
p03676
u497046426
1542571708
Python
Python (3.4.3)
py
Runtime Error
216
50780
998
# ARC 77 D MOD = 10**9 + 7 n = int(input()) A = list(map(int, input().split())) fact = {i: None for i in range(n+1)} # n! inverse = {i: None for i in range(1, n+1)} # inverse of n in the field Z/(MOD)Z fact_inverse = {i: None for i in range(n+1)} # inverse of n! in the field Z/(MOD)Z fact[0] = ...
s901143065
p03676
u284854859
1535588495
Python
Python (3.4.3)
py
Runtime Error
17
3064
612
n = int(input()) a = list(map(int,input().split())) c = [1,n-1] #c[i]:n-1 C i for i in range(1,n+1): if n < i+2: c.append(0) else: r = (c[-1]*(n-1-i)//(i+1)) c.append(r) k = sum(a)- n*(n+1)//2 pp = [] for i in range(n+1): if a[i] == k: pp.append(i) w = pp[1]-pp[0]-1 d = [1...
s998992852
p03676
u591717585
1531482353
Python
PyPy3 (2.4.0)
py
Runtime Error
171
38256
4896
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; import java.util.NoSuchElementException; public class Main { static PrintWriter out; static InputReader ir; static boolean debug = false; static void solve() { i...
s472138850
p03676
u062147869
1530756616
Python
Python (3.4.3)
py
Runtime Error
645
31976
898
N=int(input()) A=[int(i) for i in input().split()] mod=10**9+7 deni=[1]*(N+1)#(k)!を格納 quot=[1]*(N+1)#(k)!の逆数を格納 for i in range(1,N+1): deni[i]=(deni[i-1]*(i+1))%mod for i in range(1,N+1): t=pow(i+1,mod-2,mod) quot[i]=(quot[i-1]*t)%mod deni=[1]+deni quot=[1]+quot box=[[0,0]]*(N+1) for i in range(N): if b...
s095134310
p03676
u218843509
1527704552
Python
Python (3.4.3)
py
Runtime Error
17
3064
889
MOD = (10 ** 9) + 7 f_list = [1] * 100001 f_r_list = [1] * 100001 for i in range(100000): f_list[i + 1] = int((f_list[i] * (i + 2)) % MOD) def power(n, x): if x == 1: return n elif x % 2 == 0: return power(int((n * n) % MOD), int(x / 2)) else: return int((n * power(n, x - 1)) % MOD) f_r_list[-1] = power(f...
s922889923
p03676
u218843509
1527704464
Python
Python (3.4.3)
py
Runtime Error
299
21748
889
MOD = (10 ** 9) + 7 f_list = [1] * 100000 f_r_list = [1] * 100000 for i in range(99999): f_list[i + 1] = int((f_list[i] * (i + 2)) % MOD) def power(n, x): if x == 1: return n elif x % 2 == 0: return power(int((n * n) % MOD), int(x / 2)) else: return int((n * power(n, x - 1)) % MOD) f_r_list[-1] = power(f_...
s868833055
p03676
u218843509
1527704253
Python
PyPy3 (2.4.0)
py
Runtime Error
301
56928
876
MOD = (10 ** 9) + 7 f_list = [1] * 100000 f_r_list = [1] * 100000 for i in range(99999): f_list[i + 1] = int((f_list[i] * (i + 2)) % MOD) def power(n, x): if x == 1: return n elif x % 2 == 0: return power(int((n * n) % MOD), int(x / 2)) else: return int((n * power(n, x - 1)) % MOD) f_r_list[-1] = power(f_...
s204355436
p03676
u218843509
1527704246
Python
Python (3.4.3)
py
Runtime Error
295
21748
876
MOD = (10 ** 9) + 7 f_list = [1] * 100000 f_r_list = [1] * 100000 for i in range(99999): f_list[i + 1] = int((f_list[i] * (i + 2)) % MOD) def power(n, x): if x == 1: return n elif x % 2 == 0: return power(int((n * n) % MOD), int(x / 2)) else: return int((n * power(n, x - 1)) % MOD) f_r_list[-1] = power(f_...
s420357062
p03676
u846150137
1525126567
Python
Python (3.4.3)
py
Runtime Error
117
23744
359
from statistics import mode n=int(input()) a=[int(i) for i in input().split()] d=mode(a) x=0 lr=0 for i in a: if i==d: x+=1 if x==0 or x==2: lr+=1 lr-=1 b=1 c=1 for i in range(n+1): b *= n + 1 - i b /= i + 1 m=0 if i==0: m+=1 elif lr + 1 -i>=0: c *= lr + 1 -i c /= i m+=int(...
s301305607
p03676
u846150137
1525126399
Python
Python (3.4.3)
py
Runtime Error
115
23680
391
from statistics import mode n=int(input()) a=[int(i) for i in input().split()] d=mode(a) x=0 lr=0 for i in a: if i==d: x+=1 if x==0 or x==2: lr+=1 lr-=1 bb=1 bs=1 cb=1 cs=1 for i in range(n+1): bb *= (n + 1 - i) bs *= (i + 1) m=0 if i==0: m+=1 elif lr + 1 -i>=0: cb *= (lr + 1 -i) ...
s916209223
p03676
u846150137
1525126164
Python
Python (3.4.3)
py
Runtime Error
117
23680
378
from statistics import mode n=int(input()) a=[int(i) for i in input().split()] d=mode(a) x=0 lr=0 for i in a: if i==d: x+=1 if x==0 or x==2: lr+=1 lr-=1 bb=1 bs=1 cb=1 cs=1 for i in range(n+1): bb *= (n + 1 - i) bs *= (i + 1) m=0 if i==0: m+=1 else: cb *= (lr + 1 -i) cs *= (i ) ...
s601701091
p03676
u808427016
1520518465
Python
Python (3.4.3)
py
Runtime Error
85
20184
1053
# https://arc077.contest.atcoder.jp/tasks/arc077_b MOD = 10**9 + 7 from itertools import accumulate F = [1] + list(accumulate(range(1, 10001), lambda x, y:x * y % MOD)) def C(n, r, cache={}): if (n, r) in cache: return cache[n, r] result = F[n] * pow(F[r], MOD - 2, MOD) * pow(F[n - r], MOD - 2, MOD)...
s068524856
p03676
u808427016
1520492068
Python
Python (3.4.3)
py
Runtime Error
79
20184
1049
# https://arc077.contest.atcoder.jp/tasks/arc077_b MOD = 10**9 + 7 from itertools import accumulate F = [1] + list(accumulate(range(1, 10000), lambda x, y:x * y % MOD)) def C(n, r, cache={}): if (n, r) in cache: return cache[n, r] result = F[n] * pow(F[r], MOD - 2, MOD) * pow(F[n - r], MOD - 2, MOD)...
s714762979
p03676
u972669913
1499646282
Python
Python (2.7.6)
py
Runtime Error
936
28828
831
# -*- coding: utf-8 -*- def binary_exp_with_mod(x,n,mod): p = x ret = 1 while n > 0: if n % 2 == 0: p = (p * p) % mod n /= 2 else: ret = (ret * p) % mod n -= 1 return ret n = int(raw_input()) a = map(int, raw_input().split()) BP = 10**9+7 x = -1 j = -1 s = set() for i in rang...
s317382740
p03676
u972669913
1499646245
Python
Python (2.7.6)
py
Runtime Error
940
28724
843
# -*- coding: utf-8 -*- def binary_exp_with_mod(x,n,mod): p = x ret = 1 while n > 0: if n % 2 == 0: p = (p * p) % mod n /= 2 else: ret = (ret * p) % mod n -= 1 return ret n = int(raw_input()) a = map(int, raw_input().split()) BP = 10**9+7 x = -1 j = -1 s = set() for i in rang...
s064268815
p03676
u972669913
1499643966
Python
Python (2.7.6)
py
Runtime Error
855
28448
991
# -*- coding: utf-8 -*- def binary_exp_with_mod(x,n,mod): p = x ret = 1 while n > 0: if n % 2 == 0: p = (p * p) % mod n /= 2 else: ret = (ret * p) % mod n -= 1 return ret n = int(raw_input()) a = map(int, raw_input().split()) BP = 10**9+7 x = -1 j = -1 s = set() for i in rang...
s419454229
p03676
u329749432
1499622308
Python
Python (3.4.3)
py
Runtime Error
2293
746664
436
from collections import Counter n=int(input()) s=[int(i) for i in input().split()] div=int(10**9+7) c = Counter(s) j=-1 for i in range(1, n + 1): if c[i] == 2: j = i break a, b = [i for i in range(n + 1) if s[i] == j] f=[1] t=1 for i in range(1,n+2): t=t*i f.append(t) for i in range(1,n+...
s354543721
p03676
u340781749
1499181877
Python
Python (3.4.3)
py
Runtime Error
2115
252424
851
import sys sys.setrecursionlimit(100001) def get_ncr(div): cache = {} def f(*args): if args in cache: return cache[args] n, r = args if r == 0 or n == r: cache[args] = 1 return 1 cache[args] = (f(n - 1, r) + f(n - 1, r - 1)) % div r...
s043779409
p03676
u340781749
1499181804
Python
Python (3.4.3)
py
Runtime Error
2115
252368
851
import sys sys.setrecursionlimit(100000) def get_ncr(div): cache = {} def f(*args): if args in cache: return cache[args] n, r = args if r == 0 or n == r: cache[args] = 1 return 1 cache[args] = (f(n - 1, r) + f(n - 1, r - 1)) % div r...
s601366422
p03676
u340781749
1499180013
Python
Python (3.4.3)
py
Runtime Error
2115
260436
1092
import sys sys.setrecursionlimit(100000) def get_ncr(): cache = {} def f(*args): if args in cache: return cache[args] n, r = args if r == 0 or n == r: cache[args] = 1 return 1 cache[args] = f(n - 1, r) + f(n - 1, r - 1) return cache...
s142706643
p03676
u340781749
1499179692
Python
Python (3.4.3)
py
Runtime Error
111
13812
1048
def get_ncr(): cache = {} def f(*args): if args in cache: return cache[args] n, r = args if r == 0 or n == r: cache[args] = 1 return 1 cache[args] = f(n - 1, r) + f(n - 1, r - 1) return cache[args] return f def find_duplicated(a...
s466029116
p03676
u635974378
1498969336
Python
Python (3.4.3)
py
Runtime Error
2104
10420
1139
n = int(input()) seq = input().split() lc = 'a' already = [] for idx,c in enumerate(seq): if c in already: break already.append(c) lc = c left = seq.index(c) right = list(reversed(seq)).index(c) middle = n-left-right-2 # print(left,middle,right,lc) # print(seq) NUM = 10**9+7 # def f(n): # if n...
s380660557
p03676
u635974378
1498969184
Python
Python (3.4.3)
py
Runtime Error
2104
10420
1140
n = int(input()) seq = input().split() lc = 'a' already = [] for idx,c in enumerate(seq): if c in already: break already.append(c) lc = c left = seq.index(c) right = list(reversed(seq)).index(c) middle = n-left-right-2 # print(left,middle,right,lc) # print(seq) NUM = 10**9+7 # def f(n): # if n...
s847018732
p03676
u635974378
1498968977
Python
Python (3.4.3)
py
Runtime Error
2104
10420
1140
n = int(input()) seq = input().split() lc = 'a' already = [] for idx,c in enumerate(seq): if c in already: break already.append(c) lc = c left = seq.index(c) right = list(reversed(seq)).index(c) middle = n-left-right-2 # print(left,middle,right,lc) # print(seq) NUM = 10**9+7 # def f(n): # if n...
s073796175
p03676
u635974378
1498968424
Python
Python (3.4.3)
py
Runtime Error
2104
11892
995
n = int(input()) seq = input().split() lc = 'a' already = [] for idx,c in enumerate(seq): if c in already: break already.append(c) lc = c left = seq.index(c) right = list(reversed(seq)).index(c) middle = n-left-right-2 # print(left,middle,right,lc) # print(seq) NUM = 10**9+7 def f(n): if n<=1:...
s970105858
p03676
u635974378
1498967881
Python
Python (3.4.3)
py
Runtime Error
2104
10420
999
n = int(input()) seq = input().split() lc = 'a' already = [] for idx,c in enumerate(seq): if c in already: break already.append(c) lc = c left = seq.index(c) right = list(reversed(seq)).index(c) middle = n-left-right-2 # print(left,middle,right,lc) # print(seq) NUM = 10**9+7 def f(n): if n<=1:...