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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s067333401 | p03987 | u810735437 | 1475447588 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3060 | 2033 | // 解説pdfの方針に沿った解答
// 参考: http://agc005.contest.atcoder.jp/submissions/904878
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <climits>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())
const int N = 1234567;
int pr[N]; // 数列のi番目の数値から左に辿り、最初により小さい数値があるindex
int ne[N]; // 数列のi番目の数値から右に辿り、最初により小さい数値があるindex
int pos[N]; // 数値xがある数列のindexを保持
int main() {
int N;
cin >> N;
FOR(i, 1, N + 1) {
int a;
cin >> a;
pos[a] = i;
}
REP(i, N+2) {
pr[i] = i - 1;
ne[i] = i + 1;
}
long long ans = 0;
for (int i = N; i >= 1; i--) {
// j: 数値iがある数列のindex
int j = pos[i];
// 数値i * 数値iが最小値となるような部分配列の数
ans += i * 1LL * (j - pr[j]) * (ne[j] - j);
// 例えば以下の数列で、今 数値i = 4, j = 5とする。
// 数列 .. 3 7 8 4 9 2
// idx 2 3 4 5 6 7
// このとき、pr[5] = 2, ne[5] = 7。
// 数値4を処理し終わった後は、数値4にとってのne, prを使ってテーブルを更新。
// この場合、数値3にとってのneは、数値4にとってのneと等しくなる。
// また、 数値2にとってのprは、数値4にとってのneと等しくなる。
// 式で書くと ne[2] = ne[7], pr[7] = pr[7]となる。
pr[ne[j]] = pr[j];
ne[pr[j]] = ne[j];
}
cout << ans << endl;
return 0;
}
|
s385456317 | p03987 | u854554545 | 1475378793 | Python | PyPy3 (2.4.0) | py | Runtime Error | 206 | 38768 | 216 | import sys
import numpypy as np
N = int(sys.stdin.readline())
P = np.array([int(x) for x in sys.stdin.readline().split()])
SUM = np.sum([np.sum([min(P[l:r+1]) for r in range(l, N)]) for l in range(N)])
print(SUM) |
s930917805 | p03988 | u423585790 | 1590699900 | Python | PyPy3 (2.4.0) | py | Runtime Error | 173 | 38640 | 469 | n = int(input())
a = list(map(int, input().split()))
x = sorted(set(a))
if (max(a) - 1) // 2 + 1 == min(a):
if max(a) & 1:
m = 0
for i in range(x[0],m[-1]+1):
if a.count(i) < 2: m = 1
if m:
print("Impossible")
else:
print("Possible")
else:
m = a.count(x[0]) != 1
for i in range(x[0]+1,m[-1]+1):
if a.count(i) < 2: m = 1
if m:
print("Impossible")
else:
print("Possible")
else:
print("Impossible") |
s232656352 | p03988 | u366541443 | 1588549434 | Python | PyPy3 (2.4.0) | py | Runtime Error | 179 | 38384 | 405 |
n = int(input())
a = list(map(int, input().split()))
num = Zeros(n,-1)
for i in range(n):
num[a[i]] += 1
mx = max(a)
#print(num)
ans = "Possible"
if(mx%2==0):
num[mx//2] -= 1
if(num[mx//2]<0): ans="Impossible"
now = mx//2 + 1
for i in range(mx-now+1):
num[now+i]-=2
if(num[now+i]<0): ans="Impossible"
#print(num)
if(sum(num[0:now])>=1):
ans = "Impossible"
print(ans)
|
s713053949 | p03988 | u892251744 | 1568766168 | Python | PyPy3 (2.4.0) | py | Runtime Error | 177 | 38384 | 566 | N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
yes = 'Possible'
no = 'Impossible'
if N == 2:
if a[0] != 1 and a[1] != 1:
print(no)
exit()
if a[-1] != (a[0] + 1) // 2:
print(no)
exit()
else:
if a[0] % 2 == 0:
if a[-2] == a[-1]:
print(no)
exit()
else:
if a[-3] == a[-1]:
print(no)
exit()
ok = [0] * N
for i in range(N):
ok[a[i]] += 1
for i in range(a[-1] + 1, a[0] + 1):
if ok[i] < 2:
print(no)
exit()
print(yes)
|
s287986651 | p03988 | u190405389 | 1568515257 | Python | PyPy3 (2.4.0) | py | Runtime Error | 178 | 38256 | 361 | from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
m = max(a)
flag = True
for i in range(1, m+1):
if i<=m//2:
if c[i]>1:
flag = False
else:
if c[i]<2:
flag = False
break
if m%2==0 and c[m//2]!=1:
flag = False
print('Possible' if flag else 'Impossible') |
s775064402 | p03988 | u111421568 | 1539823928 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 1057 | n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
m = a[-1]
f = 1
if m % 2 == 1:
s = m // 2 + 1
count = 0
if a[0] != s or a[2] == s:
f = 0
else:
for i in range(n):
if a[i] < s:
continue
elif a[i] == s:
if count == 0:
count = 1
else:
count = 0
s += 1
else:
f = 0
break
if count == 1:
f = 0
else:
s = m // 2 + 1
count = 0
if a[0] != s-1 or a[1] == s-1:
f = 0
else:
for i in range(1, n):
if a[i] < s:
continue
elif a[i] == s:
if count == 0:
count = 1
else:
count = 0
s += 1
else:
f = 0
break
if count == 1:
f = 0
if f == 1:
print('Possible')
else:
print('Impossible') |
s085474868 | p03988 | u729707098 | 1536907784 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 259 | n = int(input())
a = [int(i) for i in input().split()]
a.sort()
m,s = a[-1],a[0]
if m!=a[-2] or (m+1)//2!=s or (m%2 and s-a[1]) or ((not m%2) and s==a[1]) or any(a.count(i)<2 for i in range(s+1,m)) or s==a[1]==a[2]: print("Impossible")
else: print("Possible") |
s175455314 | p03988 | u250209149 | 1475374357 | Python | Python (2.7.6) | py | Runtime Error | 16 | 2568 | 905 | N = int(raw_input())
a = [int(x) for x in raw_input().split(' ')]
sorteda = sorted(a)
maxlen = sorteda[-1]
numpathsoflen = {}
if(sorteda[0] < (maxlen+1)/2):
print 'Impossible'
elif(maxlen % 2 == 0
and sorteda[0] == maxlen/2
and sorteda[0] == sorteda[1]):
print 'Impossible'
else:
numnodes = maxlen + 1
for i in range(N):
if a[i] in numpathsoflen.keys():
if numpathsoflen[a[i]] >= 2:
numnodes += 1
numpathsoflen[a[i]] += 1
else:
numpathsoflen[a[i]] = 1
if(numnodes != N):
print 'Impossible'
else:
out= 'Possible'
starti = (maxlen+1)/2)
if maxlen % 2 == 0:
starti++
for i in range(starti, maxlen)
if(not i in numpathsoflen.keys() or numpathsoflen[i] < 2):
out = 'Impossible'
print out |
s527972624 | p03992 | u460185449 | 1601089079 | Python | PyPy3 (7.3.0) | py | Runtime Error | 101 | 68424 | 54 | `r`````````````````. ````````@|@|@|@|@|@|@|@|@|@|@|@|i |
s393134290 | p03992 | u626337957 | 1600922154 | Python | PyPy3 (7.3.0) | py | Runtime Error | 96 | 74764 | 172 | N = int(input())
nums = list(map(int, input().split()))
answer = 0
for i, num in enumerate(nums, start=1):
if i == nums[num-1] and i < num:
answer += 1
print(answer)
|
s533113467 | p03992 | u368796742 | 1599340054 | Python | Python (3.8.2) | py | Runtime Error | 24 | 8920 | 33 | s = input()
print(s[:4]+" "+s[4:] |
s815846972 | p03992 | u468972478 | 1598105926 | Python | Python (3.8.2) | py | Runtime Error | 21 | 9032 | 41 | n = input()
print(" ".join(n[:4], n[4:])) |
s752410054 | p03992 | u562015767 | 1597185267 | Python | PyPy3 (7.3.0) | py | Runtime Error | 327 | 92828 | 560 | 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)) |
s055909337 | p03992 | u930734502 | 1593632761 | Python | Python (3.8.2) | py | Runtime Error | 28 | 8884 | 170 | #include <iostream>
using namespace std;
int main() {
string s;
cin >> s;
for (int i=0; i<s.size(); i++) {
if (i==4) cout << ' ';
else cout << s[i];
}
} |
s158903511 | p03992 | u100927237 | 1592153164 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 366 | makeA = lambda c: (ord('z')-ord(c)+1) % 26
s = list(map(makeA,list(input())))
#print(s)
K = int(input())
len_s = len(s)
#print(len_s)
for i in range(len_s-1):
if s[i] <= K:
K -= s[i]
s[i] = 0
print(s)
if K > 0:
s[-1] = (s[-1] + 26 - (K % 26)) % 26
#print(s)
makeS = lambda n: chr((26-n)%26+ord('a'))
print(''.join(list(map(makeS,s)))) |
s504797722 | p03992 | u941047297 | 1592018276 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 381 | def main():
S = list(input())
k = int(input())
ans = []
for s in S:
if k == 0:
break
if s != 'a' and ord(s) >= 123 - k:
ans.append('a')
k -= 123 - ord(s)
else:
ans.append(s)
if k > 0:
ans[-1] = chr(ord(ans[-1]) + k)
print(''.join(ans))
if __name__ == '__main__':
main()
|
s552019744 | p03992 | u974792613 | 1591998517 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 430 | import sys
alphabet = "abcdefghijklmnopqrstuvwxyz"
a_len = len(alphabet)
table = {c: idx for idx, c in enumerate(alphabet)}
rl = sys.stdin.readline
s = rl().rstrip()
k = int(rl())
ans = ""
for i in range(len(s[:-1])):
gap = a_len - table[s[i]]
if gap <= k:
ans += "a"
k -= gap
elif k == 0:
ans += s[i:-1]
else:
ans += s[i]
ans += alphabet[(table[s[-1]] + k) % a_len]
print(ans)
|
s833403883 | p03992 | u974792613 | 1591998493 | Python | PyPy3 (2.4.0) | py | Runtime Error | 164 | 38256 | 430 | import sys
alphabet = "abcdefghijklmnopqrstuvwxyz"
a_len = len(alphabet)
table = {c: idx for idx, c in enumerate(alphabet)}
rl = sys.stdin.readline
s = rl().rstrip()
k = int(rl())
ans = ""
for i in range(len(s[:-1])):
gap = a_len - table[s[i]]
if gap <= k:
ans += "a"
k -= gap
elif k == 0:
ans += s[i:-1]
else:
ans += s[i]
ans += alphabet[(table[s[-1]] + k) % a_len]
print(ans)
|
s663856645 | p03992 | u974792613 | 1591998448 | Python | PyPy3 (2.4.0) | py | Runtime Error | 174 | 38484 | 431 | import sys
alphabet = "abcdefghijklmnopqrstuvwxyz"
a_len = len(alphabet)
table = {c: idx for idx, c in enumerate(alphabet)}
rl = sys.stdin.readline
s = rl().rstrip()
K = int(rl())
ans = ""
for i in range(len(s[:-1])):
gap = a_len - table[s[i]]
if gap <= k:
ans += "a"
k -= gap
elif k == 0:
ans += s[i:-1]
else:
ans += s[i]
ans += alphabet[(table[s[-1]] + k) % a_len]
print(ans)
|
s791045072 | p03992 | u974792613 | 1591998431 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 431 | import sys
alphabet = "abcdefghijklmnopqrstuvwxyz"
a_len = len(alphabet)
table = {c: idx for idx, c in enumerate(alphabet)}
rl = sys.stdin.readline
s = rl().rstrip()
K = int(rl())
ans = ""
for i in range(len(s[:-1])):
gap = a_len - table[s[i]]
if gap <= k:
ans += "a"
k -= gap
elif k == 0:
ans += s[i:-1]
else:
ans += s[i]
ans += alphabet[(table[s[-1]] + k) % a_len]
print(ans)
|
s939016872 | p03992 | u357751375 | 1591363321 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 44 | s = list(input())
print(s[:4] + ' ' + s[4:]) |
s954712648 | p03992 | u357751375 | 1591363010 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 56 | s = list(input())
s = s.insert(4,' ')
print(''.join(s))
|
s358314268 | p03992 | u970809473 | 1587653056 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 28 | print(input().insert(4,' ')) |
s935118064 | p03992 | u013202780 | 1587266681 | Python | PyPy3 (2.4.0) | py | Runtime Error | 166 | 38528 | 153 | n=int(input())
a=list(map(int,input().split()))
a = [None] + a
cnt = 0
for i in range(1, n):
j = a[i]
if j > i and a[j] == i:
cnt += 1
print(cnt) |
s572202382 | p03992 | u600402037 | 1585747868 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 125 | #include <bits/stdc++.h>
using namespace std;
int main() {
string S;
cin >> S;
S.insert(4, " ");
cout << S << '\n';
} |
s903709071 | p03992 | u702786238 | 1584979268 | Python | PyPy3 (2.4.0) | py | Runtime Error | 170 | 38384 | 54 | s = list(input())
print("".join(s[:4] + [" "] + s[4:]) |
s020576327 | p03992 | u047102107 | 1584818233 | Python | PyPy3 (2.4.0) | py | Runtime Error | 164 | 38256 | 46 | s = input()
print("{} {}".format(s[:4], s[4:]) |
s278518035 | p03992 | u355371431 | 1584103889 | Python | PyPy3 (2.4.0) | py | Runtime Error | 175 | 38512 | 350 | s = input()
K = int(input())
ans = []
for i in s:
if i == "a":
ans.append("a")
continue
elif ord(i) + K > ord("z") + 1:
ans.append("a")
K -= ord("z") + 1 - ord(i)
else:
ans.append(i)
last = (K + ord(ans[-1]) - ord('a')) % 26
ans[-1] = chr(ord("a") + last)
print(''.join(ans)) |
s852368979 | p03992 | u503228842 | 1584102834 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 508 | #print(ord('a')) # 97
abc = ''
for i in range(97 ,97+26):
abc += chr(i)
#print(abc)
S = input()
K = int(input())
ans = ''
for i,s in enumerate(S):
if ord(s) > ord('a') and 27 - (ord(s) - ord('a')) <= K and i!=len(S)-1:
ans += 'a'
#K -= 26 - (ord(s) - ord('a'))
K -= 27 - (ord(s) - ord('a'))
#print(K)
elif i != len(S)-1:
ans += s
else:
#ans += chr(ord(s) + K%26)
ans += abc[(ord(s) + K%26-ord('a'))%26]
#print(ans)
print(ans) |
s450426182 | p03992 | u115877451 | 1583168393 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2568 | 32 | S=input()
print(S[:4],' ',S[4:]) |
s849578472 | p03992 | u115877451 | 1583168252 | Python | Python (2.7.6) | py | Runtime Error | 11 | 2568 | 31 | S=input()
print(s(:4)," ",s(:6) |
s098926987 | p03992 | u115877451 | 1583168048 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2568 | 24 | a=(
int(input(a))
range |
s987327843 | p03992 | u115877451 | 1583120952 | Python | Python (2.7.6) | py | Runtime Error | 11 | 2572 | 13 | int(input())
|
s169416278 | p03992 | u086503932 | 1583047038 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 34 | s = input()
print(S[:4]+' '+S[4:]) |
s812790060 | p03992 | u577914737 | 1577924077 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 72 | a = input()
a_first, a_last = s[:4], s[4:]
print(a_first + ' ' + a_last) |
s566010761 | p03992 | u296150111 | 1574395585 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 281 | s=input()
k=int(input())
ss=[]
for i in range(len(s)):
ss.append(ord(s[i])-ord("a"))
i=0
while k>0:
if i==len(s)-1:
ss[i]=(k+ss[i])%26
break
elif k>=26-ss[i] and ss[i]!="a":
k-=(26-ss[i])
ss[i]=0
i+=1
ans=""
for i in range(len(s)):
ans+=chr(ord("a")+ss[i])
print(ans)
|
s590010495 | p03992 | u366959492 | 1572796015 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 320 | s=list(input())
k=int(input())
for i in range(len(s)):
if k>=ord("z")-ord(s[i])+1:
k-=(ord("z")-ord(s[i])+1)
s[i]="a"
if k>0:
if ord("z")-(ord(s[-1])+k)<=0:
k-=ord("z")-ord(s[-1])+1
k%=26
s[-1]=chr(ord("a")+k)
else:
s[-1]=chr(ord(s[-1])+k)
print("".join(s))
|
s160708745 | p03992 | u223904637 | 1569714176 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 56 | s=list(input())
print(''.join(s[0:4]+' '+''.join(s[4:]) |
s603345732 | p03992 | u240630407 | 1567883067 | Python | PyPy3 (2.4.0) | py | Runtime Error | 180 | 38256 | 471 | s = input()
K = int(input())
for i, c in enumerate(s):
if i == len(s) - 1:
res = K % 26
if (ord(c) + res) <= ord("z"):
s = s[:i] + chr(ord(c) + res) + s[i+1:]
else:
s = s[:i] + chr((ord(c) + res) - ord("z") + ord("a") - 1) + s[i+1:]
elif ord(c) == ord("a"):
continue
elif K > ord("z") - ord(c) + 1:
s = s[:i] + "a" + s[i+1:]
K -= ord("z") - ord(c) + 1
else:
continue
print(s) |
s073618217 | p03992 | u240630407 | 1567883023 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 471 | s = input()
K = int(input())
for i, c in enumerate(s):
if i == len(s) - 1:
res = K % 26
if (ord(c) + res) <= ord("z"):
s = s[:i] + chr(ord(c) + res) + s[i+1:]
else:
s = s[:i] + chr((ord(c) + res) - ord("z") + ord("a") - 1) + s[i+1:]
elif ord(c) == ord("a"):
continue
elif K > ord("z") - ord(c) + 1:
s = s[:i] + "a" + s[i+1:]
K -= ord("z") - ord(c) + 1
else:
continue
print(s) |
s733838710 | p03992 | u921773161 | 1566214268 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 52 | a = list(input())
ans = a[:4] + ' ' + a[4:]
print(a) |
s030212913 | p03992 | u172873334 | 1561602063 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 35 | s=gets.chomp
puts s[0,4]+' '+s[4,8] |
s361237238 | p03992 | u507116804 | 1558755064 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 38 | s=input()
S=s[5].append("")
print(S) |
s414217297 | p03992 | u151625340 | 1554685711 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 136 | N = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(N):
if a[a[i]-1]-1 == i:
ans += 1
print(ans//2)
|
s361706323 | p03992 | u552816314 | 1552351180 | Python | Python (3.4.3) | py | Runtime Error | 20 | 3060 | 237 | size = int(input())
rabbit_list = input().split()
rabbits = [int(x) for x in rabbit_list]
count = 0
for i in range(size):
if (rabbits[i] - 1) > i and (rabbits[rabbits[i]-1] - 1) == i:
count += 1
if count > 0:
print(count) |
s533352739 | p03992 | u552816314 | 1552350687 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 236 | num = int(input())
rabbits_input = input().split()
rabbits = [int(x) for x in rabbits_input]
count = 0
rabbit_index = 0
for i in range(num):
if rabbits[i+1] > (i+1) and rabbits[rabbits[i+1]] == (i+1):
count += 1
return count |
s716301982 | p03992 | u740284863 | 1550299760 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 131 | N = int(input())
n = list(map(int,input().split()))
ans = 0
for i in range(N):
if n[n[i]-1] == i:
ans += 1
print(ans) |
s423784385 | p03992 | u397531548 | 1541978919 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 36 | S=input()
T=S[:4]+" "+S[4:]
ptint(T) |
s573318095 | p03992 | u832039789 | 1540010734 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 88 | input();*a,=map(int,input().split());print(sum(a[a[i]-1]==i+1for i in range(len(a)))>>1) |
s870642135 | p03992 | u858136677 | 1532611873 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 69 | s = input()
sega = s[0:4]
segb = s[4:12]
print(sega + “ “ + segb) |
s309166366 | p03992 | u224983328 | 1531515267 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 621 | s = input()
K = int(input())
sArr = list(s)
endpoint = len(sArr) - 1
result = ""
for i in range(len(sArr)):
if ord("z") - ord(sArr[i]) + 1 <= K:
K -= ord("z") - ord(sArr[i]) + 1
sArr[i] = "a"
while K > 0:
if ord("z") - ord(sArr[endpoint]) >= K:
sArr[endpoint] = chr(ord(sArr[endpoint]) + K)
K = 0
else:
sArr[endpoint] = "z"
K -= ord("z") - ord(sArr[endpoint])
endpoint -= 1
if endpoint == 0:
while endpoint != len(s) - 1:
sArr[endpoint] = "a"
K -= 1
for j in range(len(sArr)):
result += sArr[j]
print(result) |
s254033704 | p03992 | u403355272 | 1530577892 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 169 | N = int(input())
jk =0
le = list(map(int,input().split()))
le = [0] + le
for i in range(N):
print(le[le[i]])
if le[le[i]] == i:
jk += 1
print(jk // 2)
|
s525536514 | p03992 | u403355272 | 1530577868 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 164 | N = int(input())
jk =0
le = list(map(int,input().split()))
le = [0] + le
for i in range(N):
print(le[le[i]])
if le[le[i]] == i:
jk += 1
print(jk)
|
s951186214 | p03992 | u150253773 | 1524685181 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 56 | t1 = input()
t2 = t1[:4] + " " + t2[4:] + "\n"
print(t2) |
s290829658 | p03992 | u858748695 | 1515268842 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 135 | #!/usr/bin/env python3
N = int(input())
a = list(map(int, input().split()))
print(sum([a[a[i] - 1] - 1 == i for i in range(N)]) // 2)
|
s261072758 | p03992 | u258300459 | 1506209155 | Python | Python (3.4.3) | py | Runtime Error | 20 | 3060 | 345 | # -*- coding: utf-8 -*-
"""
Created on Sat Sep 23 19:10:57 2017
@author: taichiNakamura
"""
# -*- coding: utf-8 -*-
# 整数の入力
N = int(input())
# スペース区切りの整数の入力
a = input().split()
a = list(map(int, a))
favorite = 0
for i,ai in enumerate(a):
if a[ai-1] == (i+1):
favorite += 1
print(favorite//2)
|
s442539579 | p03992 | u258300459 | 1506209102 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 345 | # -*- coding: utf-8 -*-
"""
Created on Sat Sep 23 19:10:57 2017
@author: taichiNakamura
"""
# -*- coding: utf-8 -*-
# 整数の入力
N = int(input())
# スペース区切りの整数の入力
a = input().split()
a = list(map(int, a))
favorite = 0
for i,ai in enumerate(a):
if a[ai-1] == (i+1):
favorite += 1
print(favorite//2)
|
s020799674 | p03992 | u343128979 | 1504205089 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 189 |
N = int(input())
usa = list(map(int, input().split()))
print (usa[0])
for i, j in enumerate(usa):
if(usa[j]-1 == i):
count+=1
if(i >= N/2):
break
print (count)
|
s922854478 | p03992 | u373026530 | 1502386549 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 158 | N = int(input())
a = list(map(int, input().split()))
count = 0
for i, target in enumerate(a):
if a[target - 1] == i + 1:
count += 1
print(count // 2) |
s265361246 | p03992 | u373026530 | 1502386517 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 158 | N = int(input())
a = list(map(int, input().split()))
count = 0
for i, target in enumerate(a):
if a[target - 1] == i + 1:
count += 1
print(count // 2) |
s126299450 | p03992 | u373026530 | 1502386405 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 149 | N = int(input())
a = map(int, input().split())
count = 0
for i, target in enumerate(a):
if a[target - 1] == i + 1:
count += 1
print(count // 2) |
s481054465 | p03992 | u864668001 | 1491542811 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 33 | s = input()
print(s[:4]+' '+s[4:] |
s429692967 | p03992 | u619728370 | 1489841513 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 205 | number = int(input())
a = list(map(int,input().split()))
count = 0
for i in range(number):
for j in range(i,number):
if a[i] ==j+1 and a[j] == i+1:
count += 1
print(int(count))
|
s723788530 | p03992 | u731028462 | 1476694219 | Python | Python (3.4.2) | py | Runtime Error | 23 | 3064 | 329 | n, m = list(map(int, input().split()))
a = [input() for i in range(n)]
print(n,m)
##
## Template
##
## map, filter, reduce
# map(lambda x: x*2, range(10))
# filter(lambda x: x % 2, range(10))
# from functools import reduce
# reduce(lambda sum,x: sum+x, range(10))
# [x * 2 for x in range(1, 10) if x % 3 == 1]
# => [2, 8, 14]
|
s861894331 | p03992 | u989160925 | 1475559266 | Python | Python (3.4.3) | py | Runtime Error | 24 | 3064 | 154 | n = int(input())
a = list(map(int, input().split()))
count = 0
for i in range(0, n-1, 2):
if a[i] < a[i+1] or a[i] > a[i+1]:
count += 1
print(count)
|
s466162786 | p03992 | u399243564 | 1475375616 | Python | Python (2.7.6) | py | Runtime Error | 16 | 2568 | 255 | s = bytearray(raw_input())
N = int(raw_input())
dis = [ord('z')-c for c in s]
for idx, d in enumerate(dis[:-1]):
if d+1 <= N:
s[idx] = 'a'
N -= (d+1)
if N > 0:
N %= 26
t = (dis[-1]-N) % 26
s[-1] = chr(ord('z') - t)
print s |
s097781652 | p03992 | u399243564 | 1475374610 | Python | Python (2.7.6) | py | Runtime Error | 15 | 2568 | 242 | s = raw_input()
N = int(raw_input())
dis = [ord('z')-ord(c) for c in s]
for idx, d in enumerate(dis[:-1]):
if d <= N:
s[idx] = 'a'
N -= d
if N > 0:
N %= 27
t = (dis[-1]-N) % 27
s[-1] = chr(ord('z') - t)
print s |
s486225725 | p03992 | u122324030 | 1475346163 | Python | Python (2.7.6) | py | Runtime Error | 17 | 2568 | 414 | input()
K = int(raw_input())
s_list = list(s)
for i in range(len(s_list)):
# how long does it take to force a
lag = ord('z') - ord(s_list[i]) + 1
if s_list[i] != 'a' and K >= lag and i < len(s_list) - 1:
# not a and can conv
s_list[i] = 'a'
K -= lag
elif i == len(s_list) - 1:
s_list[i] = chr(ord('a') + ((ord(s_list[i]) - ord('a') + K) % 26))
print "".join(s_list)
|
s679782113 | p03992 | u998100201 | 1475308696 | Python | Python (2.7.6) | py | Runtime Error | 16 | 2568 | 95 | n = input()
a = map(int,raw_input().split())
print sum(i == a[a[i]-1]-1 for i in range(n)) / 2
|
s142828687 | p03992 | u562446079 | 1475301991 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3064 | 457 | import sys
input = lambda : sys.stdin.readline()
def main():
s = list(input())
n = int(input())
A = []
for c in s:
if (ord('a') - ord(c)) % 26 <= n:
A.append('a')
n -= (ord('a') - ord(c)) % 26
else:
A.append(c)
# print(''.join(*A))
# for itm in A:
# print(itm,end = '')
A[-1] = chr(ord(A[-1]) + n % 26)
print(''.join(A))
if __name__ == '__main__':
main()
|
s966844451 | p03992 | u436484848 | 1475299325 | Python | PyPy3 (2.4.0) | py | Runtime Error | 228 | 40048 | 1020 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# D-Grid and Integers
from collections import defaultdict
def ReadInput():
return [int(i) for i in input().split(" ")]
(R, C) = ReadInput()
N = int(input())
VectorSet = set()
Grid = defaultdict(list)
for i in range(N):
(r, c, a) = ReadInput()
Grid[("R", r)].append((("C", c), a))
Grid[("C", c)].append((("R", r), a))
VectorSet.add(('R', r))
VectorSet.add(('C', c))
def iteration(vector):
VectorSet.discard(vector)
for (v, a) in Grid[vector]:
temp = a - VectorCover[vector]
if (v in VectorCover):
if(temp != VectorCover[v]):
print("No")
print("No equal")
exit()
else:
VectorCover[v] = temp
iteration(v)
while(len(VectorSet) != 0):
vector = VectorSet.pop()
VectorCover = dict()
VectorCover[vector] = 0
iteration(vector)
minR = min(a for (p, a) in VectorCover.items() if (p[0] == "R"))
minC = min(a for (p, a) in VectorCover.items() if (p[0] == "C"))
if (minR + minC < 0):
print("No")
print("min")
exit()
print("Yes") |
s968903989 | p03992 | u122324030 | 1475268637 | Python | Python (2.7.6) | py | Runtime Error | 16 | 2568 | 245 | s=raw_input()
K=int(raw_input())
s=list(s)
#a-z 97-122
for i, s_ in enumerate(s):
if s_!='a':
if ord(s_)+K >= 123:
s[i]='a'
K -= (123-ord(s_))
if K>0:
asc=ord(s[-1])+K%26
s[-1]=chr(asc)
print"".join(s) |
s354249084 | p03992 | u122324030 | 1475268565 | Python | Python (2.7.6) | py | Runtime Error | 17 | 2568 | 247 | s=raw_input()
K=int(raw_input())
s=list(s)
#a-z 97-122
for i, s_ in enumerate(s):
if s_!='a':
if ord(s_)+K >= 123:
s[i]='a'
K -= (123-ord(s_))
if K>0:
asc=ord(s[-1])+K%26
s[-1]=chr(asc)
print("".join(s)) |
s537136666 | p03992 | u122324030 | 1475268405 | Python | Python (2.7.6) | py | Runtime Error | 17 | 2696 | 239 | s=input()
K=int(input())
s=list(s)
#a-z 97-122
for i, s_ in enumerate(s):
if s_!='a':
if ord(s_)+K >= 123:
s[i]='a'
K -= (123-ord(s_))
if K>0:
asc=ord(s[-1])+K%26
s[-1]=chr(asc)
print("".join(s)) |
s446477863 | p03992 | u122324030 | 1475267843 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3064 | 239 | s=input()
K=int(input())
s=list(s)
#a-z 97-122
for i, s_ in enumerate(s):
if s_!='a':
if ord(s_)+K >= 123:
s[i]='a'
K -= (123-ord(s_))
if K>0:
asc=ord(s[-1])+K%26
s[-1]=chr(asc)
print("".join(s)) |
s178291935 | p03992 | u122324030 | 1475267758 | Python | Python (3.4.3) | py | Runtime Error | 24 | 3064 | 240 | s=input()
K=int(input())
s=list(s)
#a-z 97-122
for i, s_ in enumerate(s):
if s_!='a':
if ord(s_)+K >= 123:
s[i]='a'
K -= (123-ord(s_))
if K>0:
asc=ord(s[-1])+K%26
s[-1]=chr(asc)
print ("".join(s)) |
s600851849 | p03992 | u122324030 | 1475267531 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3064 | 239 | s=input()
K=int(input())
s=list(s)
#a-z 97-122
for i, s_ in enumerate(s):
if s_!='a':
if ord(s_)-K <= 97:
s[i]='a'
K -= (123-ord(s_))
if K>0:
asc=ord(s[-1])+K%26
s[-1]=chr(asc)
print ("".join(s)) |
s030351191 | p03992 | u122324030 | 1475267140 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3064 | 275 | s=input()
K=int(input())
s=list(s)
#a-z 97-122
for i in range(len(s)):
if s[i]!='a':
if ord(s[i])+K < 123:
continue
else:
K-=(123-ord(s[i]))
s[i]='a'
if K>0:
asc=ord(s[-1])+K%26
s[-1]=chr(asc)
print ("".join(s)) |
s385220158 | p03992 | u436484848 | 1475134679 | Python | Python (3.4.3) | py | Runtime Error | 27 | 3316 | 979 | from collections import defaultdict
def readInput():
return [int(i) for i in input().split(" ")]
(R, C) = readInput()
N = int(input())
rowIdx = set()
grid = defaultdict(lambda:None)
rowGrid = defaultdict(set)
for i in range(N):
(r, c, a) = readInput()
r -= 1
c -= 1
rowGrid[r].add(c)
grid[(r, c)] = a
rowIdx.add(r)
pairIdx = rowIdx.copy
for i in rowIdx:
pairIdx.remove(i)
for j in pairIdx:
tempRow = rowGrid[i]
tempPair = rowGrid[j]
mark = 1
for k in tempRow:
if (grid[(j, k)] != None):
diff = grid[(i, k)] - grid[(j, k)]
mark = 0
if (mark is 1):
continue
for m in tempRow:
anchor = grid[(i, m)]
anchorP = grid[(j, m)]
if (anchorP is None and anchor < diff):
print('No')
exit()
elif (anchorP is not None and anchor - anchorP != diff):
print('No')
exit()
for n in tempPair:
anchor = grid[(j, n)]
anchorP = grid[(i, n)]
if (anchorP is None and anchor < -diff):
print('No')
exit()
print('Yes') |
s053114098 | p03992 | u436484848 | 1475132155 | Python | PyPy3 (2.4.0) | py | Runtime Error | 207 | 38768 | 1071 | #/usr/bin/env python3
# -*- coding: utf-8 -*-
# D-Grid and Integers
from collections import defaultdict
def readInput():
return [int(i) for i in input().split(" ")]
(R, C) = readInput()
N = int(input())
rowIdx = list()
colIdx = list()
grid = defaultdict(lambda:None)
rowGrid = defaultdict(list)
for i in range(N):
(r, c, a) = readInput()
r -= 1
c -= 1
rowGrid[r].append(c)
grid[(r, c)] = a
rowIdx.append(r)
pairIdx = rowIdx.copy()
for i in rowIdx:
pairIdx.remove(i)
for j in pairIdx:
tempRow = rowGrid[i]
tempPair = rowGrid[j]
mark = 1
for k in tempRow:
if (grid[(j, k)] != None):
diff = grid[(i, k)] - grid[(j, k)]
mark = 0
if (mark == 1):
continue
for m in tempRow:
anchor = grid[(i, m)]
anchorP = grid[(j, m)]
if (anchorP == None and anchor < diff):
print('No')
exit()
elif (anchorP != None and anchor - anchorP != diff):
print('No')
exit()
for n in tempPair:
anchor = grid[(j, n)]
anchorP = grid[(i, n)]
if (anchorP == None and anchor < -diff):
print('No')
exit()
print('Yes') |
s226440410 | p03992 | u436484848 | 1475129933 | Python | Python (3.4.3) | py | Runtime Error | 27 | 3424 | 1158 | #/usr/bin/env python3
# -*- coding: utf-8 -*-
# D-Grid and Integers
from collections import defaultdict
def readInput():
return [int(i) for i in input().split(" ")]
(R, C) = readInput()
N = int(input())
rowIdx = list()
colIdx = list()
grid = defaultdict(lambda:None)
rowGrid = defaultdict(list)
colGrid = defaultdict(list)
for i in range(N):
(r, c, a) = readInput()
r -= 1
c -= 1
rowGrid[r].append(c)
colGrid[c].append(r)
grid[(r, c)] = a
rowIdx.append(r)
colIdx.append(c)
pairIdx = rowIdx.copy()
for i in rowIdx:
pairIdx.remove(i)
for j in pairIdx:
tempRow = set(rowGrid[i])
tempPair = set(rowGrid[j])
intersect = tempRow.intersection(tempPair)
if (len(intersect) == 0):
continue
col = list(intersect)[0]
diff = grid[(i, col)] - grid[(j, col)]
for m in tempRow:
anchor = grid[(i, m)]
anchorP = grid[(j, m)]
if (anchorP == None and anchor < diff):
print('No')
exit()
elif (anchorP != None and anchor - anchorP != diff):
print('No')
exit()
for n in tempPair:
anchor = grid[(j, n)]
anchorP = grid[(i, n)]
if (anchorP == None and anchor < -diff):
print('No')
exit()
print('Yes') |
s083104686 | p03992 | u155667931 | 1475115711 | Python | Python (2.7.6) | py | Runtime Error | 17 | 2692 | 615 | def decoder(str_int):
s_=''
for a in str_int:
s_ = s_+(alpbet[a])
return s_
def encoder(s):
return [alpbet.index(a) for a in s]
s = raw_input()
K = input()
alpbet = 'abcdefghijklmnopqrstuvwxyz'
encoder = lambda s: [alpbet.index(a) for a in s]
inc_count = K
str_int = encoder(s)
for i in range(len(str_int)):
if i != len(str_int)-1:
if str_int[i] > 0:
cost = 26 - str_int[i]
if inc_count > cost:
inc_count -= cost
str_int[i] = 0
else:
str_int[i] = (str_int[i] + inc_count) % 26
print decoder(str_int) |
s533366368 | p03992 | u664481257 | 1475109571 | Python | Python (3.4.3) | py | Runtime Error | 69 | 7160 | 897 | # -*- 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:
pos = int(i)
if target_list[pos-1] == pos-1:
lovers.append(pos-1)
print(len(lovers))
if __name__ == "__main__":
import doctest
doctest.testmod()
target = input_two_line()
search_lovers(target)
|
s882378772 | p03992 | u436484848 | 1474936988 | Python | Python (3.4.3) | py | Runtime Error | 28 | 3316 | 1188 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# D-Grid and Integers
from collections import defaultdict
def ReadInput():
return [int(i) for i in input().split(" ")]
(R, C) = ReadInput()
N = int(input())
RowIdx = set()
ColIdx = set()
Grid = defaultdict(list)
RowGrid = defaultdict(list)
ColGrid = defaultdict(list)
for i in range(N):
(r, c, a) = ReadInput()
RowGrid[r].append(c)
ColGrid[c].append(r)
Grid[(r, c)] = a
RowIdx.add(r)
ColIdx.add(c)
fresh = 1
while(fresh == 1):
fresh = 0
for row in RowIdx:
if (len(RowGrid[row]) == 1):
continue
TempRow = RowGrid[row].copy()
TempColGrid = ColGrid.copy()
for pointer in TempRow:
TempCol = TempRow.copy()
TempCol.remove(pointer)
for pair in TempCol:
dif = Grid[(row, pointer)] - Grid[(row, pair)]
ObjCol = TempColGrid[pointer].copy()
ObjCol.remove(row)
for obj in ObjCol:
val = Grid[(obj, pointer)]- dif
if (val < 0):
print("No")
exit()
if ((obj, pair) in Grid):
if (val != Grid[(obj, pair)]):
print("No");
exit()
else:
Grid[(obj, pair)] = val
RowGrid[obj].append(pair)
ColGrid[pair].append(obj)
fresh = 1
print("Yes") |
s415572571 | p03992 | u579299997 | 1474921108 | Python | PyPy3 (2.4.0) | py | Runtime Error | 207 | 38640 | 1079 | ## this submission is just for checking pypy3 performance
## the code is borrowed from http://code-festival-2016-quala.contest.atcoder.jp/submissions/899133
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
def read():
return int(input())
def reads():
return [int(x) for x in input().split()]
setrecursionlimit(1000000)
(R, C) = reads()
N = read()
d = defaultdict(list)
V = set()
for _ in range(N):
(r, c, a) = reads()
(r, c) = (r-1, c-1)
d["R", r].append((("C", c), a))
d["C", c].append((("R", r), a))
V.add(("R", r))
V.add(("C", c))
def walk(v):
V.discard(v)
for (w, a) in d[v]:
wcol = a - col[v]
if w in col:
if col[w] != wcol:
print("No"); exit()
else:
col[w] = wcol
walk(w)
while len(V) > 0:
v = V.pop()
col = dict()
col[v] = 0
walk(v)
rcol = min(a for (v, a) in col.items() if v[0] == "R")
ccol = min(a for (v, a) in col.items() if v[0] == "C")
if rcol + ccol < 0:
print("No"); exit()
print("Yes")
|
s528719437 | p03992 | u155667931 | 1474865231 | Python | Python (2.7.6) | py | Runtime Error | 17 | 2568 | 763 | def decoder(str_int):
s_=''
for a in str_int:
s_ = s_+(alpbet[a])
return s_
def encoder(s):
return [alpbet.index(a) for a in s]
s = raw_input()
K = input()
alpbet = 'abcdefghijklmnopqrstuvwxyz'
encoder = lambda s: [alpbet.index(a) for a in s]
inc_count = K
str_int = encoder(s)
for i in range(len(str_int)):
#末尾文字でない
if i != len(str_int)-1:
#b~zの間でかつデクリメントできる
if str_int[i] > 0:
#aになるまで必要なインクリメント回数
cost = 26 - str_int[i]
if inc_count > cost:
inc_count -= cost
str_int[i] = 0
else:
str_int[i] = (str_int[i] + inc_count) % 26
print decoder(str_int) |
s587420832 | p03992 | u749912909 | 1474846004 | Python | Python (2.7.6) | py | Runtime Error | 17 | 2692 | 508 | #import ascii
#def ctoi(ch):
# return ch - 97
def itoc(i):
return chr(i+97)
s = raw_input()
s = map(lambda x: ord(x) - 97, s)
K = input()
N = len(s)
#print("s", s)
for i in range(N):
if s[i] + K <= 25:
pass
elif s[i] != 0:
K = K - (25 - s[i]) - 1
s[i] = 0
else:
pass
if K == 0:
break
#print(s)
#print(K)
for i in range(N-1, -1, -1):
if s[i] + K <= 25:
s[i] = s[i] + K
K = 0
break
else:
K = K - (26 - s[i])
s[i] = 0
#print(K)
tmp = [itoc(item) for item in s]
print("".join(tmp))
|
s579129116 | p03992 | u502175663 | 1474829818 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3064 | 158 | n = int(input())
a = input().split(' ')
t = 0
for o in range(n):
i = o + 1
b = int(a[o]) - i
if i == int(a[o + b]):
t += 1
print(int(t / 2)) |
s814855356 | p03992 | u502175663 | 1474825938 | Python | Python (3.4.3) | py | Runtime Error | 26 | 3068 | 187 | n = int(input())
l = input().split(' ')
t_l =[]
for i in range(0,n):
t = i + int(l[i])
t_l.append(t)
a = 0
for i in range(n *2 -1):
if t_l.count(i) == 2:
a += 1
print(a) |
s896895261 | p03992 | u502175663 | 1474825203 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3064 | 222 | n = int(input())
line = input().split(' ')
total_list =[]
for i in range(0,n):
total = i + int(line[i])
total_list.append(total)
a = 0
for i in range(n *2 -1):
if total_list.count(i) == 2:
a += 1
print(a) |
s593842783 | p03992 | u502175663 | 1474825062 | Python | Python (3.4.3) | py | Runtime Error | 24 | 3064 | 237 | n = int(input())
line = input().split(' ')
total_list =[]
for i in range(0,n):
total = i + int(line[i])
total_list.append(total)
answer = 0
for i in range(n *2 -1):
if total_list.count(i) == 2:
answer += 1
print(answer) |
s207376163 | p03992 | u091855288 | 1474819305 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3064 | 48 | s = input()
print('{0] {1}'.format(s[:4],s[4:])) |
s370972270 | p03992 | u254757050 | 1474775915 | Python | Python (2.7.6) | py | Runtime Error | 16 | 2568 | 352 | mystring = raw_input()
string_arr = []
q = int(raw_input())
for char in mystring:
string_arr.append(char)
for i in range(0,len(string_arr)):
val = ord('z') - ord(string_arr[i]) + 1
if val <= q:
string_arr[i] = 'a'
q = q-val
if q!=0:
q=q%26
string_arr[len(string_arr)-1] = chr(ord('a')+(ord(string_arr[i])+q)%ord('a'))
print "".join(string_arr) |
s345401217 | p03992 | u352021237 | 1474775259 | Python | PyPy2 (5.6.0) | py | Runtime Error | 37 | 8816 | 208 | y=list(raw_input())
k=int(raw_input())
for i in range(len(y)):
if y[i]=='a':
continue
else:
if 123-ord(y[i])<=k:
k-=(123-ord(y[i]))
y[i]='a'
y[len(y)-1]=chr(ord(y[len(y)-1])+k%26)
print ''.join(y) |
s943993852 | p03992 | u352021237 | 1474774619 | Python | PyPy2 (5.6.0) | py | Runtime Error | 41 | 8816 | 122 | n=int(raw_input())
N=map(int,raw_input().split())
count=0
for i in range(n):
if i==N[N[i]-1]-1:
count+=1
print count/2
|
s169893292 | p03992 | u849957366 | 1474773615 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3064 | 42 | s = raw_input()
print s[0:4] + ' ' + s[4:] |
s876518819 | p03992 | u477320129 | 1474772363 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3184 | 1133 | """難しいすぎるよぅ..."""
def solve():
R, C = list(map(int, input().split()))
N = int(input())
row = [[] for _ in range(R)]
field = {}
for _ in range(N):
r, c, a = list(map(int, input().split()))
r, c = r - 1, c - 1
row[r].append((c, a))
field[(r, c)] = a
row = [sorted(r) for r in row]
for rn, r in enumerate(row):
for i, e1 in enumerate(r):
for e2 in r[i+1:]:
n = e2[0] - e1[0]
print(r, e1, e2, n)
if n > C:
break
a = field.get((rn+n, e1[0]), None)
b = field.get((rn+n, e2[0]), None)
if a is None and b is None:
continue
if a is None:
if e1[1] + b - e2[1] < 0:
return False
elif b is None:
if e2[1] + a - e1[1] < 0:
return False
else:
if e1[1] + b == e2[1] + a:
return False
return True
print("Yes" if solve() else "No")
|
s316313504 | p03992 | u849957366 | 1474772339 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3064 | 241 | if __name__ == "__main__":
S="CODEFESTIVAL"
print (S[:4].upper() + " " + S[4:].upper())
S="POSTGRADUATE"
print (S[:4].upper() + " " + S[4:].upper())
S="ABCDEFGHIJKL"
print (S[:4].upper() + " " + S[4:].upper())
|
s664766905 | p03992 | u564917060 | 1474772283 | Python | Python (3.4.3) | py | Runtime Error | 31 | 3444 | 687 | from collections import deque
def next_char_ascii_num(c, k):
n = ord(c) + (k % 26)
if n <= 122:
return n
else:
return n % 123 + 97
s = input()
k = int(input())
d = deque()
l = len(s)
for i, x in enumerate(s):
if k <= 0:
l = i
break
else:
if k >= 25 and l != 1:
d.append(97)
k -= (26 - (ord(x) - 97))
else:
v =[next_char_ascii_num(x, y) for y in range(k + 1)]
min_index = v.index(min(v))
d.append(v[min_index])
k -= min_index
if k > 0:
d[-1] = next_char_ascii_num(chr(d[-1]), k)
else:
d += s[l:]
print("".join([chr(x) for x in d]))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.