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
s616498346
p03993
u623687794
1571854843
Python
Python (3.4.3)
py
Runtime Error
17
2940
109
n=int(input()) a=list(map(int,input().split())) ans=0 for i in range(n): if a[a[i]-1]=i+1:ans+=1 print(ans)
s892149512
p03993
u391731808
1563941348
Python
Python (3.4.3)
py
Runtime Error
19
4724
75
input();*A,=map(int,input());print(sum(A[a]==i for i,a in enumerate(A))//2)
s743674450
p03993
u014847113
1563000206
Python
Python (3.4.3)
py
Runtime Error
17
2940
290
#include<stdio.h> #include<stdlib.h> #include<string.h> #define df 0 int main(){ int n; scanf("%d",&n); int i,a[n+1]; for(i=0;i<n;i++) scanf("%d",&a[i+1]); int count=0; for(i=1;i<=n;i++) if(a[a[i]]==i)count++; printf("%d",count/2); return 0; } /// confirm df==0 ///
s843641051
p03993
u170324846
1561344627
Python
Python (3.4.3)
py
Runtime Error
59
13880
121
N = int(input()) a = [int(i) for i in input().split()] S = 0 for i in range(N): if a[a[i]] == i: S += 1 print(S//2)
s548648609
p03993
u102461423
1560812223
Python
Python (3.4.3)
py
Runtime Error
45
13880
155
N = input() A = [None] + [int(x) for x in input().split()] answer = 0 for i in range(1,N+1): if A[A[i]] == i: answer += 1 answer //= 2 print(answer)
s937808996
p03993
u767664985
1559194636
Python
Python (3.4.3)
py
Runtime Error
16
2940
122
N = int(input()) *a, = map(int, input().split()) ans = 0 for i in range(N): if i = a.index(a[i]): ans += 1 print(ans)
s831164946
p03993
u743272507
1554929781
Python
Python (3.4.3)
py
Runtime Error
58
13880
114
n = int(input()) k = list(map(int,input().split())) r = 0 for i in range(n): if k[k[i]] == i: r += 1 print(r//2)
s612701598
p03993
u527261492
1554732386
Python
Python (3.4.3)
py
Runtime Error
60
14008
154
n=int(input()) a=list(map(int,input().split())) cnt=0 for i in range(n): if a[a[i]]==i+1: cnt+=1 break else: cnt=cnt print(cnt)
s189589092
p03993
u527261492
1554732351
Python
Python (3.4.3)
py
Runtime Error
20
2940
153
n=int(input()) a=list(map(int,input().split())) cnt=0 for i in range(n): if a[a[i]]==i+1 cnt+=1 break else: cnt=cnt print(cnt)
s190854865
p03993
u256868077
1554687683
Python
Python (3.4.3)
py
Runtime Error
18
2940
139
n=int(input()) a=list(map(int,input().split())) ans=0 for i in range(n): b=a[i] if a[b] = i: ans += 1 else: i += 1 print(ans)
s872002287
p03993
u957722693
1554685899
Python
Python (3.4.3)
py
Runtime Error
55
13880
118
n=int(input()) l=list(map(int,input().split())) sum=0 for i in range(n): if l[l[i]]==i: sum+=1 print(int(sum/2))
s178456716
p03993
u227082700
1553914699
Python
Python (3.4.3)
py
Runtime Error
17
2940
109
n=int(input());a=list(map(int,input().split()));ans=0 for i in range(n): if i+1=a[a[i]-1]:ans+=1 print(ans)
s124236921
p03993
u118642796
1553573519
Python
Python (3.4.3)
py
Runtime Error
26
10612
124
N = int(input()) A = [int[i] for i in input().split()] ans = 0 for i in range(N): if A[i] == i+1: ans += 1 print(ans)
s142662533
p03993
u557143627
1552747721
Python
Python (3.4.3)
py
Runtime Error
42
14008
194
size = int(input()) rabbits = list(map(int, input().split())) count = 0 for i in range(size): if (rabbit[i] - 1) > i and (rabbits[rabbits[i]-1] -1) == i: count += 1 print(count) #123
s465452844
p03993
u557143627
1552704955
Python
Python (3.4.3)
py
Runtime Error
40
13880
189
size = int(input()) rabbits = list(map(int, input().split())) count = 0 for i in range(size): if (rabbit[i] - 1) > i and (rabbits[rabbits[i]-1] -1) == i: count += 1 print(count)
s026427265
p03993
u557143627
1552704896
Python
Python (2.7.6)
py
Runtime Error
14
4480
189
size = int(input()) rabbits = list(map(int, input().split())) count = 0 for i in range(size): if (rabbit[i] - 1) > i and (rabbits[rabbits[i]-1] -1) == i: count += 1 print(count)
s040731321
p03993
u557143627
1552704829
Python
Python (3.4.3)
py
Runtime Error
40
14008
189
size = int(input()) rabbits = list(map(int, input().split())) count = 0 for i in range(size): if (rabbit[i] - 1) > i and (rabbits[rabbits[i]-1] -1) == i: count += 1 print(count)
s451356513
p03993
u552816314
1552351818
Python
Python (3.4.3)
py
Runtime Error
18
3060
229
size = int(raw_input()) rabbit_list = raw_input().split() rabbits = [int(x) for x in rabbits_input] count = 0 for i in range(size): if (rabbits[i] - 1) > i and (rabbits[rabbits[i]-1] - 1) == i: count += 1 print(count)
s744826936
p03993
u552816314
1552351377
Python
Python (3.4.3)
py
Runtime Error
25
10420
221
size = int(input()) rabbit_list = input().split() rabbits = [int(x) for x in rabbits_input] count = 0 for i in range(size): if (rabbits[i] - 1) > i and (rabbits[rabbits[i]-1] - 1) == i: count += 1 print(count)
s508939010
p03993
u367130284
1551721307
Python
Python (3.4.3)
py
Runtime Error
30
8756
100
n=int(input());s=list(input());print(n-len(set(tuple(sorted((i+1,int(s[i*2]))))for i in range(n))))
s710339815
p03993
u740284863
1550299724
Python
Python (3.4.3)
py
Runtime Error
57
14008
129
N = int(input()) n = list(map(int,input().split())) ans = 0 for i in range(N): if n[n[i]] == i: ans += 1 print(ans)
s958695188
p03993
u689562091
1549600724
Python
Python (3.4.3)
py
Runtime Error
66
14008
138
N = int(input()) A = list(map(int, input().split())) res = 0 for i in range(N): if i + 1 == A[A[A[i]-1]]: res += 1 print(res)
s802614452
p03993
u359856428
1548271276
Python
Python (3.4.3)
py
Runtime Error
21
4724
153
n = int(input()) nums = [int(input()) - 1 for i in range(n)] count = 0 for i in range(n): if i == nums[nums[i]]: count += 1 print(count // 2)
s172848143
p03993
u619819312
1547769709
Python
Python (3.4.3)
py
Runtime Error
18
3064
131
n=int(input(n)) a=list(map(int,input().split())) c=0 for i in range(n): if i==a[a[i]-1]: c+=1 a[i]=n+1 print(c)
s167481135
p03993
u379702654
1537140956
Python
Python (3.4.3)
py
Runtime Error
17
2940
472
import qualified Data.IntMap as M main :: IO () main = do n <- readLn as <- map read . words <$> getLine print $ solve n as solve :: Int -> [Int] -> Int solve n as = go mp0 where mp0 = M.fromList $ zip [1 .. n] as go :: M.IntMap Int -> Int go mp = case M.minViewWithKey mp of Nothing -> 0 Just ((k, a), mp') | M.lookup a mp' == Just k -> 1 + go mp' | otherwise -> go mp'
s668623883
p03993
u627417051
1531443213
Python
Python (3.4.3)
py
Runtime Error
17
2940
130
N = int(input()) a = list(map(int, input()split())) c = 0 for i in range(N): if a[a[i] - 1] == i + 1: c += 1 print(int(c / 2))
s093796335
p03993
u143536664
1530575913
Python
Python (3.4.3)
py
Runtime Error
17
3060
432
for i in range(N): for k in num_ban: if k == i + 1: ban = 1 break if ban == 1: ban = 0 continue for j in A: count_j += 1 if count_j != i + 1 and j == i + 1: if A[i] == count_j: count_ans += 1 num_ban.append(j) num_ban.append(count_j) else: count_j = 0 else: print(int(count_ans))
s029278198
p03993
u409064224
1530572890
Python
Python (3.4.3)
py
Runtime Error
62
14008
144
n = int(input()) a = list(map(int,input().split())) res = 0 for i in range(n): sel = a[i] if a[sel] == i: res += 1 else: print(res/2)
s741262961
p03993
u409064224
1530572773
Python
Python (3.4.3)
py
Runtime Error
17
2940
143
n = int(input()) a = list(map(int,input().split())) res = 0 for i in range(n): sel = a[i] if a[sel] = i: res += 1 else: print(res/2)
s256899374
p03993
u941884460
1526046558
Python
Python (3.4.3)
py
Runtime Error
59
14008
156
n = int(input()) nums = list(map(int,input().split())) count = 0 for i in range(n): if i < nums[i] and (i+1) == nums[nums[i]]: count += 1 print(count)
s135062464
p03993
u941884460
1526046507
Python
Python (3.4.3)
py
Runtime Error
41
13880
157
n = int(input()) nums = list(map(int,input().split())) count += 1 for i in range(n): if i < nums[i] and (i+1) == nums[nums[i]]: count += 1 print(count)
s840061803
p03993
u729133443
1523250427
Python
Python (3.4.3)
py
Runtime Error
17
2940
107
n = int(input()) a = map(int, input().split()) c = 0 for i in range(n): if a[a[i]] == i: c++ print(c)
s230718747
p03993
u258300459
1506208891
Python
Python (3.4.3)
py
Runtime Error
25
10420
332
# -*- coding: utf-8 -*- """ Created on Sat Sep 23 19:10:57 2017 @author: taichiNakamura """ # -*- coding: utf-8 -*- # 整数の入力 N = int(input()) # スペース区切りの整数の入力 a = map(int, input().split()) favorite = 0 for i,ai in enumerate(a): if a[ai-1] == (i+1): favorite += 1 print(favorite//2)
s346743122
p03993
u343128979
1504205761
Python
Python (3.4.3)
py
Runtime Error
76
14008
242
N = int(input()) usa = list(map(int, input().split())) flag = [0 for x in range(N)] count = 0 for i, j in enumerate(usa): if(flag[i]): continue if(usa[j-1]-1 == i): count+=1 flag[usa[j - 1]] = 1 print (count)
s974775896
p03993
u619728370
1489841344
Python
Python (3.4.3)
py
Runtime Error
18
2940
199
number = int(input()) a = list(map(int,input().split())) count = 0 for i in range(number): for j in range(number): if a[i] ==j+1 and a[j] == i+1: count += 1 print(int(count/2)
s226577540
p03993
u039623862
1482124409
Python
Python (3.4.3)
py
Runtime Error
55
14008
137
n = int(input()) a = list(map(int, input().split())) cnt = 0 for i in range(a): if a[a[i]-1] -1 == i: cnt +=1 print(cnt // 2)
s788529689
p03993
u039623862
1482124381
Python
Python (3.4.3)
py
Runtime Error
58
14008
135
n = int(input()) a = list(map(int, input().split())) cnt = 0 for i in range(a): if a[a[i]] -1 == i: cnt +=1 print(cnt // 2)
s069976151
p03993
u998100201
1475308525
Python
Python (2.7.6)
py
Runtime Error
16
2568
92
n = input() a = map(int,raw_input.split()) print sum(i == a[a[i-1]]-1 for i in range(n)) / 2
s424419890
p03993
u464852639
1475254976
Python
Python (3.4.3)
py
Runtime Error
86
25068
172
n = int(input()) a = map(int, input().split()) d = {i+1: j for (i,j) in enumerate(a)} sum = 0 for x in range(n): if( x == d[d[x]]): sum += 1 print(sum//2)
s358142988
p03993
u464852639
1475254861
Python
Python (3.4.3)
py
Runtime Error
22
3192
168
n = int(input()) a = map(int, input().split()) d = {i+1: j for (i,j) in enumerate(a)} sum = 0 for x in range(n): if( x == d[d[x]]): sum += 1 print sum//2
s424499998
p03993
u664481257
1475109483
Python
Python (3.4.3)
py
Runtime Error
111
14520
870
# -*- coding: utf-8 -*- # !/usr/bin/env python # vim: set fileencoding=utf-8 : """ # # Author: Noname # URL: https://github.com/pettan0818 # License: MIT License # Created: 2016-09-28 # # Usage # """ import sys def input_single_line(): """Receive Inputs.""" return input() def input_two_line(): """Receive Two Lined Inputs. Like this. N 1 2 3 4 5 """ sys.stdin.readline() target = sys.stdin.readline() target = target.rstrip("\n") target = target.split(" ") return target def search_lovers(target_list: list) -> None: """Search Simple.""" lovers = [] for i in target_list: if target_list[i-1] == i-1: lovers.append(i-1) print(len(lovers)) if __name__ == "__main__": import doctest doctest.testmod() target = input_two_line() search_lovers(target)
s863781071
p03993
u875246225
1474949713
Python
PyPy3 (2.4.0)
py
Runtime Error
271
57260
204
N = int(input()) a = list(map(int, input().split())) b = {} ans = 0 for i, v in enumerate(a): if v > i+1: b[i+1] = v elif v < i+1: if b[v] == i+1: ans += 1 print(ans)
s895817059
p03993
u199479035
1474771271
Python
Python (3.4.3)
py
Runtime Error
86
10548
178
n = input() a = input() a = a.split(sep=' ') result = 0 for i in range(1,int(n)+1): if int(a[int(a[i])]) == i: result = result+1 result = int(result/2) print(result)
s144679227
p03993
u199479035
1474771168
Python
Python (3.4.3)
py
Runtime Error
38
10548
168
n = input() a = input() a = a.split(sep=' ') result = 0 for i in range(1,int(n)+1): if a[a[i]] == i: result = result+1 result = int(result/2) print(result)
s677822291
p03993
u356172016
1474771108
Python
PyPy2 (5.6.0)
py
Runtime Error
39
10096
239
rabbit_number = input() rabbit_like = [] for i in range(rabbit_number): like = raw_input() rabbit_like.append(like) couple = 0 for i in range(rabbit_number): if rabbit_like[i] == rabbit_like[rabbit_like[i]-1]: couple += 1 print couple
s059539313
p03993
u356172016
1474771108
Python
PyPy2 (5.6.0)
py
Runtime Error
40
10096
239
rabbit_number = input() rabbit_like = [] for i in range(rabbit_number): like = raw_input() rabbit_like.append(like) couple = 0 for i in range(rabbit_number): if rabbit_like[i] == rabbit_like[rabbit_like[i]-1]: couple += 1 print couple
s511347079
p03993
u199479035
1474770877
Python
Python (3.4.3)
py
Runtime Error
38
8756
213
n = input() s = list(input()) a = {} for i in range(1,int(n)+1): a[i] = int(s[2*i-2]) result = 0 for i in range(1,int(n)+1): if a[a[i]] == i: result = result+1 result = int(result/2) print(result)
s560023459
p03993
u199479035
1474770799
Python
Python (3.4.3)
py
Runtime Error
23
3064
257
n = input() s = [] while len(s) < 2*n: s = s+list(input())+[' '] a = {} for i in range(1,int(n)+1): a[i] = int(s[2*i-2]) result = 0 for i in range(1,int(n)+1): if a[a[i]] == i: result = result+1 result = int(result/2) print(result)
s920740414
p03993
u199479035
1474770616
Python
Python (3.4.3)
py
Runtime Error
23
3064
263
n = input() l = 0 s = [] while len(s) < 2*n: s = s+list(input())+[' '] a = {} for i in range(1,int(n)+1): a[i] = int(s[2*i-2]) result = 0 for i in range(1,int(n)+1): if a[a[i]] == i: result = result+1 result = int(result/2) print(result)
s033943871
p03993
u199479035
1474770602
Python
Python (3.4.3)
py
Runtime Error
23
3064
263
n = input() l = 0 s = [] while len(s) < 2*n: s = s+list(input())+[' '] a = {} for i in range(1,int(n)+1): a[i] = int(s[2*i-2]) result = 0 for i in range(1,int(n)+1): if a[a[i]] == i: result = result+1 result = int(result/2) print(result)
s067781343
p03993
u199479035
1474770507
Python
Python (3.4.3)
py
Runtime Error
23
3064
265
n = input() l = 0 s = [] while len(s) < 2*n-1: s = s+[' ']+list(input()) a = {} for i in range(1,int(n)+1): a[i] = int(s[2*i-2]) result = 0 for i in range(1,int(n)+1): if a[a[i]] == i: result = result+1 result = int(result/2) print(result)
s434563167
p03993
u199479035
1474770217
Python
Python (3.4.3)
py
Runtime Error
42
8756
213
n = input() s = list(input()) a = {} for i in range(1,int(n)+1): a[i] = int(s[2*i-2]) result = 0 for i in range(1,int(n)+1): if a[a[i]] == i: result = result+1 result = int(result/2) print(result)
s106796494
p03993
u199479035
1474769770
Python
Python (3.4.3)
py
Runtime Error
38
8756
95
n = int(input()) s = list(input()) r = 0 for i in range(0,n): r = r+int(s[i]) print(r)
s291663991
p03993
u476127533
1474769743
Python
Python (2.7.6)
py
Runtime Error
84
11304
288
N = int(raw_input()) a = map(int, raw_input().split(" ")) b = [-1] a = b + a #print a count = 0 for i in range(1,N+1): #print a.index(a[int(a[i])]) if i == int(a[(a[i])]) and a.index(a[(a[i])]) == (a[i]): count +=1 a[i] = '0' a[(a[i])] ='0' print count
s641538272
p03993
u794929569
1474769082
Python
Python (3.4.3)
py
Runtime Error
22
3064
148
s1 = raw_input() s2 = raw_input() s2 = s2.split(" ") f = 0 for a,b in enumerate(s2): if str(s2[int(b)-1]) == str(a+1): f = f+1 print f/2
s665037075
p03993
u794929569
1474769002
Python
Python (3.4.3)
py
Runtime Error
22
3064
153
s1 = raw_input() s2 = raw_input() s2 = s2.split(" ") f = 0 for a,b in enumerate(s2): if str(s2[int(b)-1]) == str(a+1): f = f+1 print str(f/2)
s654038414
p03993
u794929569
1474768926
Python
Python (3.4.3)
py
Runtime Error
22
3064
148
s1 = raw_input() s2 = raw_input() s2 = s2.split(" ") f = 0 for a,b in enumerate(s2): if str(s2[int(b)-1]) == str(a+1): f = f+1 print f/2
s821482072
p03993
u794929569
1474768885
Python
Python (3.4.3)
py
Runtime Error
23
3064
157
s1 = raw_input() s2 = raw_input() s2 = s2.split(" ") f = 0 print s2 for a,b in enumerate(s2): if str(s2[int(b)-1]) == str(a+1): f = f+1 print f/2
s030277909
p03993
u794929569
1474768550
Python
Python (3.4.3)
py
Runtime Error
22
3064
133
s1 = raw_input() s2 = raw_input() s2 = s2.split(" ") f = 0 for a,b in enumerate(s2): if s2[int(b)] == str(a): f++ print f
s006411720
p03993
u794929569
1474768462
Python
Python (3.4.3)
py
Runtime Error
22
3064
128
s1 = raw_input() s2 = raw_input() s2 = s2.split(" ") f = 0 for a,b in enumerate(s2): if s2[b] == str(a): f++ print f
s895728748
p03993
u102438343
1474767561
Python
Python (2.7.6)
py
Runtime Error
19
3332
301
N = raw_input() likes = raw_input() pairs = 0 counter = 0 rabbit = 1 while counter < (int(N) * 2): if int(likes[((int(likes[counter]) -1 ) * 2)]) == rabbit: pairs += 1 rabbit += 1 counter += 2 else: rabbit += 1 counter += 2 pairs = pairs / 2 print pairs
s760309879
p03993
u102438343
1474767561
Python
Python (2.7.6)
py
Runtime Error
19
3332
301
N = raw_input() likes = raw_input() pairs = 0 counter = 0 rabbit = 1 while counter < (int(N) * 2): if int(likes[((int(likes[counter]) -1 ) * 2)]) == rabbit: pairs += 1 rabbit += 1 counter += 2 else: rabbit += 1 counter += 2 pairs = pairs / 2 print pairs
s454298198
p03993
u199479035
1474766742
Python
Python (3.4.3)
py
Runtime Error
28
4916
194
n = input() a = {} for i in range(1,int(n)+1): a[i] = int(input()) result = 0 for i in range(1,int(n)+1): if a[a[i]] == i: result = result+1 result = int(result/2) print(result)
s253730934
p03993
u436484848
1474766605
Python
Python (3.4.3)
py
Runtime Error
22
3064
235
num = int(input()) str = input() Li = list(map(int,str.split(' '))) CoupleNum = 0 for pointer in range(len(Li): ai = Li[pointer] if (ai > pointer+1): if (Li[ai-1]=pointer+1): CoupleNum++ print(CoupleNum)
s244785576
p03993
u199479035
1474766447
Python
Python (3.4.3)
py
Runtime Error
28
4788
194
n = input() a = {} for i in range(1,int(n)+1): a[i] = int(input()) result = 0 for i in range(1,int(n)+1): if a[a[i]] == i: result = result+1 result = int(result/2) print(result)
s274423352
p03993
u199479035
1474766322
Python
Python (3.4.3)
py
Runtime Error
27
4788
194
n = input() a = {} for i in range(1,int(n)+1): a[i] = int(input()) result = 0 for i in range(1,int(n)+1): if a[a[i]] == i: result = result+1 result = int(result/2) print(result)
s989186278
p03993
u199479035
1474766226
Python
Python (3.4.3)
py
Runtime Error
28
4916
173
n = input() a = {} for i in range(1,int(n)+1): a[i] = int(input()) result = 0 for i in range(1,int(n)+1): if a[a[i]] == i: result = result+1 print(result/2)
s898621528
p03993
u531436689
1474765746
Python
Python (2.7.6)
py
Runtime Error
29
8832
118
N = input() a = raw_input().split() ans = 0 for i in xrange(N): if a[ a[i] - 1 ] == i+1: ans += 1 print ans
s282892839
p03993
u575473686
1474765678
Python
Python (3.4.3)
py
Runtime Error
37
10548
160
N = int(input()) A = map(int, input().split()) pairs = [] for i in range(len(A)): if A[A[i] - 1] == i + 1: pairs.append(1) print(len(pairs) // 2)
s079539881
p03993
u575473686
1474765565
Python
Python (3.4.3)
py
Runtime Error
22
3064
147
N = int(input()) A = map(int, input().split()) pairs = [] for i in A: if A[A[i] - 1] = i + 1: pairs.append(1) print(len(pairs) // 2)
s366264011
p03993
u104282757
1474765466
Python
Python (2.7.6)
py
Runtime Error
16
2568
134
x_vec = map(int, raw_input().split()) ret = 0 for i in range(len(x_vec)): if x_vec[x_vec[i]] == i: ret += 1 print ret / 2
s376164040
p03994
u036104576
1601439046
Python
Python (3.8.2)
py
Runtime Error
68
10336
726
import sys import itertools # import numpy as np import time import math from heapq import heappop, heappush from collections import defaultdict from collections import Counter from collections import deque from itertools import permutations sys.setrecursionlimit(10 ** 7) INF = 10 ** 18 MOD = 10 ** 9 + 7 read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines # map(int, input().split()) S = input() K = int(input()) ans = [] for i, c in enumerate(S): num = ord('z') - ord(c) + 1 if K >= num: K -= num ans.append('a') else: ans.append(c) if K > 0: ans[-1] = chr((ord(S[-1]) - ord('a') + K) % 26 + ord('a')) print("".join(an))
s725339170
p03994
u761529120
1599912544
Python
PyPy3 (7.3.0)
py
Runtime Error
86
75520
315
def main(): S = list(input()) K = int(input()) L = len(S) for i in range(L): if ord('z') - ord(S[i]) + 1 <= K: K -= ord('z') - ord(S[i]) + 1 S[i] = 'a' if K > 0: S[-1] = chr(ord(S[-1]) + K) print(''.join(S)) if __name__ == "__main__": main()
s252274679
p03994
u721166818
1599710658
Python
Python (3.8.2)
py
Runtime Error
25
9008
1889
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> // Acknowledgement: Special thanks to kyomukyomupurin, who developed this // template. template <class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '(' << p.first << ", " << p.second << ')'; } template <class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { int n = 0; for (auto e : vec) os << (n++ ? ", " : "{") << e; return os << (n ? "}" : "{}"); } template <class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { int n = 0; for (auto e : st) os << (n++ ? ", " : "{") << e; return os << (n ? "}" : "{}"); } template <class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { int n = 0; for (auto e : mp) os << (n++ ? ", " : "{") << e; return os << (n ? "}" : "{}"); } template <class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { for (T& e : vec) is >> e; return is; } #ifdef LOCAL #define debug(...) \ std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__) #else #define debug(...) #endif void debug_out() { std::cerr << '\n'; } template <class Head, class... Tail> void debug_out(Head&& head, Tail&&... tail) { std::cerr << head; if (sizeof...(Tail) != 0) std::cerr << ", "; debug_out(std::forward<Tail>(tail)...); } using namespace std; using int64 = long long; int main() { string s; int64 K; cin >> s >> K; int N = s.size(); for (int i = 0; i < N; i++) { int idx = s[i] - 'a'; if (K >= 26 - idx) { K -= 26 - idx; s[i] = 'a'; } } if (K != 0) { int tmp = s[N - 1] - 'a' + K; s[N - 1] = tmp + 'a'; } cout << s << endl; return 0; }
s012291460
p03994
u289288647
1599011592
Python
Python (3.8.2)
py
Runtime Error
68
11240
209
s = list(input()) k = int(input()) num = len(s) for i in range(num): a = 122-ord(s[i])+1 if a <= k: k -= a s[i] = 'a' if k > 0: s[-1] = chr(ord(s[-1])+k) print(*s, sep='')
s333883243
p03994
u370721525
1598523952
Python
Python (3.8.2)
py
Runtime Error
1726
11192
417
s = str(input()) K = int(input()) i = 0 for j in range(len(s)): if s[j] != 'a': if 26+ord('a')-ord(s[j]) <= K-i: i += 26+ord('a')-ord(s[j]) s = s[:j] + 'a' + s[j+1:] if i < K: for k in range(1, len(s)+1): if s[-k] != 'a': if 26+ord('a')-ord(s[-k]) <= K-i: s = s[:-k] + 'a' + s[-k+1:] i += 26+ord('a')-ord(s[-k]) if i < K: s = s[:-1] + chr(ord(s[-1])+K-i) print(s)
s005542445
p03994
u062691227
1598309130
Python
PyPy3 (7.3.0)
py
Runtime Error
109
94332
310
from string import ascii_lowercase alp = ascii_lowercase num = {char: i for i, char in enumerate(alp)} s = input() k = int(input()) ns = [num[char] for char in s] for i in range(len(ns)): v = ns[i] if 26 - v <= k: ns[i] = 0 k -= 26 - v ns[-1] += k print(''.join(alp[n] for n in ns))
s317420982
p03994
u252828980
1597752552
Python
Python (3.8.2)
py
Runtime Error
90
10228
294
s = input() k = int(input()) L = [] for i in range(len(s)): L.append((ord("z")-ord(s[i])+1)) ans = "" i = 0 while i < len(s): if k-L[i] >= 0: ans +="a" k -=L[i] i +=1 else: ans +=s[i] i +=1 ans = ans[:-1] + chr(ord(ans[-1]) + k) print(ans)
s918262999
p03994
u193264896
1597677955
Python
Python (3.8.2)
py
Runtime Error
48
9344
529
import sys read = sys.stdin.read readline = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 8) INF = float('inf') MOD = 10 ** 9 + 7 def main(): S = input() K = int(input()) ans = '' for s in S: if s=='a': ans += s else: if 123 - ord(s) <= K: ans += 'a' K -= 123 - ord(s) else: ans += s if K > 0: ans = ans[:-1] + (chr(ord(ans[-1]) + K)) print(ans) if __name__ == '__main__': main()
s498283071
p03994
u193264896
1597677877
Python
Python (3.8.2)
py
Runtime Error
50
9444
455
import sys read = sys.stdin.read readline = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 8) INF = float('inf') MOD = 10 ** 9 + 7 def main(): S = input() K = int(input()) ans = '' for s in S: if 123 - ord(s) <= K: ans += 'a' K -= 123 - ord(s) else: ans += s if K > 0: ans = ans[:-1] + (chr(ord(ans[-1]) + K)) print(ans) if __name__ == '__main__': main()
s353873222
p03994
u193264896
1597677676
Python
Python (3.8.2)
py
Runtime Error
52
9324
455
import sys read = sys.stdin.read readline = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 8) INF = float('inf') MOD = 10 ** 9 + 7 def main(): S = input() K = int(input()) ans = '' for s in S: if 123 - ord(s) <= K: ans += 'a' K -= 123 - ord(s) else: ans += s if K > 0: ans = ans[:-1] + (chr(ord(ans[-1]) + K)) print(ans) if __name__ == '__main__': main()
s811898785
p03994
u562015767
1597184886
Python
PyPy3 (7.3.0)
py
Runtime Error
99
85772
558
s = list(map(str,input())) k = int(input()) ans = [0]*len(s) for i in range(len(s)): tmp = ord(s[i]) ans[i] = tmp b = 123 for i in range(len(ans)): tmp = ord(s[i]) if i != len(ans)-1: if b - tmp <= k: k = k-(b - tmp) ans[i] = "a" else: ans[i] = s[i] else: if tmp + k >= 123: tmp1 = tmp+k - 122 ans[i] = 96+tmp1 ans[i] = chr(ans[i]) else: ans[i] += k ans[i] = chr(ans[i]) print("".join(ans))
s100908185
p03994
u562015767
1597183813
Python
PyPy3 (7.3.0)
py
Runtime Error
100
85744
587
s = list(map(str,input())) k = int(input()) ans = [0]*len(s) for i in range(len(s)): tmp = ord(s[i]) ans[i] = tmp a = 123 for i in range(len(ans)): if i != len(ans)-1: if a - ans[i] <= k: k = k-(a - ans[i]) ans[i] = 97 ans[i] = chr(ans[i]) else: ans[i] = chr(ans[i]) else: if ans[i] + k >= 123: tmp = ans[i]+k - 122 ans[i] = 96+tmp ans[i] = chr(ans[i]) else: ans[i] += k ans[i] = chr(ans[i]) print("".join(ans))
s775383018
p03994
u442877951
1596602053
Python
Python (3.8.2)
py
Runtime Error
1535
139460
312
from bisect import * S = list(str(input())) K = int(input()) alp = list("abcdefghijklmnopqrstuvwxyz") for i in range(len(S)): b = bisect_left(alp,S[i]) print(b,K,S) if i == len(S)-1: S[i] = alp[(b+K)%26] elif 26 - b <= K: K -= (26 - b) S[i] = "a" if K == 0: break print("".join(S))
s493418513
p03994
u373047809
1596251560
Python
Python (3.8.2)
py
Runtime Error
60
9976
132
s,k,t=input(),int(input()),"" for q in s: if(p:=(123-ord(q))%26)<=k:t+="a";k-=p else:t+=q *a,b=t print(a+chr((ord(b)-97+k)%26+97))
s727725937
p03994
u373047809
1596251441
Python
Python (3.8.2)
py
Runtime Error
23
9236
134
s,k,t=input(),int(input()),"" for q in s: if(p:=(123-ord(q))%26)<=k:n+="a";K-=i else:n+=c print(t[:-1]+chr((ord(t[-1])-97+k)%26+97))
s869090466
p03994
u519968172
1595612545
Python
Python (3.8.2)
py
Runtime Error
62
10064
160
s=input() k=int(input()) l=list(s) for i in range(len(s)): f=-ord(s[i])+ord("z")+1 if f<=k: l[i]="a" k-=f l[-1]=chr(ord(l[-1])+k) print("".join(l))
s048034811
p03994
u519968172
1595612193
Python
Python (3.8.2)
py
Runtime Error
63
10244
160
s=input() k=int(input()) l=list(s) for i in range(len(s)): f=-ord(s[i])+ord("z")+1 if f<=k: l[i]="a" k-=f l[-1]=chr(ord(s[-1])+k) print("".join(l))
s053859848
p03994
u339199690
1594975633
Python
Python (3.8.2)
py
Runtime Error
71
9920
254
S = list(input()) K = int(input()) l = 0 for i, s in enumerate(S): if ord('z') - ord(s) + 1 <= K: S[i] = 'a' K -= ord('z') - ord(s) + 1 else: l = i else: if K > 0: S[l] = chr(ord(S[l]) + K) print("".join(S))
s290097123
p03994
u339199690
1594975538
Python
Python (3.8.2)
py
Runtime Error
70
10016
226
S = list(input()) K = int(input()) for i, s in enumerate(S): if ord('z') - ord(s) + 1 <= K: S[i] = 'a' K -= ord('z') - ord(s) + 1 else: if K > 0: S[-1] = chr(ord(S[-1]) + K) print("".join(S))
s090397077
p03994
u222668979
1593832507
Python
Python (3.8.2)
py
Runtime Error
80
11616
368
from math import ceil s, k = input(), int(input()) ans = [] a = ord('z') + 1 for i in s: if k == 0: ans.append(ord(i)) elif a - ord(i) <= k and i != 'a': k -= a - ord(i) ans.append(ord('a')) else: ans.append(ord(i)) ans[-1] += k if ans[-1] >= a: ans[-1] -= ceil((ans[-1] - (a - 1)) / 26) print(*map(chr, ans), sep='')
s365847434
p03994
u222668979
1593832460
Python
Python (3.8.2)
py
Runtime Error
76
11848
355
from math import ceil s, k = input(), int(input()) ans = [] a = ord('z') + 1 for i in s: if k == 0: ans.append(ord(i)) elif a - ord(i) <= k: k -= a - ord(i) ans.append(ord('a')) else: ans.append(ord(i)) ans[-1] += k if ans[-1] >= a: ans[-1] -= ceil((ans[-1] - (a - 1)) / 26) print(*map(chr, ans), sep='')
s199574143
p03994
u222668979
1593832300
Python
Python (3.8.2)
py
Runtime Error
82
11576
324
from math import ceil s, k = input(), int(input()) ans = [] a = ord('z') + 1 for i in s: if a - ord(i) <= k and i != 'a': k -= a - ord(i) ans.append(ord('a')) else: ans.append(ord(i)) ans[-1] += k if ans[-1] >= a: ans[-1] -= ceil((ans[-1] - (a - 1)) / 26) print(*map(chr, ans), sep='')
s493305615
p03994
u222668979
1593832265
Python
PyPy3 (7.3.0)
py
Runtime Error
132
83996
324
from math import ceil s, k = input(), int(input()) ans = [] a = ord('z') + 1 for i in s: if a - ord(i) <= k and i != 'a': k -= a - ord(i) ans.append(ord('a')) else: ans.append(ord(i)) ans[-1] += k if ans[-1] >= a: ans[-1] -= ceil((ans[-1] - (a - 1)) / 26) print(*map(chr, ans), sep='')
s932697822
p03994
u222668979
1593832052
Python
PyPy3 (7.3.0)
py
Runtime Error
96
85828
342
from math import ceil s, k = input(), int(input()) ans = [] a = ord('z') + 1 for i in s: if k == 0: break elif a - ord(i) <= k: k -= a - ord(i) ans.append(ord('a')) else: ans.append(ord(i)) ans[-1] += k if ans[-1] >= a: ans[-1] -= ceil((ans[-1] - (a - 1)) / 26) print(*map(chr, ans), sep='')
s742490244
p03994
u597455618
1592589785
Python
Python (3.8.2)
py
Runtime Error
61
10036
225
s = list(input()) k = int(input()) n = len(s) c = ord("z") + 1 i = 0 for i in range(n): tmp = c - ord(s[i]) if k >= tmp: s[i] = "a" k -= tmp if k > 0: s[n-1] = chr(ord(s[n-1])+k) print("".join(s))
s210024147
p03994
u597455618
1592589680
Python
Python (3.8.2)
py
Runtime Error
57
9908
231
s = list(input()) k = int(input()) n = len(s) c = ord("z") + 1 i = 0 for i in range(n): tmp = c - ord(s[i]) if k > 0 and k >= tmp: s[i] = "a" k -= tmp else: s[n-1] = chr(ord(s[n-1])+k) print("".join(s))
s266044332
p03994
u597455618
1592589399
Python
Python (3.8.2)
py
Runtime Error
57
10056
221
s = list(input()) k = int(input()) n = len(s) c = ord("z") + 1 i = 0 for i in range(n): tmp = c - ord(s[i]) if k >= tmp: s[i] = "a" k -= tmp else: s[n-1] = chr(ord(s[n-1])+k) print("".join(s))
s793094351
p03994
u597455618
1592589238
Python
Python (3.8.2)
py
Runtime Error
1715
9356
226
s = input() k = int(input()) n = len(s) c = ord("z") + 1 i = 0 for i in range(n): tmp = c - ord(s[i]) if k >= tmp: s = s[:i] + "a" + s[i+1:] k -= tmp else: s = s[:n-1] + chr(ord(s[n-1])+k) print(s)
s280108692
p03994
u597455618
1592588602
Python
Python (3.8.2)
py
Runtime Error
29
9188
855
a = input().replace("S", " S").replace("H", " H").replace("D", " D").replace("C", " C").split() m, s, h, d, c = [], [], [], [], [] ans = [] for i in range(len(a)): if a[i][1] in ["2", "3", "4", "5", "6", "7", "8", "9"]: m.append(i) else: if a[i][0] == "S": s.append(i) if len(s) == 5: ans = s break elif a[i][0] == "H": h.append(i) if len(h) == 5: ans = h break elif a[i][0] == "D": d.append(i) if len(d) == 5: ans = d break else: c.append(i) if len(c) == 5: ans = c break ch = 0 d = "" for i in ans: d += "".join(a[ch:i]) ch = i+1 if d == "": print(0) else: print(d)