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
s531419416
p03611
u112465297
1504759289
Python
Python (3.4.3)
py
Runtime Error
17
3060
138
a = list(map(int, input().split())) cnt=[0]*10000 print(a) for t in a: cnt[t] += 1 cnt[t-1] += 1 cnt[t+1] += 1 print(max(cnt))
s724290008
p03611
u010110540
1504577557
Python
Python (3.4.3)
py
Runtime Error
74
14776
151
n = int(input()) cnt = [0] * 100001 a = list(map(int, input().split())) for v in a: cnt[v] += 1 cnt[v+1] += 1 cnt[v+2] += 1 print(max(cnt))
s838021113
p03611
u676264453
1504564850
Python
Python (3.4.3)
py
Runtime Error
63
13964
309
N = int(input()) ls = list(map(int, input().split(' '))) d = {} for l in ls: if l in d: d[l] += 1 else: d[l] = 1 m = 0 for k in range(1, 100002): if k in d: c += d[k] if (k-1) in d: c += d[k-1] if (k+1) in d: c += d[k+1] m = max(m,c) print(m)
s047506008
p03611
u676264453
1504564778
Python
Python (3.4.3)
py
Runtime Error
116
14088
608
N = int(input()) ls = list(map(int, input().split(' '))) d = {} for l in ls: if l in d: d[l] += 1 else: d[l] = 1 m = 0 keys = sorted(d.keys()) for k in keys: c = d[k] if (k-1) in d: c += d[k-1] if (k+1) in d: c += d[k+1] m = max(m,c) print(m) N = int(input()) ls ...
s653016906
p03611
u191214791
1504412319
Python
Python (3.4.3)
py
Runtime Error
84
14212
2003
# encoding: "utf-8" from collections import defaultdict # class Stdin: # @staticmethod # def read_line(converter=str): # return [converter(x) for x in input().split()] # @staticmethod # def read_lines(n, converter=str): # result = list() # for _ in range(n): # ...
s857405870
p03611
u191214791
1504412294
Python
Python (3.4.3)
py
Runtime Error
83
14212
2003
# encoding: "utf-8" from collections import defaultdict # class Stdin: # @staticmethod # def read_line(converter=str): # return [converter(x) for x in input().split()] # @staticmethod # def read_lines(n, converter=str): # result = list() # for _ in range(n): # ...
s887585637
p03611
u191214791
1504408915
Python
Python (3.4.3)
py
Runtime Error
2104
14324
1271
# encoding: "utf-8" class Stdin: @staticmethod def read_line(converter=str): return [converter(x) for x in input().split()] @staticmethod def read_lines(n, converter=str): result = list() for _ in range(n): result.append(Stdin.read_line(converter)) retur...
s999836450
p03611
u255555420
1504408412
Python
Python (3.4.3)
py
Runtime Error
41
13964
167
N=int(input()) a=list(map(int,input().split())) count = [0]*100002 for a in a_list: count[a] += 1 count[a+1] += 1 count[a+2] += 1 print(max(count))
s629081854
p03611
u785205215
1504407602
Python
Python (3.4.3)
py
Runtime Error
108
13964
246
n = int(input()) a = [int(i) for i in input().split()] max_num = max(a) cnt = [0]*(max_num+1) for i in a: cnt[i] = cnt[i]+1 maxn = cnt[0] + cnt[1] for i in range(max_num): maxn = max(maxn, cnt[i-1] + cnt[i] + cnt[i+1]) print(maxn)
s413461769
p03611
u768816323
1504406931
Python
Python (3.4.3)
py
Runtime Error
17
3064
309
# your code goes here n=int(input()) a=[int(i) for i in input().split()] a.sort() i=0 x=0 j=0 k=0 while j<len(a) and a[j]-a[i]<1: j+=1 k=j+1 while k<len(a): while k<len(a) and a[k]-a[j]<1: k+=1 if k<len(a): if x<k-i: x=k-i i=j j=k k=j print(x)j
s204745269
p03611
u768816323
1504406690
Python
Python (3.4.3)
py
Runtime Error
18
2940
283
your code goes here n=int(input()) a=[int(i) for i in input().split()] a.sort() i=0 x=0 j=0 k=0 while j<len(a) and a[j]-a[i]<1: j+=1 k=j+1 while k<len(a) and a[k]-a[j]<1: k+=1 if k<len(a): if x<k-i: x=k-i i=j j=k k=j print(x)
s637126204
p03611
u619384481
1504406005
Python
Python (2.7.6)
py
Runtime Error
80
11316
172
a=input() b=map(int,raw_input().split()) c=[] for i in range(100000): c.append(0) for i in b: c[i]+=1 c[i+1]+=1 c[i+2]+=1 c.sort() c.reverse() print c[0]
s646681004
p03611
u665415433
1504405874
Python
Python (3.4.3)
py
Runtime Error
2104
13964
655
def solve(): N = int(input()) a = list(map(int, input().split())) ans = 0 n=0 check = 0 checkmm = 0 checkm = 0 a.sort() for i in a: if i == i-1: break if i-2 in a: checkmm = checkm else: checkmm = 0 if i-1 in a: ...
s107147822
p03611
u142415823
1504405548
Python
Python (3.4.3)
py
Runtime Error
65
13964
333
import sys def main(): N = int(sys.stdin.readline()) a = list(map(int, input().split())) n = [0 for i in range(0, max(a)+1)] for i in a: n[i] += 1 if len(a) < 2: print(sum(n)) else: print(max([i+j+k for i, j, k in zip(n[:-2], n[1:-1], n[2:])])) if __name__ == '__main__'...
s444928079
p03611
u455591217
1504404610
Python
Python (3.4.3)
py
Runtime Error
2104
139476
488
N = int(input()) A = list(map(int, input().split(' '))) A2 = sorted(A) countQ = [A2.pop(0)] maxAns = 1 while A2: a = A2.pop(0) if countQ[0] + 2 >= a: countQ.append(a) print(countQ) else: tmp = len(countQ) if maxAns < tmp: maxAns = tmp countQ.append(a) ...
s763443616
p03611
u142415823
1504404069
Python
Python (3.4.3)
py
Runtime Error
65
14004
278
import sys def main(): N = int(sys.stdin.readline()) a = list(map(int, input().split())) n = [0 for i in range(0, max(a)+1)] for i in a: n[i] += 1 print(max([i+j+k for i, j, k in zip(n[:-2], n[1:-1], n[2:])])) if __name__ == '__main__': main()
s505210008
p03611
u142415823
1504403417
Python
Python (3.4.3)
py
Runtime Error
66
14008
271
import sys def main(): N = int(sys.stdin.readline()) a = list(map(int, input().split())) n = [0 for i in range(0, max(a)+1)] for i in a: n[i] += 1 print(max([i+j+k for i, j, k in zip(n, n[1:], n[2:])])) if __name__ == '__main__': main()
s010755227
p03611
u205803237
1504402724
Python
Python (3.4.3)
py
Runtime Error
2104
10712
507
N = int(input()) A = input().split() ans = 1 A__ = [] for i in A: if i not in A__: A__.append(i) A_ = {} for i in A__: A_[int(i)] = A.count(i) for a in A__: a_ = int(a) - 1 if a_ >= 0: est = A_[a_-1] + A_[a_] + A_[a_+1] ans = max(ans, est) a_ = int(a) if a_ >= 0: ...
s892701009
p03611
u205803237
1504402627
Python
Python (3.4.3)
py
Runtime Error
2104
15040
519
N = int(input()) A = input().split() ans = 1 A_ = {} for i in range(-1, 10**5+1): A_[i] = A.count(str(i)) A__ = [] for i in A: if i not in A__: A__.append(i) for a in A__: a_ = int(a) - 1 if a_ >= 0: est = A_[a_-1] + A_[a_] + A_[a_+1] ans = max(ans, est) a_ = int(a) if...
s346041638
p03611
u190405389
1504402623
Python
Python (3.4.3)
py
Runtime Error
198
35040
209
import statistics N = int(input()) a = list(map(int, input().split())) b = [] c = [] for i in range(N): b.append(a[i] - 1) c.append(a[i] + 1) x = a + b + c y = statistics.mode(x) print(x.count(y))
s478473762
p03611
u086049681
1504402581
Python
Python (3.4.3)
py
Runtime Error
2104
15124
252
N = int(input()) s1 = input() s1 = [int(n) for n in s1.split()] s1 = s1[:N] dict = {} for n in range(max(s1)): count = 0 for val in s1: if val in [n,n+1,n+2]: count += 1 dict.update({n+1:count}) print (sorted(dict.values())[-1])
s116801894
p03611
u642905089
1504402518
Python
Python (3.4.3)
py
Runtime Error
127
14008
309
n = input() a = list(map(int,input().split())) a.sort() hist = [0 for x in range(-1,max(a)+3)] As = [] ans = -1 Aspd = As.append if len(a) ==1: ans = a[0] else: for i in a: hist[i] += 1 for i in range(len(hist)-1): Aspd(hist[i-1]+hist[i]+hist[i+1]) print(max(As))
s504649232
p03611
u086049681
1504402490
Python
Python (3.4.3)
py
Runtime Error
2104
4792
243
N = int(input()) s1 = input()[:N] s1 = [int(n) for n in s1.split()] dict = {} for n in range(max(s1)): count = 0 for val in s1: if val in [n,n+1,n+2]: count += 1 dict.update({n+1:count}) print (sorted(dict.values())[-1])
s283775564
p03611
u086049681
1504402241
Python
Python (3.4.3)
py
Runtime Error
18
4280
235
N = int(input()) s1 = input()[:N] s1 = [int(n) for n in s1] dict = {} for n in range(max(s1)): count = 0 for val in s1: if val in [n,n+1,n+2]: count += 1 dict.update({n+1:count}) print (sorted(dict.values())[-1])
s023006994
p03611
u099918199
1504401951
Python
Python (3.4.3)
py
Runtime Error
17
3064
285
a = input() l = a.split() n = int(l[0]) l.pop(0) for i in range(n): l[i] = int(l[i]) counting = 0 list_i = [] for i in range(100000): counting = 0 for j in range(n): if (l[j] == i or l[j] == i-1 or l[j] == i+1): counting += 1 list_i.append(counting) print(max(list_i))
s668812856
p03611
u099918199
1504401896
Python
Python (3.4.3)
py
Runtime Error
17
3064
285
a = input() l = a.split() n = int(l[0]) l.pop(0) for i in range(n): l[i] = int(l[i]) counting = 0 list_i = [] for i in range(100000): counting = 0 for j in range(n): if (l[j] == i or l[j] == i-1 or l[j] == i+1): counting += 1 list_i.append(counting) print(max(list_i))
s056471526
p03611
u552668967
1504400989
Python
Python (2.7.6)
py
Runtime Error
10
2568
269
from sys import stdin di = {} n = int(stdin.readline()) a = map(int,stdin.readline().split()) for i in a: di[i] = di.get(i,0) + 1 di[i-1] = di.get(i-1,0) + 1 di[i+1] = di.get(i+1,0) + 1 ans = -5 print di for i in di: if di[i] > di.get(ans,0): ans = print di[ans]
s872971438
p03612
u623814058
1601499442
Python
Python (3.8.2)
py
Runtime Error
48
20560
111
N=int(input()) *P,=map(int,input().split()) i=c=0 while i<L: if P[i]==i+1: c+=1 i+=1 i+=1 print(c)
s741958328
p03612
u732061897
1601348681
Python
Python (3.8.2)
py
Runtime Error
84
20576
252
N = int(input()) P = list(map(int, input().split())) ans = 0 for i in range(N): if i == N-1: if P[i] == i+1: ans +=1 a, b = P[i], P[i + 1] if a == i + 1: ans += 1 P[i] = b P[i + 1] = a print(ans)
s828157761
p03612
u773440446
1600654219
Python
Python (3.8.2)
py
Runtime Error
72
24584
193
n = int(input()) m = [i for i in range(1,n+1)] p = list(map(int,input().split())) cnt = 0 for i in m: if p[i-1] == i: p[i-1] = p[i] p[i] = i cnt += 1 print(cnt)
s929508221
p03612
u753386263
1600558889
Python
PyPy3 (7.3.0)
py
Runtime Error
104
85720
408
N = int(input()) p=list(map(int, input().split())) #前と後ろどっちと交換すればよいか ans=0 for i in range(N): if i<N-1: if p[i]==i+1: a=p[i] b=p[i+1] p[i]=b p[i+1]=a ans+=1 if i==N-1: if p[i]==i+1: a=p[i] b=p[i-1] p[...
s953969028
p03612
u753386263
1600558759
Python
PyPy3 (7.3.0)
py
Runtime Error
107
85268
778
N = int(input()) p=list(map(int, input().split())) #前と後ろどっちと交換すればよいか ans=0 for i in range(N): if i==0:#このときは計算方針1個しかない if p[i]==i+1: a=p[i] b=p[i+1] p[i]=b p[i+1]=a ans+=1 if 0<i<N-1: if p[i]==i+1: if p[i+1]==i+2: ...
s325235931
p03612
u753386263
1600558467
Python
PyPy3 (7.3.0)
py
Runtime Error
104
90636
432
N = int(input()) p=list(map(int, input().split())) p_=[i for i in range(1,N+1)] #前と後ろどっちと交換すればよいか ans=0 for i in range(N): if p[i]==i+1: if i<N-1 and p[i+1]==i+2: a=p[i] b=p[i+1] p[i]=b p[i+1]=a ans+=1 else: a=p[i] b...
s677613918
p03612
u980205854
1599585867
Python
PyPy3 (7.3.0)
py
Runtime Error
109
87404
1051
import sys from sys import exit from collections import deque from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値) from heapq import heapify, heappop, heappush from math import * sys.setrecursionlimit(10**6) INF = 10**20 eps = 1.0e-20 MOD = 10**9+7 def lcm(x,y): return x*y//gcd(x,y...
s624797836
p03612
u409306788
1599475519
Python
Python (3.8.2)
py
Runtime Error
82
20740
491
import sys input = sys.stdin.readline # D - Derangement def swap(index, swap_with_right): global p if swap_with_right: l = index r = index + 1 else: l = index - 1 r = index pl = p[l] pr = p[r] p[l] = pr p[r] = pl N = int(input()) p = list(map(int, input().split())) p.insert(0, 0) ans...
s487519074
p03612
u017050982
1599445757
Python
PyPy3 (7.3.0)
py
Runtime Error
100
85020
367
N = int(input()) p = list(map(int,input().rstrip().split(" "))) ans = 0 swap = 0 for i in range(N): if p[i] == i + 1: if i != N: swap = p[i] p[i] = p[i + 1] p[i + 1] = swap ans += 1 else: swap = p[i] p[i] = p[i - 1] ...
s569805774
p03612
u409306788
1599383712
Python
PyPy3 (7.3.0)
py
Runtime Error
88
74668
433
D - Derangement def swap(index, swap_with_right): global p if swap_with_right: l = index r = index + 1 else: l = index - 1 r = index pl = p[l] pr = p[r] p[l] = pr p[r] = pl N = int(input()) p = list(map(int, input().split())) p.insert(0, 0) ans = 0 if p[1] == 1: swap(1, True) an...
s583571541
p03612
u271064067
1599361713
Python
Python (3.8.2)
py
Runtime Error
76
20096
274
n = int(input()) p = [int(x) for x in input().split()] ans = 0 index = 0 while index <= n-1: if p[index] == index+1: if p[index+1] != index+2: index += 1 else: index += 2 ans += 1 else: index += 1 print(ans)
s840318008
p03612
u255673886
1599261266
Python
PyPy3 (7.3.0)
py
Runtime Error
136
89708
2397
from collections import deque from heapq import heapify,heappop,heappush,heappushpop from copy import copy,deepcopy from itertools import product,permutations,combinations,combinations_with_replacement from collections import defaultdict,Counter from bisect import bisect_left,bisect_right from math import gcd,ceil,floo...
s853039445
p03612
u394244719
1598673980
Python
Python (3.8.2)
py
Runtime Error
71
20720
503
import sys inint = lambda: int(sys.stdin.readline()) inintm = lambda: map(int, sys.stdin.readline().split()) inintl = lambda: list(inintm()) instrm = lambda: map(str, sys.stdin.readline().split()) instrl = lambda: list(instrm()) n = inint() P = inintl() ans = 0 if n == 2: if P[0] == 1: print(1) ...
s587031216
p03612
u247830763
1598269647
Python
Python (3.8.2)
py
Runtime Error
80
22364
538
import sys sys.setrecursionlimit(10000) n = int(input()) ls = list(map(int,input().split())) di = [] ans = 0 def culc(n): if n == 1: return 1 elif n == 2: return 1 else: if n % 2 == 0: a = culc(n/2)*2 else: a = culc(n/2)+culc((n/2)+1) return a...
s735471389
p03612
u247830763
1598269620
Python
PyPy3 (7.3.0)
py
Runtime Error
152
101440
538
import sys sys.setrecursionlimit(10000) n = int(input()) ls = list(map(int,input().split())) di = [] ans = 0 def culc(n): if n == 1: return 1 elif n == 2: return 1 else: if n % 2 == 0: a = culc(n/2)*2 else: a = culc(n/2)+culc((n/2)+1) return a...
s054788513
p03612
u108934099
1598054631
Python
Python (3.8.2)
py
Runtime Error
77
20592
176
N = int(input()) A = list(map(int,input().split())) cnt = 0 for i in range(N): if A[i] == i+1: A[i],A[i+1] = A[i+1],A[i] cnt += 1 i += 1 print(cnt)
s900700013
p03612
u688219499
1597260832
Python
Python (3.8.2)
py
Runtime Error
70
20548
175
n = int(input()) p = list(map(int, input().split())) count = 0 for i in range(n): if p[i] - 1 == i: count += 1 p[i] ,p[i + 1] = p[i + 1], p[i] print(count)
s693372945
p03612
u968404618
1596942255
Python
Python (3.8.2)
py
Runtime Error
89
20440
1037
n = int(input()) P = list(map(int, input().split())) ans = 0 Cnt = [] for idx, p in enumerate(P, 1): if idx == p: Cnt.append(idx) #print(Cnt) if len(Cnt) == 0: ans = 0 elif len(Cnt) == 2: ans += Cnt[1] - Cnt[0] elif len(Cnt) %2: for i in range(1, len(Cnt), 2): if i == 0: a...
s125497008
p03612
u869790980
1596941317
Python
PyPy2 (7.3.0)
py
Runtime Error
368
85212
436
n = int(raw_input()) h = {} for i,a in enumerate(map(int, raw_input())): i += 1 if a != i: h[a] = i def get(u, parent): if parent[u] != u: parent[u] = get(parent[u], parent) return parent[u] parent = {u:u for u in h} sizes = {u:1 for u in h} for u in h: v = h[u] pu,pv = get(u, parent), get(v, parent) if pu...
s310758336
p03612
u962718741
1596816316
Python
Python (3.8.2)
py
Runtime Error
31
17280
233
def main(): N = int(input()) P = map(int, input().split()) cnt = 0 for i in range(N): if P[i] == i + 1: cnt += 1 ans = (cnt + 1) // 2 print(ans) if __name__ == "__main__": main()
s996793232
p03612
u545368057
1596803919
Python
Python (3.8.2)
py
Runtime Error
70
20636
220
# 前から順番に後ろに向けてswap n = int(input()) ps = list(map(int, input().split())) cnt = 0 for i, p in enumerate(ps): if i + 1 == p: ps[i], ps[i+1] = ps[i+1], ps[i] cnt += 1 print(cnt)
s438107958
p03612
u986254798
1596663244
Python
Python (3.8.2)
py
Runtime Error
71
20548
212
n = int(input()) arr = list(map(int, input().split())) ans = 0 for i in range(n): if arr[i] == i + 1: ans += 1 arr[i+1], arr[i] = arr[i], arr[i+1] if arr[n-1] == n: ans += 1 print (ans)
s945135494
p03612
u986254798
1596663146
Python
Python (3.8.2)
py
Runtime Error
74
20456
181
n = int(input()) arr = list(map(int, input().split())) ans = 0 for i in range(n): if arr[i] == i + 1: ans += 1 arr[i+1], arr[i] = arr[i], arr[i+1] print (ans)
s107239519
p03612
u212502386
1596334315
Python
Python (3.8.2)
py
Runtime Error
74
20516
149
N=int(input()) p=list(map(int,input().split())) ans=0 for i in range(N): if p[i]==i+1: p[i],p[i+1]=p[i+1],p[i] ans+=1 print(ans)
s429814946
p03612
u536034761
1596270618
Python
Python (3.8.2)
py
Runtime Error
76
20556
329
N = int(input()) A = list(map(int, input().split())) cnt = 0 for i, a in enumerate(A, 1): if a == i: if i != len(A) + 1: x = A[i - 1] y = A[i] A[i - 1] = y A[i] = x cnt += 1 else: x = A[i - 2] y = A[i - 1] A[i - 2] = y A[i - 1] = x cnt += 1 p...
s562068995
p03612
u536034761
1596269583
Python
Python (3.8.2)
py
Runtime Error
57
20564
330
N = int(input()) A = list(map(int, input().split())) cnt = 0 for i, a in enumerate(A, 1): if a == i: if i == len(A) + 1: x = a[i - 1] y = a[i] a[i - 1] = y a[i] = x cnt += 1 else: x = a[i - 2] y = a[i - 1] a[i - 2] = y a[i - 1] = x cnt += 1 p...
s713427342
p03612
u536034761
1596269438
Python
Python (3.8.2)
py
Runtime Error
52
20580
190
N = int(input()) A = list(map(int, input().split())) cnt = 0 for i, a in enumerate(A, 1): if a == i: x = a[i - 1] y = a[i] a[i - 1] = y a[i] = x cnt += 1 print(cnt)
s422309897
p03612
u107639613
1595981539
Python
PyPy3 (7.3.0)
py
Runtime Error
104
86188
340
import sys from collections import deque def input(): return sys.stdin.readline().strip() def main(): N = int(input()) P = [0] + list(map(int, input().split())) ans = 0 for i in range(1, N + 1): if i == P[i]: P[i + 1] = P[i] ans += 1 print(ans) if __name__ == "__...
s576371389
p03612
u317779196
1595444653
Python
Python (3.8.2)
py
Runtime Error
71
20008
285
n = int(input()) p = [int(i) for i in input().split()] ''' i == x となる点で、i+1とスワップする 境界に注意 ''' ans = 0 for i in range(n): if i < n and p[i] == i+1: p[i+1] = p[i] ans += 1 elif i == n and p[i] == i+1: ans += 1 print(ans)
s948477071
p03612
u279493135
1595224030
Python
Python (3.8.2)
py
Runtime Error
81
21320
918
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement from operator import itemgetter, mul from copy import deepcopy from s...
s850648608
p03612
u060432908
1595145870
Python
Python (3.8.2)
py
Runtime Error
69
20640
148
n=int(input()) p=list(map(int,input().split())) ans=0 for i in range(n): if i+1==p[i]: p[i],p[i+1]=p[i+1],p[i] ans+=1 print(ans)
s795476955
p03612
u976225138
1595057630
Python
Python (3.8.2)
py
Runtime Error
75
20052
201
n = int(input()) p = [int(x) for x in input().split()] cnt = 0 for i in range(n): if p[i] == i + 1: cnt += 1 if i != n: p[i], p[i+1] = p[i+1], p[i] else: print(cnt)
s019972462
p03612
u976225138
1595057048
Python
Python (3.8.2)
py
Runtime Error
77
20040
216
_ = input() p = [int(x) for x in input().split()] lenp = len(p) cnt = 0 for i in range(lenp): if p[i] == i + 1: cnt += 1 if i != lenp: p[i], p[i+1] = p[i+1], p[i] else: print(cnt)
s306279659
p03612
u976225138
1595055975
Python
Python (3.8.2)
py
Runtime Error
71
19972
178
_ = input() p = [int(x) for x in input().split()] cnt = 0 for i in range(len(p)): if p[i] == i + 1: p[i], p[i+1] = p[i+1], p[i] cnt += 1 else: print(cnt)
s766137400
p03612
u028973125
1594874396
Python
Python (3.8.2)
py
Runtime Error
73
20612
213
import sys N = int(sys.stdin.readline()) P = list(map(int, sys.stdin.readline().split())) ans = 0 for i, p_i in enumerate(P): if p_i == i + 1: P[i+1], P[i] = P[i], P[i+1] ans += 1 print(ans)
s817897525
p03612
u780698286
1594860702
Python
Python (3.8.2)
py
Runtime Error
73
20644
153
n = int(input()) a = list(map(int, input().split())) ans = 0 for i in range(n): if i+1 == a[i]: ans += 1 a[i], a[i+1] = a[i+1], a[i] print(ans)
s269031942
p03612
u088863512
1594790489
Python
Python (3.8.2)
py
Runtime Error
67
20892
716
# -*- coding: utf-8 -*- import sys from collections import deque, defaultdict from math import sqrt, factorial, gcd # def input(): return sys.stdin.readline()[:-1] # warning not \n # def input(): return sys.stdin.buffer.readline().strip() # warning bytes # def input(): return sys.stdin.buffer.readline().decode('utf-8')...
s237993747
p03612
u370721525
1594490735
Python
Python (3.8.2)
py
Runtime Error
71
20644
216
N = int(input()) p = list(map(int, input().split())) i = 0 ans = 0 while i < N: if p[i] == i+1: if p[i+1] == i+2: ans += 1 i += 2 else: ans += 1 i += 1 else: i += 1 print(ans)
s174493255
p03612
u075304271
1594399239
Python
Python (3.8.2)
py
Runtime Error
25
10200
298
def solve(): n = int(input()) p = list(map(int, input())) cnt = 0 for i in range(n-1): if p[i] == i + 1: if p[i] == n: p[i], p[i-1] = p[i-1], p[i] else: p[i], p[i+1] = p[i], p[i+1] cnt += 1 print(cnt) return 0 if __name__ == "__main__": solve()
s094521308
p03612
u075304271
1594399208
Python
Python (3.8.2)
py
Runtime Error
30
10264
301
def solve(): n = int(input()) p = list(map(int, input())) cnt = 0 for i in range(len(p)): if p[i] == i + 1: if p[i] == n: p[i], p[i-1] = p[i-1], p[i] else: p[i], p[i+1] = p[i], p[i+1] cnt += 1 print(cnt) return 0 if __name__ == "__main__": solve()
s707446786
p03612
u075304271
1594399070
Python
Python (3.8.2)
py
Runtime Error
29
10124
295
def solve(): n = int(input()) p = list(map(int, input())) cnt = 0 for i in range(n): if p[i] == i + 1: if p[i] == n: p[i], p[i-1] = p[i-1], p[i] else: p[i], p[i+1] = p[i], p[i+1] cnt += 1 print(cnt) return 0 if __name__ == "__main__": solve()
s776614944
p03612
u780698286
1594233655
Python
Python (3.8.2)
py
Runtime Error
70
20472
153
n = int(input()) p = list(map(int, input().split())) ans = 0 for i in range(n): if p[i] == i+1: p[i], p[i+1] = p[i+1], p[i] ans += 1 print(ans)
s365930203
p03612
u143051858
1594131501
Python
Python (3.8.2)
py
Runtime Error
21
9000
127
n = int(input()) a = list(map(int,input().split())) res = 0 for i in range(2,n: if a[i-1] == i: res += 1 print(res)
s406053910
p03612
u143051858
1594131093
Python
Python (3.8.2)
py
Runtime Error
75
20492
263
n = int(input()) a = list(map(int,input().split())) res = 0 i = 1 while i < n+1: if a[i-1] == i: res += 1 while a[i-1] == i: res+=1 i+=1 if i < n+1: break res -= 1 i+=1 print(res)
s884651691
p03612
u143051858
1594130911
Python
Python (3.8.2)
py
Runtime Error
72
20408
228
n = int(input()) a = list(map(int,input().split())) res = 0 flg = True i = 1 while i < n+1: if a[i-1] == i: res += 1 while a[i-1] == i: res+=1 i+=1 res -= 1 i+=1 print(res)
s661006090
p03612
u440975163
1593534520
Python
Python (3.8.2)
py
Runtime Error
47
20564
212
n = int(input()) a = list(map(int, input().split())) ans = 0 for i in range(n - 1): if a[i] == i + 1: a[i], a[i + 1] = a[i + 1], a[i] ans += 1 if a[n] == n + 1: ans += 1 print(ans)
s849915345
p03612
u750651325
1593089246
Python
Python (3.8.2)
py
Runtime Error
77
21336
625
import sys import math import itertools import bisect from copy import copy from collections import deque,Counter from decimal import Decimal def s(): return input() def i(): return int(input()) def S(): return input().split() def I(): return map(int,input().split()) def X(): return list(input()) def L(): return list(i...
s195155801
p03612
u750651325
1592827228
Python
Python (3.8.2)
py
Runtime Error
72
20636
193
N = int(input()) p = list(map(int, input().split())) count = 0 i = 0 while N > i: if p[i]-1 == i: p[i],p[i+1] = p[i+1],p[i] count += 1 i += 1 i+=1 print(count)
s874192739
p03612
u629350026
1592704036
Python
Python (3.8.2)
py
Runtime Error
84
20636
168
n=int(input()) p=list(map(int,input().split())) ans=0 for i in range(n): if p[i]==i+1: ans=ans+1 if p!=n-1: if p[i+1]==i+2: ans=ans-1 print(ans)
s395700392
p03612
u443736699
1592495462
Python
Python (3.4.3)
py
Runtime Error
78
14008
348
n = int(input()) a = list(map(int,input().strip().split())) ordered = [i for i in range(1,n+1)] i = 0 count = 0 if a[count] == ordered[count]: tmp = a[count] a[count] = a[count+1] a[count+1] = tmp count += 1 i += 1 for i in range(n): if a[i] == ordered[i]: tmp = a[i] a[i] = a[i+1] a[i+1] = tmp ...
s102321121
p03612
u771167374
1591974865
Python
Python (3.4.3)
py
Runtime Error
78
14008
196
n = int(input()) p = list(map(int, input().split())) q = [i for i in range(1, n+1)] cnt = 0 for j in range(n): if p[j] == q[j]: p[j], p[j+1] = p[j+1], p[j] cnt += 1 print(cnt)
s968586522
p03612
u185424824
1591728073
Python
PyPy3 (2.4.0)
py
Runtime Error
216
53292
229
N = int(input()) p = list(map(int,input().split())) ans = 0 for i in range(N): if p[i] == i+1: p[i] = -1 else: p[i] = 0 for j in range(N): if p[j] == -1: ans += 1 p[j] = 0 p[j+1] = 0 print(ans)
s643505537
p03612
u614181788
1591662603
Python
Python (3.4.3)
py
Runtime Error
72
13880
154
n = int(input()) p = list(map(int,input().split())) c = 0 for i in range(n): if p[i] == i+1: p[i],p[i+1] = p[i+1],p[i] c += 1 print(c)
s560791556
p03612
u178079174
1591500370
Python
Python (3.4.3)
py
Runtime Error
74
14008
164
N = int(input()) P = list(map(int,input().split())) count = 0 for i in range(N): if P[i] == i+1: P[i],P[i+1]=P[i+1],P[i] count += 1 print(count)
s356805478
p03612
u670961163
1591451201
Python
PyPy3 (2.4.0)
py
Runtime Error
222
52332
665
def main(): n = int(input()) inlis= list(map(int, input().split())) ans = 0 for i in range(n-1,-1): if inlis[i] != i+1: break else: #print(inlis) #print("mae", inlis[i]) a = inlis[i-1] inlis[i] = a inlis[i-1] = i+1 ...
s199150307
p03612
u506086925
1591151741
Python
Python (3.4.3)
py
Runtime Error
72
14008
187
n = int(input()) pp = list(map(int, input().split())) cnt = 0 for idx, p in enumerate(pp): if p == idx + 1: pp[idx], pp[idx+1] = pp[idx+1], pp[idx] cnt += 1 print(cnt)
s655412235
p03612
u248670337
1591068574
Python
Python (3.4.3)
py
Runtime Error
85
14008
190
n=int(input()) A=list(map(int,input().split())) c=0 for i,a in enumerate(A): i+=1 if i*a==1: c+=1 A[0]=A[1] A[1]=1 elif i==a: c+=1 A[i]=A[i-1] A[i-1]=i print(c)
s119768736
p03612
u959682820
1590812886
Python
Python (3.4.3)
py
Runtime Error
81
14008
192
n = int(input()) p = list(map(int, input().split())) for i in range(n): p[i] -= 1 ans = 0 for i in range(n): if p[i] == i: ans += 1 p[i], p[i+1] = p[i+1], p[i] print(ans)
s667643032
p03612
u488884575
1590794770
Python
Python (3.4.3)
py
Runtime Error
63
14008
155
n = int(input()) P = list(map(int, input().split())) ans = 0 for i in range(1,n+1): if i == P[i-1]: P[i] = P[i-1] ans += 1 print(ans)
s559279317
p03612
u188745744
1590681161
Python
Python (3.4.3)
py
Runtime Error
83
14008
244
N=int(input()) A= list(map(int,input().split())) l=[0]*N for i in range(N): if A[i] == i+1: l[i]=1 ans=0 for i in range(N): if l[i] == 1: if l[i+1] == 1: l[i+1]=0 ans+=1 else: ans+=1 print(ans)
s777423661
p03612
u801049006
1590522782
Python
Python (3.4.3)
py
Runtime Error
80
14004
252
n = int(input()) p = list(map(int, input().split())) ans = 0 for i in range(n): if i+1 == p[i]: temp = p[i] p[i] = p[i+1] p[i+1] = temp ans += 1 if i == n-1 and i+1 == p[i]: ans += 1 print(ans)
s599253497
p03612
u801049006
1590522559
Python
Python (3.4.3)
py
Runtime Error
73
14008
194
n = int(input()) p = list(map(int, input().split())) ans = 0 for i in range(n): if i+1 == p[i]: temp = p[i] p[i] = p[i+1] p[i+1] = temp ans += 1 print(ans)
s101209696
p03612
u622847899
1590343806
Python
Python (3.4.3)
py
Runtime Error
72
14008
150
n=int(input()) p=list(map(int,input().split())) cnt=0 for i in range(n): if p[i]==i+1: p[i],p[i+1]=p[i+1],p[i] cnt+=1 print(cnt)
s089569285
p03612
u858670323
1590234961
Python
Python (3.4.3)
py
Runtime Error
25
10420
167
n = int(input()) A = list(map(int,input().split().rstrip())) A.append(0) ans = 0 for i in range(n): if A[i]==(i+1): ans += 1 if A[i+1]==(i+2): ans -= 1
s154270872
p03612
u551109821
1590208053
Python
Python (3.4.3)
py
Runtime Error
74
14008
197
N = int(input()) p = list(map(int,input().split())) cnt = 0 for i in range(N): if p[i] == i+1: value = p[i] p[i] = p[i+1] p[i+1] = value cnt += 1 print(cnt)
s102193974
p03612
u671446913
1590025441
Python
PyPy3 (2.4.0)
py
Runtime Error
165
38384
247
n = int(input()) p = list(map(int, input().split())) ans = 0 for i, _ in enumerate(p[:-1]): #print(p_, i+1) p_ = p[i] if p_ == i + 1: ans += 1 p[i], p[i+1] = p[i+1], p[i] if p[-1] = N: ans += 1 print(ans)
s336193436
p03612
u998733244
1590020258
Python
Python (3.4.3)
py
Runtime Error
75
14008
213
#!/usr/bin/env python3 N = int(input()) P = list(map(int, input().split())) cnt = 0 for i in range(N): if i+1 == P[i]: p = P[i] P[i] = P[i+1] P[i+1] = p cnt += 1 print(cnt)
s551953609
p03612
u486251525
1589946453
Python
PyPy3 (2.4.0)
py
Runtime Error
201
53036
236
N = int(input()) p = list(map(int, input().split())) # print(p) count = 0 for i in range(len(p)): # print(p[i]) if i + 1 == p[i]: tmp = p[i] p[i] = p[i + 1] p[i + 1] = tmp count += 1 print(count)
s397543962
p03612
u373047809
1589419143
Python
Python (3.4.3)
py
Runtime Error
70
13940
170
#!/usr/bin/env python3 n, *p = map(int, open(0).read().split()) c = 0 for i in range(n): if p[i] == i + 1: p[i], p[i+1] = p[i+1], p[i] c += 1 print(c)
s589997953
p03612
u169350228
1589256744
Python
Python (3.4.3)
py
Runtime Error
77
14008
255
n = int(input()) p = list(map(int,input().split())) ans = 0 flag = False for i in range(n): if flag: flag = False continue if p[i] == i+1: if i < n+1 and p[i+1] == i+2: flag = True ans += 1 print(ans)
s009032261
p03612
u301624971
1589127643
Python
Python (3.4.3)
py
Runtime Error
60
14008
600
def myAnswer(N:int,P:list) -> int: ans = 0 counter = 0 for i in range(1,N+1): if(i == P[i - 1]): counter += 1 elif(counter != 0): ans += sum(divmod(counter,2)) counter = 0 if(counter != 0): ans += sum(divmod(counter,2)) return ans def modelAnswer(N:int,P:list...
s486448526
p03612
u888337853
1589100370
Python
Python (3.4.3)
py
Runtime Error
79
16056
648
import sys import re import math import collections import decimal import bisect import itertools import fractions import copy # import heapq # from collections import deque # import decimal sys.setrecursionlimit(10000001) INF = sys.maxsize MOD = 10 ** 9 + 7 ni = lambda: int(sys.stdin.readline()) ns = lambda: map(i...
s766342822
p03612
u288430479
1588891697
Python
Python (3.4.3)
py
Runtime Error
78
14008
338
n = int(input()) l = list(map(int,input().split())) cou = 0 if l[0]==1: x = l[0] l[0] = l[1] l[1]=x cou += 1 for i in range(1,n): if l[i]==i+1: if l[i-1]==i: x = l[i-1] l[i-1] = l[i] l[i] = x cou += 1 else: x = l[i] l[i] = l[i+1] l[i+1] = x cou += 1 # p...