user_id
stringlengths 10
10
| problem_id
stringlengths 6
6
| language
stringclasses 1
value | submission_id_v0
stringlengths 10
10
| submission_id_v1
stringlengths 10
10
| cpu_time_v0
int64 10
38.3k
| cpu_time_v1
int64 0
24.7k
| memory_v0
int64 2.57k
1.02M
| memory_v1
int64 2.57k
869k
| status_v0
stringclasses 1
value | status_v1
stringclasses 1
value | improvement_frac
float64 7.51
100
| input
stringlengths 20
4.55k
| target
stringlengths 17
3.34k
| code_v0_loc
int64 1
148
| code_v1_loc
int64 1
184
| code_v0_num_chars
int64 13
4.55k
| code_v1_num_chars
int64 14
3.34k
| code_v0_no_empty_lines
stringlengths 21
6.88k
| code_v1_no_empty_lines
stringlengths 20
4.93k
| code_same
bool 1
class | relative_loc_diff_percent
float64 0
79.8
| diff
list | diff_only_import_comment
bool 1
class | measured_runtime_v0
float64 0.01
4.45
| measured_runtime_v1
float64 0.01
4.31
| runtime_lift
float64 0
359
| key
list |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u789282627 | p02726 | python | s355222593 | s617093371 | 312 | 281 | 48,348 | 46,556 | Accepted | Accepted | 9.94 | N,X,Y = list(map(int,input().split()))
dist = [i*0 for i in range(N)]
for i in range(1,N+1):
for j in range(i,N+1):
if(i==j):
continue
a = abs(i-j)
b = abs(X-i)+1+abs(Y-j)
c = abs(X-j)+1+abs(Y-i)
dist[min(a,b,c)]+=1
for i in range(1,N):
print((dist[i]))
| N,X,Y = list(map(int,input().split()))
dist = [i*0 for i in range(N)]
for i in range(1,N+1):
for j in range(i,N+1):
if(i==j):
continue
a = abs(i-j)
b = abs(X-i)+1+abs(Y-j)
#c = abs(X-j)+1+abs(Y-i)
#print(str(min(a,b,c))+' when ('+str(i)+','+str(j)+')')
dist[min(a,b)]+=1
#if(j>X):
# if(j<X+((Y-X)/2)):
# dist[N-(Y-X)+(int((Y-X)/2) - 1) - j] += 1
# else:
# dist[N-1-j]+=1
#else:
# dist[N-(Y-X)-j]+=1
#print(Pi)
#dist=[]
#dist.append(abs(Ai[N-1]-Ai[0]))
#for i in range(N-1):
# dist.append(abs((K+Ai[i])-Ai[i+1]))
#print(min(dist))
#print(dist)
#Pi.sort(reverse=True)
#Qi.sort()
#Ri.sort()
for i in range(1,N):
print((dist[i]))
| 19 | 39 | 305 | 743 | N, X, Y = list(map(int, input().split()))
dist = [i * 0 for i in range(N)]
for i in range(1, N + 1):
for j in range(i, N + 1):
if i == j:
continue
a = abs(i - j)
b = abs(X - i) + 1 + abs(Y - j)
c = abs(X - j) + 1 + abs(Y - i)
dist[min(a, b, c)] += 1
for i in range(1, N):
print((dist[i]))
| N, X, Y = list(map(int, input().split()))
dist = [i * 0 for i in range(N)]
for i in range(1, N + 1):
for j in range(i, N + 1):
if i == j:
continue
a = abs(i - j)
b = abs(X - i) + 1 + abs(Y - j)
# c = abs(X-j)+1+abs(Y-i)
# print(str(min(a,b,c))+' when ('+str(i)+','+str(j)+')')
dist[min(a, b)] += 1
# if(j>X):
# if(j<X+((Y-X)/2)):
# dist[N-(Y-X)+(int((Y-X)/2) - 1) - j] += 1
# else:
# dist[N-1-j]+=1
# else:
# dist[N-(Y-X)-j]+=1
# print(Pi)
# dist=[]
# dist.append(abs(Ai[N-1]-Ai[0]))
# for i in range(N-1):
# dist.append(abs((K+Ai[i])-Ai[i+1]))
# print(min(dist))
# print(dist)
# Pi.sort(reverse=True)
# Qi.sort()
# Ri.sort()
for i in range(1, N):
print((dist[i]))
| false | 51.282051 | [
"- c = abs(X - j) + 1 + abs(Y - i)",
"- dist[min(a, b, c)] += 1",
"+ # c = abs(X-j)+1+abs(Y-i)",
"+ # print(str(min(a,b,c))+' when ('+str(i)+','+str(j)+')')",
"+ dist[min(a, b)] += 1",
"+ # if(j>X):",
"+ # if(j<X+((Y-X)/2)):",
"+ # dist[N-(Y-X)+(int((Y-X)/2) - 1) - j] += 1",
"+ # else:",
"+ # dist[N-1-j]+=1",
"+ # else:",
"+ # dist[N-(Y-X)-j]+=1",
"+# print(Pi)",
"+# dist=[]",
"+# dist.append(abs(Ai[N-1]-Ai[0]))",
"+# for i in range(N-1):",
"+# dist.append(abs((K+Ai[i])-Ai[i+1]))",
"+# print(min(dist))",
"+# print(dist)",
"+# Pi.sort(reverse=True)",
"+# Qi.sort()",
"+# Ri.sort()"
]
| false | 0.040495 | 0.041125 | 0.984684 | [
"s355222593",
"s617093371"
]
|
u964299793 | p03309 | python | s459845618 | s357286837 | 246 | 224 | 26,020 | 25,200 | Accepted | Accepted | 8.94 | n=int(eval(input()))
a=list(map(int,input().split()))
for i in range(n):
a[i]-=(i+1)
median=-1
a.sort()
if n%2==0:
median=(a[n//2]+a[n//2-1])//2
else:
median=a[n//2]
def comp(x):
su=0
for i in a:
su+=abs(i-x)
return su
print((min(comp(median-1),comp(median),comp(median+1))))
| n=int(eval(input()))
a=list(map(int,input().split()))
for i in range(n):
a[i]-=(i+1)
median=-1
a.sort()
if n%2==0:
median=(a[n//2]+a[n//2-1])//2
else:
median=a[n//2]
def comp(x):
su=0
for i in a:
su+=abs(i-x)
return su
print((min(comp(median),comp(median+1))))
| 19 | 19 | 321 | 306 | n = int(eval(input()))
a = list(map(int, input().split()))
for i in range(n):
a[i] -= i + 1
median = -1
a.sort()
if n % 2 == 0:
median = (a[n // 2] + a[n // 2 - 1]) // 2
else:
median = a[n // 2]
def comp(x):
su = 0
for i in a:
su += abs(i - x)
return su
print((min(comp(median - 1), comp(median), comp(median + 1))))
| n = int(eval(input()))
a = list(map(int, input().split()))
for i in range(n):
a[i] -= i + 1
median = -1
a.sort()
if n % 2 == 0:
median = (a[n // 2] + a[n // 2 - 1]) // 2
else:
median = a[n // 2]
def comp(x):
su = 0
for i in a:
su += abs(i - x)
return su
print((min(comp(median), comp(median + 1))))
| false | 0 | [
"-print((min(comp(median - 1), comp(median), comp(median + 1))))",
"+print((min(comp(median), comp(median + 1))))"
]
| false | 0.064585 | 0.042951 | 1.503694 | [
"s459845618",
"s357286837"
]
|
u084320347 | p03086 | python | s063238241 | s168503198 | 162 | 18 | 38,444 | 2,940 | Accepted | Accepted | 88.89 | s = eval(input())
a_s = ["A","C","G","T"]
l=[]
for i in range(len(s)):
if s[i] in a_s:
l.append(1)
else:
l.append(0)
cnt = 0
ans = 0
for i in range(len(s)):
if l[i] == 1:
cnt += 1
else:
ans = max(cnt,ans)
cnt = 0
ans = max(cnt,ans)
print(ans)
| s = eval(input())+"_"
cnt = 0
ans = 0
for i in range(len(s)):
if s[i] == "A" or s[i]=="C" or s[i]=="G" or s[i]=="T":
cnt+=1
else:
ans = max(ans, cnt)
cnt = 0
print(ans)
| 20 | 12 | 314 | 215 | s = eval(input())
a_s = ["A", "C", "G", "T"]
l = []
for i in range(len(s)):
if s[i] in a_s:
l.append(1)
else:
l.append(0)
cnt = 0
ans = 0
for i in range(len(s)):
if l[i] == 1:
cnt += 1
else:
ans = max(cnt, ans)
cnt = 0
ans = max(cnt, ans)
print(ans)
| s = eval(input()) + "_"
cnt = 0
ans = 0
for i in range(len(s)):
if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
cnt += 1
else:
ans = max(ans, cnt)
cnt = 0
print(ans)
| false | 40 | [
"-s = eval(input())",
"-a_s = [\"A\", \"C\", \"G\", \"T\"]",
"-l = []",
"-for i in range(len(s)):",
"- if s[i] in a_s:",
"- l.append(1)",
"- else:",
"- l.append(0)",
"+s = eval(input()) + \"_\"",
"- if l[i] == 1:",
"+ if s[i] == \"A\" or s[i] == \"C\" or s[i] == \"G\" or s[i] == \"T\":",
"- ans = max(cnt, ans)",
"+ ans = max(ans, cnt)",
"-ans = max(cnt, ans)"
]
| false | 0.044653 | 0.037237 | 1.199165 | [
"s063238241",
"s168503198"
]
|
u608088992 | p02947 | python | s396582007 | s341707116 | 1,889 | 367 | 25,960 | 24,652 | Accepted | Accepted | 80.57 | N = int(eval(input()))
alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
alphanum = dict()
for i in range(26): alphanum[alphabet[i]] = i
fact = [0] * (N + 1)
for i in range(1, N + 1): fact[i] = fact[i-1] + i
wordtype = dict()
for _ in range(N):
s = eval(input())
s_num = [0] * 26
for i in range(len(s)):
s_num[alphanum[s[i]]] += 1
s_str = ""
for i in range(26):
s_str += alphabet[i] + str(s_num[i])
if s_str in wordtype: wordtype[s_str] += 1
else: wordtype[s_str] = 1
ans = 0
for key in wordtype:
ans += fact[wordtype[key] - 1]
print(ans)
| import sys
def solve():
input = sys.stdin.readline
N = int(eval(input()))
S = [list(input().strip("\n")) for _ in range(N)]
for i in range(N): S[i].sort()
S.sort()
S.append(["E", "N", "D"])
ans = 0
current = "".join(S[0])
same = 0
for i in range(1, N+1):
tempS = "".join(S[i])
if tempS == current:
same += 1
else:
ans += (1 + same) * same // 2
same = 0
current = tempS
print(ans)
return 0
if __name__ == "__main__":
solve() | 26 | 27 | 701 | 572 | N = int(eval(input()))
alphabet = [
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
]
alphanum = dict()
for i in range(26):
alphanum[alphabet[i]] = i
fact = [0] * (N + 1)
for i in range(1, N + 1):
fact[i] = fact[i - 1] + i
wordtype = dict()
for _ in range(N):
s = eval(input())
s_num = [0] * 26
for i in range(len(s)):
s_num[alphanum[s[i]]] += 1
s_str = ""
for i in range(26):
s_str += alphabet[i] + str(s_num[i])
if s_str in wordtype:
wordtype[s_str] += 1
else:
wordtype[s_str] = 1
ans = 0
for key in wordtype:
ans += fact[wordtype[key] - 1]
print(ans)
| import sys
def solve():
input = sys.stdin.readline
N = int(eval(input()))
S = [list(input().strip("\n")) for _ in range(N)]
for i in range(N):
S[i].sort()
S.sort()
S.append(["E", "N", "D"])
ans = 0
current = "".join(S[0])
same = 0
for i in range(1, N + 1):
tempS = "".join(S[i])
if tempS == current:
same += 1
else:
ans += (1 + same) * same // 2
same = 0
current = tempS
print(ans)
return 0
if __name__ == "__main__":
solve()
| false | 3.703704 | [
"-N = int(eval(input()))",
"-alphabet = [",
"- \"a\",",
"- \"b\",",
"- \"c\",",
"- \"d\",",
"- \"e\",",
"- \"f\",",
"- \"g\",",
"- \"h\",",
"- \"i\",",
"- \"j\",",
"- \"k\",",
"- \"l\",",
"- \"m\",",
"- \"n\",",
"- \"o\",",
"- \"p\",",
"- \"q\",",
"- \"r\",",
"- \"s\",",
"- \"t\",",
"- \"u\",",
"- \"v\",",
"- \"w\",",
"- \"x\",",
"- \"y\",",
"- \"z\",",
"-]",
"-alphanum = dict()",
"-for i in range(26):",
"- alphanum[alphabet[i]] = i",
"-fact = [0] * (N + 1)",
"-for i in range(1, N + 1):",
"- fact[i] = fact[i - 1] + i",
"-wordtype = dict()",
"-for _ in range(N):",
"- s = eval(input())",
"- s_num = [0] * 26",
"- for i in range(len(s)):",
"- s_num[alphanum[s[i]]] += 1",
"- s_str = \"\"",
"- for i in range(26):",
"- s_str += alphabet[i] + str(s_num[i])",
"- if s_str in wordtype:",
"- wordtype[s_str] += 1",
"- else:",
"- wordtype[s_str] = 1",
"-ans = 0",
"-for key in wordtype:",
"- ans += fact[wordtype[key] - 1]",
"-print(ans)",
"+import sys",
"+",
"+",
"+def solve():",
"+ input = sys.stdin.readline",
"+ N = int(eval(input()))",
"+ S = [list(input().strip(\"\\n\")) for _ in range(N)]",
"+ for i in range(N):",
"+ S[i].sort()",
"+ S.sort()",
"+ S.append([\"E\", \"N\", \"D\"])",
"+ ans = 0",
"+ current = \"\".join(S[0])",
"+ same = 0",
"+ for i in range(1, N + 1):",
"+ tempS = \"\".join(S[i])",
"+ if tempS == current:",
"+ same += 1",
"+ else:",
"+ ans += (1 + same) * same // 2",
"+ same = 0",
"+ current = tempS",
"+ print(ans)",
"+ return 0",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ solve()"
]
| false | 0.036419 | 0.034433 | 1.057673 | [
"s396582007",
"s341707116"
]
|
u707808519 | p02629 | python | s528585456 | s948149642 | 34 | 29 | 9,212 | 9,188 | Accepted | Accepted | 14.71 | alp = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
y = int(eval(input()))
ans = []
while y > 26:
res = y%26
if res == 0:
ans.append(25)
y = y//26 - 1
else:
ans.append(y%26 - 1)
y = y // 26
ans.append(y - 1)
ans = ans[::-1]
S = ''
for i in range(len(ans)):
S += alp[ans[i]]
print(S) | N = int(eval(input()))
alp = [chr(i) for i in range(ord('a'), ord('z')+1)]
ans = []
while N > 0:
res = N % 26
ans.append(alp[res - 1])
N //= 26
if res == 0:
N -= 1
ans = ans[::-1]
print((''.join(ans))) | 19 | 13 | 404 | 231 | alp = [
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
]
y = int(eval(input()))
ans = []
while y > 26:
res = y % 26
if res == 0:
ans.append(25)
y = y // 26 - 1
else:
ans.append(y % 26 - 1)
y = y // 26
ans.append(y - 1)
ans = ans[::-1]
S = ""
for i in range(len(ans)):
S += alp[ans[i]]
print(S)
| N = int(eval(input()))
alp = [chr(i) for i in range(ord("a"), ord("z") + 1)]
ans = []
while N > 0:
res = N % 26
ans.append(alp[res - 1])
N //= 26
if res == 0:
N -= 1
ans = ans[::-1]
print(("".join(ans)))
| false | 31.578947 | [
"-alp = [",
"- \"a\",",
"- \"b\",",
"- \"c\",",
"- \"d\",",
"- \"e\",",
"- \"f\",",
"- \"g\",",
"- \"h\",",
"- \"i\",",
"- \"j\",",
"- \"k\",",
"- \"l\",",
"- \"m\",",
"- \"n\",",
"- \"o\",",
"- \"p\",",
"- \"q\",",
"- \"r\",",
"- \"s\",",
"- \"t\",",
"- \"u\",",
"- \"v\",",
"- \"w\",",
"- \"x\",",
"- \"y\",",
"- \"z\",",
"-]",
"-y = int(eval(input()))",
"+N = int(eval(input()))",
"+alp = [chr(i) for i in range(ord(\"a\"), ord(\"z\") + 1)]",
"-while y > 26:",
"- res = y % 26",
"+while N > 0:",
"+ res = N % 26",
"+ ans.append(alp[res - 1])",
"+ N //= 26",
"- ans.append(25)",
"- y = y // 26 - 1",
"- else:",
"- ans.append(y % 26 - 1)",
"- y = y // 26",
"-ans.append(y - 1)",
"+ N -= 1",
"-S = \"\"",
"-for i in range(len(ans)):",
"- S += alp[ans[i]]",
"-print(S)",
"+print((\"\".join(ans)))"
]
| false | 0.186537 | 0.007909 | 23.584223 | [
"s528585456",
"s948149642"
]
|
u080364835 | p03817 | python | s103628475 | s021357592 | 29 | 25 | 9,156 | 9,132 | Accepted | Accepted | 13.79 | import math
x = int(eval(input()))
if 1 <= x%11 <= 6:
print((math.ceil(x/11)*2 - 1))
else:
print((math.ceil(x/11)*2)) | n = int(eval(input()))
ans = n//11*2
if 0 < n%11 <= 6:
ans += 1
elif 6 < n%11 <= 10:
ans += 2
print(ans) | 7 | 8 | 122 | 114 | import math
x = int(eval(input()))
if 1 <= x % 11 <= 6:
print((math.ceil(x / 11) * 2 - 1))
else:
print((math.ceil(x / 11) * 2))
| n = int(eval(input()))
ans = n // 11 * 2
if 0 < n % 11 <= 6:
ans += 1
elif 6 < n % 11 <= 10:
ans += 2
print(ans)
| false | 12.5 | [
"-import math",
"-",
"-x = int(eval(input()))",
"-if 1 <= x % 11 <= 6:",
"- print((math.ceil(x / 11) * 2 - 1))",
"-else:",
"- print((math.ceil(x / 11) * 2))",
"+n = int(eval(input()))",
"+ans = n // 11 * 2",
"+if 0 < n % 11 <= 6:",
"+ ans += 1",
"+elif 6 < n % 11 <= 10:",
"+ ans += 2",
"+print(ans)"
]
| false | 0.073764 | 0.118519 | 0.622384 | [
"s103628475",
"s021357592"
]
|
u357751375 | p02860 | python | s985187570 | s148520493 | 33 | 26 | 9,120 | 9,148 | Accepted | Accepted | 21.21 | n = int(eval(input()))
s = eval(input())
if n % 2 == 1:
print('No')
exit(0)
n = n // 2
a = s[:n]
if s.count(a) == 2:
print('Yes')
else:
print('No') | n = int(eval(input()))
s = eval(input())
a = s[:n//2]
b = s[n//2:]
if a == b:
print('Yes')
else:
print('No') | 13 | 8 | 165 | 111 | n = int(eval(input()))
s = eval(input())
if n % 2 == 1:
print("No")
exit(0)
n = n // 2
a = s[:n]
if s.count(a) == 2:
print("Yes")
else:
print("No")
| n = int(eval(input()))
s = eval(input())
a = s[: n // 2]
b = s[n // 2 :]
if a == b:
print("Yes")
else:
print("No")
| false | 38.461538 | [
"-if n % 2 == 1:",
"- print(\"No\")",
"- exit(0)",
"-n = n // 2",
"-a = s[:n]",
"-if s.count(a) == 2:",
"+a = s[: n // 2]",
"+b = s[n // 2 :]",
"+if a == b:"
]
| false | 0.045268 | 0.070292 | 0.644005 | [
"s985187570",
"s148520493"
]
|
u197300773 | p03141 | python | s033683451 | s533464584 | 511 | 360 | 23,260 | 7,388 | Accepted | Accepted | 29.55 | n=int(eval(input()))
x=[]
for _ in range(n):
a,b=list(map(int,input().split()))
x.append([a+b,a,b])
x.sort(reverse=True)
ans=0
for i in range(n):
if i%2==0: ans+=x[i][1]
else: ans-=x[i][2]
print(ans) | n=int(eval(input()))
x=[]
ans=0
for _ in range(n):
a,b=list(map(int,input().split()))
x.append(a+b)
ans-=b
x.sort(reverse=True)
ans+=sum(x[i] for i in range(n) if i%2==0)
print(ans) | 11 | 10 | 213 | 190 | n = int(eval(input()))
x = []
for _ in range(n):
a, b = list(map(int, input().split()))
x.append([a + b, a, b])
x.sort(reverse=True)
ans = 0
for i in range(n):
if i % 2 == 0:
ans += x[i][1]
else:
ans -= x[i][2]
print(ans)
| n = int(eval(input()))
x = []
ans = 0
for _ in range(n):
a, b = list(map(int, input().split()))
x.append(a + b)
ans -= b
x.sort(reverse=True)
ans += sum(x[i] for i in range(n) if i % 2 == 0)
print(ans)
| false | 9.090909 | [
"+ans = 0",
"- x.append([a + b, a, b])",
"+ x.append(a + b)",
"+ ans -= b",
"-ans = 0",
"-for i in range(n):",
"- if i % 2 == 0:",
"- ans += x[i][1]",
"- else:",
"- ans -= x[i][2]",
"+ans += sum(x[i] for i in range(n) if i % 2 == 0)"
]
| false | 0.036248 | 0.035278 | 1.027481 | [
"s033683451",
"s533464584"
]
|
u899975427 | p03087 | python | s290268145 | s058396875 | 1,570 | 1,305 | 6,212 | 6,104 | Accepted | Accepted | 16.88 | N,Q = (int(i) for i in input().split())
S = eval(input())
acl = [0] * N
cnt = 0
for j in range(1,N):
if S[j-1] == 'A' and S[j] == 'C':
cnt += 1
acl[j] = cnt
for k in range(Q):
x,y = (int(i)-1 for i in input().split())
print((acl[y]-acl[x])) | N,Q = (int(i) for i in input().split())
S = eval(input())
acl = [0 for i in range(N)]
cnt = 0
for j in range(1,N):
if S[j-1] == 'A' and S[j] == 'C':
cnt += 1
acl[j] = cnt
for k in range(Q):
x,y = list(map(int, input().split()))
print((acl[y-1]-acl[x-1])) | 13 | 12 | 264 | 270 | N, Q = (int(i) for i in input().split())
S = eval(input())
acl = [0] * N
cnt = 0
for j in range(1, N):
if S[j - 1] == "A" and S[j] == "C":
cnt += 1
acl[j] = cnt
for k in range(Q):
x, y = (int(i) - 1 for i in input().split())
print((acl[y] - acl[x]))
| N, Q = (int(i) for i in input().split())
S = eval(input())
acl = [0 for i in range(N)]
cnt = 0
for j in range(1, N):
if S[j - 1] == "A" and S[j] == "C":
cnt += 1
acl[j] = cnt
for k in range(Q):
x, y = list(map(int, input().split()))
print((acl[y - 1] - acl[x - 1]))
| false | 7.692308 | [
"-acl = [0] * N",
"+acl = [0 for i in range(N)]",
"- x, y = (int(i) - 1 for i in input().split())",
"- print((acl[y] - acl[x]))",
"+ x, y = list(map(int, input().split()))",
"+ print((acl[y - 1] - acl[x - 1]))"
]
| false | 0.036322 | 0.035671 | 1.018273 | [
"s290268145",
"s058396875"
]
|
u782685137 | p03157 | python | s747905835 | s263189010 | 462 | 425 | 18,404 | 18,020 | Accepted | Accepted | 8.01 | import collections
H,W=list(map(int,input().split()))
S=[eval(input()) for i in [0]*H]
M=[[-1]*W for _ in [0]*H]
k=0
for y in range(H):
for x in range(W):
if M[y][x]!=-1:continue #visited
M[y][x]=k
Q=collections.deque()
Q.append((y,x))
while len(Q)>0:
i,j=Q.popleft()
s=S[i][j]
if i+1<H and M[i+1][j]==-1 and s!=S[i+1][j]:
M[i+1][j]=k
Q.append((i+1,j))
if i-1>=0 and M[i-1][j]==-1 and s!=S[i-1][j]:
M[i-1][j]=k
Q.append((i-1,j))
if j+1<W and M[i][j+1]==-1 and s!=S[i][j+1]:
M[i][j+1]=k
Q.append((i,j+1))
if j-1>=0 and M[i][j-1]==-1 and s!=S[i][j-1]:
M[i][j-1]=k
Q.append((i,j-1))
#print(k,M,Q)
k+=1
ds={}
dd={}
for i in range(H):
for j in range(W):
m=M[i][j]
if S[i][j]=='#':ds[m]=ds.get(m,0)+1
else:dd[m]=dd.get(m,0)+1
r=0
for i in range(k):
r += ds.get(i,0)*dd.get(i,0)
print(r) | H,W=list(map(int,input().split()))
h=list(range(H))
S=[eval(input()) for _ in h]
M=[[-1]*W for _ in h]
k=0
for y in h:
for x in range(W):
if M[y][x]!=-1:continue
M[y][x]=k;Q=[(y,x)]
while len(Q)>0:
i,j=Q.pop();s=S[i][j];p=i+1;q=i-1;r=j+1;t=j-1
if p<H and M[p][j]==-1 and s!=S[p][j]:M[p][j]=k;Q+=[(p,j)]
if i>0 and M[q][j]==-1 and s!=S[q][j]:M[q][j]=k;Q+=[(q,j)]
if r<W and M[i][r]==-1 and s!=S[i][r]:M[i][r]=k;Q+=[(i,r)]
if j>0 and M[i][t]==-1 and s!=S[i][t]:M[i][t]=k;Q+=[(i,t)]
k+=1
s={}
d={}
for i in range(H):
for j in range(W):
m=M[i][j]
if S[i][j]=='#':s[m]=s.get(m,0)+1
else:d[m]=d.get(m,0)+1
print((sum(s.get(i,0)*d.get(i,0)for i in range(k)))) | 39 | 24 | 1,102 | 779 | import collections
H, W = list(map(int, input().split()))
S = [eval(input()) for i in [0] * H]
M = [[-1] * W for _ in [0] * H]
k = 0
for y in range(H):
for x in range(W):
if M[y][x] != -1:
continue # visited
M[y][x] = k
Q = collections.deque()
Q.append((y, x))
while len(Q) > 0:
i, j = Q.popleft()
s = S[i][j]
if i + 1 < H and M[i + 1][j] == -1 and s != S[i + 1][j]:
M[i + 1][j] = k
Q.append((i + 1, j))
if i - 1 >= 0 and M[i - 1][j] == -1 and s != S[i - 1][j]:
M[i - 1][j] = k
Q.append((i - 1, j))
if j + 1 < W and M[i][j + 1] == -1 and s != S[i][j + 1]:
M[i][j + 1] = k
Q.append((i, j + 1))
if j - 1 >= 0 and M[i][j - 1] == -1 and s != S[i][j - 1]:
M[i][j - 1] = k
Q.append((i, j - 1))
# print(k,M,Q)
k += 1
ds = {}
dd = {}
for i in range(H):
for j in range(W):
m = M[i][j]
if S[i][j] == "#":
ds[m] = ds.get(m, 0) + 1
else:
dd[m] = dd.get(m, 0) + 1
r = 0
for i in range(k):
r += ds.get(i, 0) * dd.get(i, 0)
print(r)
| H, W = list(map(int, input().split()))
h = list(range(H))
S = [eval(input()) for _ in h]
M = [[-1] * W for _ in h]
k = 0
for y in h:
for x in range(W):
if M[y][x] != -1:
continue
M[y][x] = k
Q = [(y, x)]
while len(Q) > 0:
i, j = Q.pop()
s = S[i][j]
p = i + 1
q = i - 1
r = j + 1
t = j - 1
if p < H and M[p][j] == -1 and s != S[p][j]:
M[p][j] = k
Q += [(p, j)]
if i > 0 and M[q][j] == -1 and s != S[q][j]:
M[q][j] = k
Q += [(q, j)]
if r < W and M[i][r] == -1 and s != S[i][r]:
M[i][r] = k
Q += [(i, r)]
if j > 0 and M[i][t] == -1 and s != S[i][t]:
M[i][t] = k
Q += [(i, t)]
k += 1
s = {}
d = {}
for i in range(H):
for j in range(W):
m = M[i][j]
if S[i][j] == "#":
s[m] = s.get(m, 0) + 1
else:
d[m] = d.get(m, 0) + 1
print((sum(s.get(i, 0) * d.get(i, 0) for i in range(k))))
| false | 38.461538 | [
"-import collections",
"-",
"-S = [eval(input()) for i in [0] * H]",
"-M = [[-1] * W for _ in [0] * H]",
"+h = list(range(H))",
"+S = [eval(input()) for _ in h]",
"+M = [[-1] * W for _ in h]",
"-for y in range(H):",
"+for y in h:",
"- continue # visited",
"+ continue",
"- Q = collections.deque()",
"- Q.append((y, x))",
"+ Q = [(y, x)]",
"- i, j = Q.popleft()",
"+ i, j = Q.pop()",
"- if i + 1 < H and M[i + 1][j] == -1 and s != S[i + 1][j]:",
"- M[i + 1][j] = k",
"- Q.append((i + 1, j))",
"- if i - 1 >= 0 and M[i - 1][j] == -1 and s != S[i - 1][j]:",
"- M[i - 1][j] = k",
"- Q.append((i - 1, j))",
"- if j + 1 < W and M[i][j + 1] == -1 and s != S[i][j + 1]:",
"- M[i][j + 1] = k",
"- Q.append((i, j + 1))",
"- if j - 1 >= 0 and M[i][j - 1] == -1 and s != S[i][j - 1]:",
"- M[i][j - 1] = k",
"- Q.append((i, j - 1))",
"- # print(k,M,Q)",
"+ p = i + 1",
"+ q = i - 1",
"+ r = j + 1",
"+ t = j - 1",
"+ if p < H and M[p][j] == -1 and s != S[p][j]:",
"+ M[p][j] = k",
"+ Q += [(p, j)]",
"+ if i > 0 and M[q][j] == -1 and s != S[q][j]:",
"+ M[q][j] = k",
"+ Q += [(q, j)]",
"+ if r < W and M[i][r] == -1 and s != S[i][r]:",
"+ M[i][r] = k",
"+ Q += [(i, r)]",
"+ if j > 0 and M[i][t] == -1 and s != S[i][t]:",
"+ M[i][t] = k",
"+ Q += [(i, t)]",
"-ds = {}",
"-dd = {}",
"+s = {}",
"+d = {}",
"- ds[m] = ds.get(m, 0) + 1",
"+ s[m] = s.get(m, 0) + 1",
"- dd[m] = dd.get(m, 0) + 1",
"-r = 0",
"-for i in range(k):",
"- r += ds.get(i, 0) * dd.get(i, 0)",
"-print(r)",
"+ d[m] = d.get(m, 0) + 1",
"+print((sum(s.get(i, 0) * d.get(i, 0) for i in range(k))))"
]
| false | 0.037192 | 0.044109 | 0.843185 | [
"s747905835",
"s263189010"
]
|
u489959379 | p02918 | python | s521376972 | s479067785 | 42 | 31 | 3,316 | 3,316 | Accepted | Accepted | 26.19 | n, k = list(map(int, input().split()))
s = eval(input())
score = 0
ans = 0
for i in range(n-1):
if s[i] == s[i+1]:
score += 1
ans = min(score + 2 * k, n-1)
print(ans)
| import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
n, k = list(map(int, input().split()))
S = input().strip()
cnt = 0
for i in range(1, n):
if S[i - 1] == S[i]:
cnt += 1
res = min(cnt + k * 2, n - 1)
print(res)
if __name__ == '__main__':
resolve()
| 10 | 23 | 177 | 391 | n, k = list(map(int, input().split()))
s = eval(input())
score = 0
ans = 0
for i in range(n - 1):
if s[i] == s[i + 1]:
score += 1
ans = min(score + 2 * k, n - 1)
print(ans)
| import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
f_inf = float("inf")
mod = 10**9 + 7
def resolve():
n, k = list(map(int, input().split()))
S = input().strip()
cnt = 0
for i in range(1, n):
if S[i - 1] == S[i]:
cnt += 1
res = min(cnt + k * 2, n - 1)
print(res)
if __name__ == "__main__":
resolve()
| false | 56.521739 | [
"-n, k = list(map(int, input().split()))",
"-s = eval(input())",
"-score = 0",
"-ans = 0",
"-for i in range(n - 1):",
"- if s[i] == s[i + 1]:",
"- score += 1",
"-ans = min(score + 2 * k, n - 1)",
"-print(ans)",
"+import sys",
"+",
"+sys.setrecursionlimit(10**7)",
"+input = sys.stdin.readline",
"+f_inf = float(\"inf\")",
"+mod = 10**9 + 7",
"+",
"+",
"+def resolve():",
"+ n, k = list(map(int, input().split()))",
"+ S = input().strip()",
"+ cnt = 0",
"+ for i in range(1, n):",
"+ if S[i - 1] == S[i]:",
"+ cnt += 1",
"+ res = min(cnt + k * 2, n - 1)",
"+ print(res)",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ resolve()"
]
| false | 0.169231 | 0.041552 | 4.072713 | [
"s521376972",
"s479067785"
]
|
u353797797 | p03062 | python | s814487217 | s978195652 | 180 | 53 | 23,304 | 15,180 | Accepted | Accepted | 70.56 | import numpy as np
n = int(eval(input()))
a = np.array(list(map(int, input().split())),dtype="i8")
cm = np.sum(a < 0)
a = np.abs(a)
s = np.sum(a)
if cm % 2:
s -= np.min(a) * 2
print(s)
| import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def main():
n=int(input())
aa=LI()
pp=[]
mm=[]
for a in aa:
if a<0:mm.append(a)
else:pp.append(a)
if not mm:
print(sum(pp))
exit()
if not pp:
if len(mm)%2:
print(-sum(mm)+max(mm)*2)
else:
print(-sum(mm))
exit()
if len(mm)%2:
m=max(mm)
p=min(pp)
if p+m>=0:print(sum(pp)-sum(mm)+2*m)
else:print(sum(pp)-2*p-sum(mm))
else:
print(sum(pp)-sum(mm))
main()
| 10 | 35 | 193 | 831 | import numpy as np
n = int(eval(input()))
a = np.array(list(map(int, input().split())), dtype="i8")
cm = np.sum(a < 0)
a = np.abs(a)
s = np.sum(a)
if cm % 2:
s -= np.min(a) * 2
print(s)
| import sys
sys.setrecursionlimit(10**6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI():
return map(int, sys.stdin.readline().split())
def LI():
return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number):
return [LI() for _ in range(rows_number)]
def main():
n = int(input())
aa = LI()
pp = []
mm = []
for a in aa:
if a < 0:
mm.append(a)
else:
pp.append(a)
if not mm:
print(sum(pp))
exit()
if not pp:
if len(mm) % 2:
print(-sum(mm) + max(mm) * 2)
else:
print(-sum(mm))
exit()
if len(mm) % 2:
m = max(mm)
p = min(pp)
if p + m >= 0:
print(sum(pp) - sum(mm) + 2 * m)
else:
print(sum(pp) - 2 * p - sum(mm))
else:
print(sum(pp) - sum(mm))
main()
| false | 71.428571 | [
"-import numpy as np",
"+import sys",
"-n = int(eval(input()))",
"-a = np.array(list(map(int, input().split())), dtype=\"i8\")",
"-cm = np.sum(a < 0)",
"-a = np.abs(a)",
"-s = np.sum(a)",
"-if cm % 2:",
"- s -= np.min(a) * 2",
"-print(s)",
"+sys.setrecursionlimit(10**6)",
"+int1 = lambda x: int(x) - 1",
"+p2D = lambda x: print(*x, sep=\"\\n\")",
"+",
"+",
"+def MI():",
"+ return map(int, sys.stdin.readline().split())",
"+",
"+",
"+def LI():",
"+ return list(map(int, sys.stdin.readline().split()))",
"+",
"+",
"+def LLI(rows_number):",
"+ return [LI() for _ in range(rows_number)]",
"+",
"+",
"+def main():",
"+ n = int(input())",
"+ aa = LI()",
"+ pp = []",
"+ mm = []",
"+ for a in aa:",
"+ if a < 0:",
"+ mm.append(a)",
"+ else:",
"+ pp.append(a)",
"+ if not mm:",
"+ print(sum(pp))",
"+ exit()",
"+ if not pp:",
"+ if len(mm) % 2:",
"+ print(-sum(mm) + max(mm) * 2)",
"+ else:",
"+ print(-sum(mm))",
"+ exit()",
"+ if len(mm) % 2:",
"+ m = max(mm)",
"+ p = min(pp)",
"+ if p + m >= 0:",
"+ print(sum(pp) - sum(mm) + 2 * m)",
"+ else:",
"+ print(sum(pp) - 2 * p - sum(mm))",
"+ else:",
"+ print(sum(pp) - sum(mm))",
"+",
"+",
"+main()"
]
| false | 0.455854 | 0.122365 | 3.725356 | [
"s814487217",
"s978195652"
]
|
u631277801 | p04034 | python | s291636337 | s830791154 | 275 | 247 | 18,180 | 4,596 | Accepted | Accepted | 10.18 | import sys
stdin = sys.stdin
sys.setrecursionlimit(10**5)
def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())
def operation(box:list, frm:int, to:int):
box[frm] -= 1
box[to] += 1
n,m = li()
box = [1 for _ in range(n)]
cand = [False for _ in range(n)]
cand[0] = True
ope = []
for _ in range(m):
x,y = li_()
ope.append((x,y))
for x,y in ope:
operation(box,x,y)
if (not cand[y]) and cand[x]:
cand[y] = True
if cand[x] and box[x] > 0:
cand[x] = True
elif cand[x] and box[x] == 0:
cand[x] = False
print((sum(cand))) | import sys
stdin = sys.stdin
sys.setrecursionlimit(10**8)
def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())
n,m = li()
ball = [1]*n
inred = [0]*n
inred[0] = 1
for _ in range(m):
x,y = li_()
if inred[x] and ball[x] == 1:
inred[x] = 0
ball[x] = 0
inred[y] = 1
ball[y] += 1
elif inred[x] and ball[x] > 1:
ball[x] -= 1
inred[y] = 1
ball[y] += 1
else:
ball[x] -= 1
ball[y] += 1
ans = 0
for ri in inred:
ans += ri
print(ans) | 39 | 42 | 956 | 920 | import sys
stdin = sys.stdin
sys.setrecursionlimit(10**5)
def li():
return list(map(int, stdin.readline().split()))
def li_():
return [int(x) - 1 for x in stdin.readline().split()]
def lf():
return list(map(float, stdin.readline().split()))
def ls():
return stdin.readline().split()
def ns():
return stdin.readline().rstrip()
def lc():
return list(ns())
def ni():
return int(stdin.readline())
def nf():
return float(stdin.readline())
def operation(box: list, frm: int, to: int):
box[frm] -= 1
box[to] += 1
n, m = li()
box = [1 for _ in range(n)]
cand = [False for _ in range(n)]
cand[0] = True
ope = []
for _ in range(m):
x, y = li_()
ope.append((x, y))
for x, y in ope:
operation(box, x, y)
if (not cand[y]) and cand[x]:
cand[y] = True
if cand[x] and box[x] > 0:
cand[x] = True
elif cand[x] and box[x] == 0:
cand[x] = False
print((sum(cand)))
| import sys
stdin = sys.stdin
sys.setrecursionlimit(10**8)
def li():
return list(map(int, stdin.readline().split()))
def li_():
return [int(x) - 1 for x in stdin.readline().split()]
def lf():
return list(map(float, stdin.readline().split()))
def ls():
return stdin.readline().split()
def ns():
return stdin.readline().rstrip()
def lc():
return list(ns())
def ni():
return int(stdin.readline())
def nf():
return float(stdin.readline())
n, m = li()
ball = [1] * n
inred = [0] * n
inred[0] = 1
for _ in range(m):
x, y = li_()
if inred[x] and ball[x] == 1:
inred[x] = 0
ball[x] = 0
inred[y] = 1
ball[y] += 1
elif inred[x] and ball[x] > 1:
ball[x] -= 1
inred[y] = 1
ball[y] += 1
else:
ball[x] -= 1
ball[y] += 1
ans = 0
for ri in inred:
ans += ri
print(ans)
| false | 7.142857 | [
"-sys.setrecursionlimit(10**5)",
"+sys.setrecursionlimit(10**8)",
"-def operation(box: list, frm: int, to: int):",
"- box[frm] -= 1",
"- box[to] += 1",
"-",
"-",
"-box = [1 for _ in range(n)]",
"-cand = [False for _ in range(n)]",
"-cand[0] = True",
"-ope = []",
"+ball = [1] * n",
"+inred = [0] * n",
"+inred[0] = 1",
"- ope.append((x, y))",
"-for x, y in ope:",
"- operation(box, x, y)",
"- if (not cand[y]) and cand[x]:",
"- cand[y] = True",
"- if cand[x] and box[x] > 0:",
"- cand[x] = True",
"- elif cand[x] and box[x] == 0:",
"- cand[x] = False",
"-print((sum(cand)))",
"+ if inred[x] and ball[x] == 1:",
"+ inred[x] = 0",
"+ ball[x] = 0",
"+ inred[y] = 1",
"+ ball[y] += 1",
"+ elif inred[x] and ball[x] > 1:",
"+ ball[x] -= 1",
"+ inred[y] = 1",
"+ ball[y] += 1",
"+ else:",
"+ ball[x] -= 1",
"+ ball[y] += 1",
"+ans = 0",
"+for ri in inred:",
"+ ans += ri",
"+print(ans)"
]
| false | 0.091073 | 0.088302 | 1.03139 | [
"s291636337",
"s830791154"
]
|
u197457087 | p03151 | python | s349509234 | s501957888 | 152 | 113 | 18,292 | 24,040 | Accepted | Accepted | 25.66 | N = int(eval(input()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
if sum(B) > sum(A):
print("-1")
exit()
D = []
for i in range(N):
D.append(A[i]-B[i])
D.sort()
#print(D)
num = 0
s = 0; t = -1
yoyu = 0
while D[s] < 0:
if yoyu+D[s] <0:
num += 1 #ここで一番余裕があるのを取り出す。
yoyu += D[t]
t -= 1
num += 1 #ここで足りない分が足された試験
yoyu += D[s]
s += 1
print(num) | N = int(eval(input()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
if sum(B)>sum(A):
print((-1))
exit()
amari = []
fusoku = []
for i in range(N):
if A[i] < B[i]:
fusoku.append(B[i]-A[i])
elif A[i] > B[i]:
amari.append(A[i]-B[i])
amari.sort(reverse=True)
ans = len(fusoku)
nokori = sum(fusoku)
now = 0
while nokori > 0:
nokori -= amari[now]
now += 1
ans += 1
print(ans)
| 23 | 30 | 409 | 458 | N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
if sum(B) > sum(A):
print("-1")
exit()
D = []
for i in range(N):
D.append(A[i] - B[i])
D.sort()
# print(D)
num = 0
s = 0
t = -1
yoyu = 0
while D[s] < 0:
if yoyu + D[s] < 0:
num += 1 # ここで一番余裕があるのを取り出す。
yoyu += D[t]
t -= 1
num += 1 # ここで足りない分が足された試験
yoyu += D[s]
s += 1
print(num)
| N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
if sum(B) > sum(A):
print((-1))
exit()
amari = []
fusoku = []
for i in range(N):
if A[i] < B[i]:
fusoku.append(B[i] - A[i])
elif A[i] > B[i]:
amari.append(A[i] - B[i])
amari.sort(reverse=True)
ans = len(fusoku)
nokori = sum(fusoku)
now = 0
while nokori > 0:
nokori -= amari[now]
now += 1
ans += 1
print(ans)
| false | 23.333333 | [
"- print(\"-1\")",
"+ print((-1))",
"-D = []",
"+amari = []",
"+fusoku = []",
"- D.append(A[i] - B[i])",
"-D.sort()",
"-# print(D)",
"-num = 0",
"-s = 0",
"-t = -1",
"-yoyu = 0",
"-while D[s] < 0:",
"- if yoyu + D[s] < 0:",
"- num += 1 # ここで一番余裕があるのを取り出す。",
"- yoyu += D[t]",
"- t -= 1",
"- num += 1 # ここで足りない分が足された試験",
"- yoyu += D[s]",
"- s += 1",
"-print(num)",
"+ if A[i] < B[i]:",
"+ fusoku.append(B[i] - A[i])",
"+ elif A[i] > B[i]:",
"+ amari.append(A[i] - B[i])",
"+amari.sort(reverse=True)",
"+ans = len(fusoku)",
"+nokori = sum(fusoku)",
"+now = 0",
"+while nokori > 0:",
"+ nokori -= amari[now]",
"+ now += 1",
"+ ans += 1",
"+print(ans)"
]
| false | 0.041423 | 0.048862 | 0.847757 | [
"s349509234",
"s501957888"
]
|
u124498235 | p03795 | python | s400056386 | s025415900 | 19 | 17 | 2,940 | 3,064 | Accepted | Accepted | 10.53 | n = int(eval(input()))
ans = n * 800 - n//15 * 200
print (ans) | n = int(eval(input()))
x = 800*n
y = int(n/15)
print((x-200*y)) | 3 | 4 | 58 | 59 | n = int(eval(input()))
ans = n * 800 - n // 15 * 200
print(ans)
| n = int(eval(input()))
x = 800 * n
y = int(n / 15)
print((x - 200 * y))
| false | 25 | [
"-ans = n * 800 - n // 15 * 200",
"-print(ans)",
"+x = 800 * n",
"+y = int(n / 15)",
"+print((x - 200 * y))"
]
| false | 0.042397 | 0.038805 | 1.092569 | [
"s400056386",
"s025415900"
]
|
u731726888 | p03863 | python | s315516595 | s161562720 | 29 | 17 | 3,316 | 3,316 | Accepted | Accepted | 41.38 | s = eval(input())
a, b = (s[0], s[1])
N = len(s)
l = s[N-1]
for c in s:
if c not in (a, b):
if a == l:
if N%2 == 0:
print("First")
else:
print("Second")
else:
if N%2 == 0:
print("Second")
else:
print("First")
break
else:
print("Second") | s = eval(input())
N = len(s)
f, l = (s[0], s[N-1])
if f == l:
if N%2 == 0:
print("First")
else:
print("Second")
else:
if N%2 == 0:
print("Second")
else:
print("First") | 19 | 13 | 395 | 221 | s = eval(input())
a, b = (s[0], s[1])
N = len(s)
l = s[N - 1]
for c in s:
if c not in (a, b):
if a == l:
if N % 2 == 0:
print("First")
else:
print("Second")
else:
if N % 2 == 0:
print("Second")
else:
print("First")
break
else:
print("Second")
| s = eval(input())
N = len(s)
f, l = (s[0], s[N - 1])
if f == l:
if N % 2 == 0:
print("First")
else:
print("Second")
else:
if N % 2 == 0:
print("Second")
else:
print("First")
| false | 31.578947 | [
"-a, b = (s[0], s[1])",
"-l = s[N - 1]",
"-for c in s:",
"- if c not in (a, b):",
"- if a == l:",
"- if N % 2 == 0:",
"- print(\"First\")",
"- else:",
"- print(\"Second\")",
"- else:",
"- if N % 2 == 0:",
"- print(\"Second\")",
"- else:",
"- print(\"First\")",
"- break",
"+f, l = (s[0], s[N - 1])",
"+if f == l:",
"+ if N % 2 == 0:",
"+ print(\"First\")",
"+ else:",
"+ print(\"Second\")",
"- print(\"Second\")",
"+ if N % 2 == 0:",
"+ print(\"Second\")",
"+ else:",
"+ print(\"First\")"
]
| false | 0.044747 | 0.044415 | 1.007482 | [
"s315516595",
"s161562720"
]
|
u809819902 | p03059 | python | s104547340 | s815623259 | 29 | 26 | 9,104 | 9,152 | Accepted | Accepted | 10.34 | a,b,t = list(map(int,input().split()))
s = t + 0.5
print((int((s // a) * b))) | a,b,t=list(map(int,input().split()))
t+=0.5
print((int(b*(t//a)))) | 3 | 3 | 71 | 60 | a, b, t = list(map(int, input().split()))
s = t + 0.5
print((int((s // a) * b)))
| a, b, t = list(map(int, input().split()))
t += 0.5
print((int(b * (t // a))))
| false | 0 | [
"-s = t + 0.5",
"-print((int((s // a) * b)))",
"+t += 0.5",
"+print((int(b * (t // a))))"
]
| false | 0.041969 | 0.048468 | 0.865913 | [
"s104547340",
"s815623259"
]
|
u887207211 | p03307 | python | s249618205 | s184852002 | 21 | 19 | 3,316 | 3,064 | Accepted | Accepted | 9.52 | N = int(eval(input()))
if(N%2 == 0):
print(N)
else:
print((N*2)) | N = int(eval(input()))
def gcd(m, n):
while n:
m, n = n, m%n
return m
def lcm(m, n):
return int((m * n) / gcd(m, n))
print((lcm(N,2))) | 5 | 11 | 64 | 149 | N = int(eval(input()))
if N % 2 == 0:
print(N)
else:
print((N * 2))
| N = int(eval(input()))
def gcd(m, n):
while n:
m, n = n, m % n
return m
def lcm(m, n):
return int((m * n) / gcd(m, n))
print((lcm(N, 2)))
| false | 54.545455 | [
"-if N % 2 == 0:",
"- print(N)",
"-else:",
"- print((N * 2))",
"+",
"+",
"+def gcd(m, n):",
"+ while n:",
"+ m, n = n, m % n",
"+ return m",
"+",
"+",
"+def lcm(m, n):",
"+ return int((m * n) / gcd(m, n))",
"+",
"+",
"+print((lcm(N, 2)))"
]
| false | 0.039457 | 0.051334 | 0.768622 | [
"s249618205",
"s184852002"
]
|
u463655976 | p03265 | python | s631319004 | s961380002 | 149 | 17 | 12,504 | 3,060 | Accepted | Accepted | 88.59 | import numpy as np
p = list(map(int, input().split()))
s, d = list(map(lambda x, y: np.array([x, y]), p[::2], p[1::2]))
ans = ""
for _ in range(2):
v = d - s
s = d
d = s + v.dot([[0,1], [-1,0]])
ans += " " + " ".join(map(str, d))
print((ans[1:]))
| p = list(map(int, input().split()))
s, d = list(map(lambda x, y: x + y * 1j, p[::2], p[1::2]))
ans = ""
for _ in range(2):
v = d - s
s = d
d = s + v * 1j
ans += " {:.0f} {:.0f}".format(d.real, d.imag)
print((ans[1:]))
| 11 | 10 | 264 | 234 | import numpy as np
p = list(map(int, input().split()))
s, d = list(map(lambda x, y: np.array([x, y]), p[::2], p[1::2]))
ans = ""
for _ in range(2):
v = d - s
s = d
d = s + v.dot([[0, 1], [-1, 0]])
ans += " " + " ".join(map(str, d))
print((ans[1:]))
| p = list(map(int, input().split()))
s, d = list(map(lambda x, y: x + y * 1j, p[::2], p[1::2]))
ans = ""
for _ in range(2):
v = d - s
s = d
d = s + v * 1j
ans += " {:.0f} {:.0f}".format(d.real, d.imag)
print((ans[1:]))
| false | 9.090909 | [
"-import numpy as np",
"-",
"-s, d = list(map(lambda x, y: np.array([x, y]), p[::2], p[1::2]))",
"+s, d = list(map(lambda x, y: x + y * 1j, p[::2], p[1::2]))",
"- d = s + v.dot([[0, 1], [-1, 0]])",
"- ans += \" \" + \" \".join(map(str, d))",
"+ d = s + v * 1j",
"+ ans += \" {:.0f} {:.0f}\".format(d.real, d.imag)"
]
| false | 0.241077 | 0.037837 | 6.371483 | [
"s631319004",
"s961380002"
]
|
u046187684 | p02838 | python | s995742851 | s470982049 | 911 | 303 | 72,412 | 53,464 | Accepted | Accepted | 66.74 | def solve(string):
n, *a = list(map(int, string.split()))
a = ("{:060b}".format(_a) for _a in a)
m, ans = 10**9 + 7, 0
for c in zip(*a):
s = c.count("1")
ans <<= 1
ans += s * (n - s)
ans %= m
return str(ans)
if __name__ == '__main__':
import sys
print((solve(sys.stdin.read().strip())))
| """
def solve(string):
n, *a = map(int, string.split())
a = ("{:060b}".format(_a) for _a in a)
m, ans = 10**9 + 7, 0
for s in map(lambda x: x.count("1"), zip(*a)):
ans <<= 1
ans += s * (n - s)
ans %= m
return str(ans)
if __name__ == '__main__':
import sys
print(solve(sys.stdin.read().strip()))
"""
import numpy as np
def solve(string):
n, *a = list(map(int, string.split()))
# a = ["{:060b}".format(_a) for _a in a]
a = np.asarray(a, dtype=np.int64)
m = 10**9 + 7
ans = 0
for i in range(60):
s = int((a & 1).sum())
a >>= 1
# ans += s * (n - s) * pow(2, 59 - i, m)
ans = (ans + s * (n - s) * (1 << i)) % m
return str(ans)
if __name__ == '__main__':
import sys
print((solve(sys.stdin.read().strip())))
| 15 | 36 | 355 | 854 | def solve(string):
n, *a = list(map(int, string.split()))
a = ("{:060b}".format(_a) for _a in a)
m, ans = 10**9 + 7, 0
for c in zip(*a):
s = c.count("1")
ans <<= 1
ans += s * (n - s)
ans %= m
return str(ans)
if __name__ == "__main__":
import sys
print((solve(sys.stdin.read().strip())))
| """
def solve(string):
n, *a = map(int, string.split())
a = ("{:060b}".format(_a) for _a in a)
m, ans = 10**9 + 7, 0
for s in map(lambda x: x.count("1"), zip(*a)):
ans <<= 1
ans += s * (n - s)
ans %= m
return str(ans)
if __name__ == '__main__':
import sys
print(solve(sys.stdin.read().strip()))
"""
import numpy as np
def solve(string):
n, *a = list(map(int, string.split()))
# a = ["{:060b}".format(_a) for _a in a]
a = np.asarray(a, dtype=np.int64)
m = 10**9 + 7
ans = 0
for i in range(60):
s = int((a & 1).sum())
a >>= 1
# ans += s * (n - s) * pow(2, 59 - i, m)
ans = (ans + s * (n - s) * (1 << i)) % m
return str(ans)
if __name__ == "__main__":
import sys
print((solve(sys.stdin.read().strip())))
| false | 58.333333 | [
"+\"\"\"",
"- n, *a = list(map(int, string.split()))",
"+ n, *a = map(int, string.split())",
"- for c in zip(*a):",
"- s = c.count(\"1\")",
"+ for s in map(lambda x: x.count(\"1\"), zip(*a)):",
"+ return str(ans)",
"+if __name__ == '__main__':",
"+ import sys",
"+ print(solve(sys.stdin.read().strip()))",
"+\"\"\"",
"+import numpy as np",
"+",
"+",
"+def solve(string):",
"+ n, *a = list(map(int, string.split()))",
"+ # a = [\"{:060b}\".format(_a) for _a in a]",
"+ a = np.asarray(a, dtype=np.int64)",
"+ m = 10**9 + 7",
"+ ans = 0",
"+ for i in range(60):",
"+ s = int((a & 1).sum())",
"+ a >>= 1",
"+ # ans += s * (n - s) * pow(2, 59 - i, m)",
"+ ans = (ans + s * (n - s) * (1 << i)) % m"
]
| false | 0.036788 | 0.452061 | 0.081378 | [
"s995742851",
"s470982049"
]
|
u204842730 | p02947 | python | s979558777 | s734189260 | 556 | 514 | 30,580 | 30,580 | Accepted | Accepted | 7.55 | import collections
n = int(eval(input()))
s = [[0 for j in range(10)] for i in range(n)]
for i in range(n):
t = eval(input())
s[i] = "".join(sorted(t))
s.sort()
ans = 0
c = collections.Counter(s)
for i in set(s):
n = c[i]
ans += n * (n-1) // 2
print(ans) | import collections
n = int(eval(input()))
s = [[0 for j in range(10)] for i in range(n)]
for i in range(n):
t = eval(input())
s[i] = "".join(sorted(t))
ans = 0
c = collections.Counter(s)
for i in set(s):
n = c[i]
ans += n * (n-1) // 2
print(ans) | 14 | 13 | 272 | 262 | import collections
n = int(eval(input()))
s = [[0 for j in range(10)] for i in range(n)]
for i in range(n):
t = eval(input())
s[i] = "".join(sorted(t))
s.sort()
ans = 0
c = collections.Counter(s)
for i in set(s):
n = c[i]
ans += n * (n - 1) // 2
print(ans)
| import collections
n = int(eval(input()))
s = [[0 for j in range(10)] for i in range(n)]
for i in range(n):
t = eval(input())
s[i] = "".join(sorted(t))
ans = 0
c = collections.Counter(s)
for i in set(s):
n = c[i]
ans += n * (n - 1) // 2
print(ans)
| false | 7.142857 | [
"-s.sort()"
]
| false | 0.039651 | 0.040268 | 0.984672 | [
"s979558777",
"s734189260"
]
|
u600402037 | p03017 | python | s668413046 | s172876929 | 72 | 58 | 3,572 | 3,572 | Accepted | Accepted | 19.44 | n, a, b, c, d = list(map(int, input().split()))
s = eval(input())
if d > c:
for i in range(a, d-1):
if s[i-1] == s[i] == "#":
print("No")
break
else:
print("Yes")
else:
for i in range(a, c):
if s[i-1] == s[i] == "#":
print("No")
break
else:
for j in range(b-1, d):
if s[j-1] == s[j] == s[j+1] == ".":
print("Yes")
break
else:
print("No") | N ,A ,B ,C ,D = list(map(int,input().split()))
S = eval(input())
def judgeArrive(S, x, y):
flag = "Yes"
for i in range(x-1 ,y-2):
if S[i] == S[i+1] == "#":
flag = "No"
return flag
def judgeJumpOver(S, x , y):
flag = "No"
for i in range(x-1 ,y):
if S[i-1] == S[i] == S[i+1] == ".":
flag = "Yes"
break
return flag
result = "Yes"
if(C > D):
result = judgeJumpOver(S, B, D)
if(result == "Yes"):
result = judgeArrive(S, B, D)
if(result == "Yes"):
result = judgeArrive(S, A, C)
print(result) | 21 | 27 | 511 | 561 | n, a, b, c, d = list(map(int, input().split()))
s = eval(input())
if d > c:
for i in range(a, d - 1):
if s[i - 1] == s[i] == "#":
print("No")
break
else:
print("Yes")
else:
for i in range(a, c):
if s[i - 1] == s[i] == "#":
print("No")
break
else:
for j in range(b - 1, d):
if s[j - 1] == s[j] == s[j + 1] == ".":
print("Yes")
break
else:
print("No")
| N, A, B, C, D = list(map(int, input().split()))
S = eval(input())
def judgeArrive(S, x, y):
flag = "Yes"
for i in range(x - 1, y - 2):
if S[i] == S[i + 1] == "#":
flag = "No"
return flag
def judgeJumpOver(S, x, y):
flag = "No"
for i in range(x - 1, y):
if S[i - 1] == S[i] == S[i + 1] == ".":
flag = "Yes"
break
return flag
result = "Yes"
if C > D:
result = judgeJumpOver(S, B, D)
if result == "Yes":
result = judgeArrive(S, B, D)
if result == "Yes":
result = judgeArrive(S, A, C)
print(result)
| false | 22.222222 | [
"-n, a, b, c, d = list(map(int, input().split()))",
"-s = eval(input())",
"-if d > c:",
"- for i in range(a, d - 1):",
"- if s[i - 1] == s[i] == \"#\":",
"- print(\"No\")",
"+N, A, B, C, D = list(map(int, input().split()))",
"+S = eval(input())",
"+",
"+",
"+def judgeArrive(S, x, y):",
"+ flag = \"Yes\"",
"+ for i in range(x - 1, y - 2):",
"+ if S[i] == S[i + 1] == \"#\":",
"+ flag = \"No\"",
"+ return flag",
"+",
"+",
"+def judgeJumpOver(S, x, y):",
"+ flag = \"No\"",
"+ for i in range(x - 1, y):",
"+ if S[i - 1] == S[i] == S[i + 1] == \".\":",
"+ flag = \"Yes\"",
"- else:",
"- print(\"Yes\")",
"-else:",
"- for i in range(a, c):",
"- if s[i - 1] == s[i] == \"#\":",
"- print(\"No\")",
"- break",
"- else:",
"- for j in range(b - 1, d):",
"- if s[j - 1] == s[j] == s[j + 1] == \".\":",
"- print(\"Yes\")",
"- break",
"- else:",
"- print(\"No\")",
"+ return flag",
"+",
"+",
"+result = \"Yes\"",
"+if C > D:",
"+ result = judgeJumpOver(S, B, D)",
"+if result == \"Yes\":",
"+ result = judgeArrive(S, B, D)",
"+if result == \"Yes\":",
"+ result = judgeArrive(S, A, C)",
"+print(result)"
]
| false | 0.083935 | 0.03763 | 2.230538 | [
"s668413046",
"s172876929"
]
|
u644516473 | p02787 | python | s601360481 | s477393725 | 785 | 640 | 78,172 | 65,500 | Accepted | Accepted | 18.47 | import sys
def resolve():
H, N = list(map(int, sys.stdin.readline().split()))
m = list(map(int, sys.stdin.read().split()))
AB = list(zip(m, m))
INF = 10**20
dp = [INF]*(H+10**4)
dp[0] = 0
for a, b in AB:
for j in range(H+10**4):
dp[j] = min(dp[j], dp[j-a] + b if j-a >= 0 else INF)
return min(dp[H:])
if __name__ == '__main__':
print((resolve()))
| import sys
H, N = list(map(int, sys.stdin.readline().split()))
m = list(map(int, sys.stdin.read().split()))
AB = list(zip(m, m))
INF = 10**20
dp = [INF]*(H+10**4)
dp[0] = 0
for a, b in AB:
for j in range(H+10**4):
dp[j] = min(dp[j], dp[j-a] + b if j-a >= 0 else INF)
print((min(dp[H:])))
| 18 | 11 | 404 | 290 | import sys
def resolve():
H, N = list(map(int, sys.stdin.readline().split()))
m = list(map(int, sys.stdin.read().split()))
AB = list(zip(m, m))
INF = 10**20
dp = [INF] * (H + 10**4)
dp[0] = 0
for a, b in AB:
for j in range(H + 10**4):
dp[j] = min(dp[j], dp[j - a] + b if j - a >= 0 else INF)
return min(dp[H:])
if __name__ == "__main__":
print((resolve()))
| import sys
H, N = list(map(int, sys.stdin.readline().split()))
m = list(map(int, sys.stdin.read().split()))
AB = list(zip(m, m))
INF = 10**20
dp = [INF] * (H + 10**4)
dp[0] = 0
for a, b in AB:
for j in range(H + 10**4):
dp[j] = min(dp[j], dp[j - a] + b if j - a >= 0 else INF)
print((min(dp[H:])))
| false | 38.888889 | [
"-",
"-def resolve():",
"- H, N = list(map(int, sys.stdin.readline().split()))",
"- m = list(map(int, sys.stdin.read().split()))",
"- AB = list(zip(m, m))",
"- INF = 10**20",
"- dp = [INF] * (H + 10**4)",
"- dp[0] = 0",
"- for a, b in AB:",
"- for j in range(H + 10**4):",
"- dp[j] = min(dp[j], dp[j - a] + b if j - a >= 0 else INF)",
"- return min(dp[H:])",
"-",
"-",
"-if __name__ == \"__main__\":",
"- print((resolve()))",
"+H, N = list(map(int, sys.stdin.readline().split()))",
"+m = list(map(int, sys.stdin.read().split()))",
"+AB = list(zip(m, m))",
"+INF = 10**20",
"+dp = [INF] * (H + 10**4)",
"+dp[0] = 0",
"+for a, b in AB:",
"+ for j in range(H + 10**4):",
"+ dp[j] = min(dp[j], dp[j - a] + b if j - a >= 0 else INF)",
"+print((min(dp[H:])))"
]
| false | 0.219042 | 0.456134 | 0.480213 | [
"s601360481",
"s477393725"
]
|
u670180528 | p04015 | python | s280078835 | s608088283 | 28 | 25 | 3,188 | 3,188 | Accepted | Accepted | 10.71 | n,a,*X=list(map(int,open(0).read().split()))
y=[a-x for x in X]
dp={0:1}
for i in y:
for k,v in set(dp.items()):
dp[i+k]=dp.get(i+k,0)+v
print((dp[0]-1)) | n,a=list(map(int,input().split()))
y=[a-int(x) for x in input().split()]
dp={0:1}
for i in y:
for k,v in list(dp.items()):
dp[i+k]=dp.get(i+k,0)+v
print((dp[0]-1)) | 7 | 7 | 154 | 164 | n, a, *X = list(map(int, open(0).read().split()))
y = [a - x for x in X]
dp = {0: 1}
for i in y:
for k, v in set(dp.items()):
dp[i + k] = dp.get(i + k, 0) + v
print((dp[0] - 1))
| n, a = list(map(int, input().split()))
y = [a - int(x) for x in input().split()]
dp = {0: 1}
for i in y:
for k, v in list(dp.items()):
dp[i + k] = dp.get(i + k, 0) + v
print((dp[0] - 1))
| false | 0 | [
"-n, a, *X = list(map(int, open(0).read().split()))",
"-y = [a - x for x in X]",
"+n, a = list(map(int, input().split()))",
"+y = [a - int(x) for x in input().split()]",
"- for k, v in set(dp.items()):",
"+ for k, v in list(dp.items()):"
]
| false | 0.119501 | 0.046151 | 2.589322 | [
"s280078835",
"s608088283"
]
|
u599114793 | p03107 | python | s209413610 | s480642761 | 42 | 37 | 3,188 | 3,956 | Accepted | Accepted | 11.9 | s = eval(input())
ans = 0
for i in range(len(s)):
if s[i] == "0":
ans -= 1
else:
ans += 1
print((len(s) - abs(ans)))
| s = list(eval(input()))
cnt = 0
for i in range(len(s)):
if s[i] == "0":
cnt += 1
print((min(cnt, len(s)-cnt)*2))
| 8 | 6 | 140 | 122 | s = eval(input())
ans = 0
for i in range(len(s)):
if s[i] == "0":
ans -= 1
else:
ans += 1
print((len(s) - abs(ans)))
| s = list(eval(input()))
cnt = 0
for i in range(len(s)):
if s[i] == "0":
cnt += 1
print((min(cnt, len(s) - cnt) * 2))
| false | 25 | [
"-s = eval(input())",
"-ans = 0",
"+s = list(eval(input()))",
"+cnt = 0",
"- ans -= 1",
"- else:",
"- ans += 1",
"-print((len(s) - abs(ans)))",
"+ cnt += 1",
"+print((min(cnt, len(s) - cnt) * 2))"
]
| false | 0.046615 | 0.038091 | 1.223772 | [
"s209413610",
"s480642761"
]
|
u525065967 | p02642 | python | s164794170 | s756038144 | 471 | 392 | 32,248 | 32,240 | Accepted | Accepted | 16.77 | n = int(eval(input()))
A = [*list(map(int, input().split()))]
mx = max(A)
c = [0]*(mx+1)
for a in A:
for i in range(a, mx+1, a): c[i] += 1
ans = 0
for a in A:
if c[a] == 1: ans += 1
print(ans)
| n = int(eval(input()))
A = [*list(map(int, input().split()))]
mx = max(A)
c = [0]*(mx+1)
for a in A:
if c[a]: c[a] = 2; continue
for i in range(a, mx+1, a): c[i] += 1
ans = 0
for a in A:
if c[a] == 1: ans += 1
print(ans)
| 10 | 11 | 198 | 231 | n = int(eval(input()))
A = [*list(map(int, input().split()))]
mx = max(A)
c = [0] * (mx + 1)
for a in A:
for i in range(a, mx + 1, a):
c[i] += 1
ans = 0
for a in A:
if c[a] == 1:
ans += 1
print(ans)
| n = int(eval(input()))
A = [*list(map(int, input().split()))]
mx = max(A)
c = [0] * (mx + 1)
for a in A:
if c[a]:
c[a] = 2
continue
for i in range(a, mx + 1, a):
c[i] += 1
ans = 0
for a in A:
if c[a] == 1:
ans += 1
print(ans)
| false | 9.090909 | [
"+ if c[a]:",
"+ c[a] = 2",
"+ continue"
]
| false | 0.073524 | 0.033904 | 2.168582 | [
"s164794170",
"s756038144"
]
|
u014333473 | p03317 | python | s939460286 | s296899672 | 49 | 24 | 20,520 | 10,080 | Accepted | Accepted | 51.02 | import math
n,k=list(map(int,input().split()));a=list(map(int,input().split()))
print(([math.ceil((n-k)/(k-1))+1,1][n==k])) | import math
n,k=list(map(int,input().split()));eval(input());print(([math.ceil((n-k)/(k-1))+1,1][n==k])) | 3 | 2 | 117 | 91 | import math
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
print(([math.ceil((n - k) / (k - 1)) + 1, 1][n == k]))
| import math
n, k = list(map(int, input().split()))
eval(input())
print(([math.ceil((n - k) / (k - 1)) + 1, 1][n == k]))
| false | 33.333333 | [
"-a = list(map(int, input().split()))",
"+eval(input())"
]
| false | 0.039249 | 0.035568 | 1.1035 | [
"s939460286",
"s296899672"
]
|
u673361376 | p03309 | python | s651003685 | s206588530 | 271 | 213 | 27,248 | 26,180 | Accepted | Accepted | 21.4 | import statistics
N = int(eval(input()))
A = [int(a)-(i+1) for i, a in enumerate(input().split())]
ans = float('inf')
medi = int(statistics.median(A))
for b in range(medi-1, medi+2):
ans = min(ans, sum([abs(A[i]-b) for i in range(N)]))
print(ans)
| def calc_sadness(b):
ans = 0
for a in A:
ans += abs(a - b)
return ans
N = int(eval(input()))
A = []
for idx, a in enumerate(map(int, input().split())):
A.append(a - idx - 1)
A.sort()
if N % 2 == 0:
b = [A[N // 2]]
else:
b = [A[N // 2 - 1], A[N // 2]]
print((min(list(map(calc_sadness, b)))))
| 8 | 19 | 250 | 332 | import statistics
N = int(eval(input()))
A = [int(a) - (i + 1) for i, a in enumerate(input().split())]
ans = float("inf")
medi = int(statistics.median(A))
for b in range(medi - 1, medi + 2):
ans = min(ans, sum([abs(A[i] - b) for i in range(N)]))
print(ans)
| def calc_sadness(b):
ans = 0
for a in A:
ans += abs(a - b)
return ans
N = int(eval(input()))
A = []
for idx, a in enumerate(map(int, input().split())):
A.append(a - idx - 1)
A.sort()
if N % 2 == 0:
b = [A[N // 2]]
else:
b = [A[N // 2 - 1], A[N // 2]]
print((min(list(map(calc_sadness, b)))))
| false | 57.894737 | [
"-import statistics",
"+def calc_sadness(b):",
"+ ans = 0",
"+ for a in A:",
"+ ans += abs(a - b)",
"+ return ans",
"+",
"-A = [int(a) - (i + 1) for i, a in enumerate(input().split())]",
"-ans = float(\"inf\")",
"-medi = int(statistics.median(A))",
"-for b in range(medi - 1, medi + 2):",
"- ans = min(ans, sum([abs(A[i] - b) for i in range(N)]))",
"-print(ans)",
"+A = []",
"+for idx, a in enumerate(map(int, input().split())):",
"+ A.append(a - idx - 1)",
"+A.sort()",
"+if N % 2 == 0:",
"+ b = [A[N // 2]]",
"+else:",
"+ b = [A[N // 2 - 1], A[N // 2]]",
"+print((min(list(map(calc_sadness, b)))))"
]
| false | 0.119078 | 0.037368 | 3.186649 | [
"s651003685",
"s206588530"
]
|
u697386253 | p02702 | python | s078084008 | s666970096 | 117 | 106 | 9,356 | 9,196 | Accepted | Accepted | 9.4 | s=eval(input())
s=s[::-1]
n=len(s)
count=[0]*2019
count[0]=1
num,d=0,1
for i in s:
num+=int(i)*d
num%=2019
d*=10
d%=2019
count[num]+=1
ans=0
for i in count:
ans+=i*(i-1)//2
print(ans)
| s = eval(input())
s = s[::-1]
n = len(s)
num = [0]*2019
num[0] = 1
number = 0
d = 1
for i in s:
number += int(i)*d
num[number%2019] += 1
d *= 10
d %= 2019
ans = 0
for i in num:
ans += i*(i-1)//2
print(ans) | 20 | 21 | 215 | 244 | s = eval(input())
s = s[::-1]
n = len(s)
count = [0] * 2019
count[0] = 1
num, d = 0, 1
for i in s:
num += int(i) * d
num %= 2019
d *= 10
d %= 2019
count[num] += 1
ans = 0
for i in count:
ans += i * (i - 1) // 2
print(ans)
| s = eval(input())
s = s[::-1]
n = len(s)
num = [0] * 2019
num[0] = 1
number = 0
d = 1
for i in s:
number += int(i) * d
num[number % 2019] += 1
d *= 10
d %= 2019
ans = 0
for i in num:
ans += i * (i - 1) // 2
print(ans)
| false | 4.761905 | [
"-count = [0] * 2019",
"-count[0] = 1",
"-num, d = 0, 1",
"+num = [0] * 2019",
"+num[0] = 1",
"+number = 0",
"+d = 1",
"- num += int(i) * d",
"- num %= 2019",
"+ number += int(i) * d",
"+ num[number % 2019] += 1",
"- count[num] += 1",
"-for i in count:",
"+for i in num:"
]
| false | 0.038914 | 0.101527 | 0.383289 | [
"s078084008",
"s666970096"
]
|
u535803878 | p03364 | python | s184735046 | s796288382 | 633 | 580 | 69,024 | 74,128 | Accepted | Accepted | 8.37 | import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")
n = int(eval(input()))
s = [None]*n
for i in range(n):
s[i] = eval(input())
def sub(i):
# res = True
# for j in range(n):
# if not all(s[(i+j)%n][(j+k)%n]==s[(i+j+k)%n][j] for k in range(n)):
# res = False
# break
res = all(all(s[(i+j)%n][(j+k)%n]==s[(i+j+k)%n][j] for k in range(n)) for j in range(n))
return res
ans = 0
for i in range(n):
if sub(i):
ans += n
print(ans) | import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")
n = int(eval(input()))
s = [None]*n
for i in range(n):
s[i] = eval(input())
ans = n * sum(all(all(s[(i+j)%n][(j+k)%n]==s[(i+j+k)%n][j] for k in range(n)) for j in range(n)) for i in range(n))
print(ans) | 24 | 13 | 594 | 354 | import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x + "\n")
n = int(eval(input()))
s = [None] * n
for i in range(n):
s[i] = eval(input())
def sub(i):
# res = True
# for j in range(n):
# if not all(s[(i+j)%n][(j+k)%n]==s[(i+j+k)%n][j] for k in range(n)):
# res = False
# break
res = all(
all(s[(i + j) % n][(j + k) % n] == s[(i + j + k) % n][j] for k in range(n))
for j in range(n)
)
return res
ans = 0
for i in range(n):
if sub(i):
ans += n
print(ans)
| import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x + "\n")
n = int(eval(input()))
s = [None] * n
for i in range(n):
s[i] = eval(input())
ans = n * sum(
all(
all(s[(i + j) % n][(j + k) % n] == s[(i + j + k) % n][j] for k in range(n))
for j in range(n)
)
for i in range(n)
)
print(ans)
| false | 45.833333 | [
"-",
"-",
"-def sub(i):",
"- # res = True",
"- # for j in range(n):",
"- # if not all(s[(i+j)%n][(j+k)%n]==s[(i+j+k)%n][j] for k in range(n)):",
"- # res = False",
"- # break",
"- res = all(",
"+ans = n * sum(",
"+ all(",
"- return res",
"-",
"-",
"-ans = 0",
"-for i in range(n):",
"- if sub(i):",
"- ans += n",
"+ for i in range(n)",
"+)"
]
| false | 0.039926 | 0.040563 | 0.984284 | [
"s184735046",
"s796288382"
]
|
u014333473 | p03208 | python | s982905907 | s200190901 | 228 | 172 | 7,384 | 16,908 | Accepted | Accepted | 24.56 | N, K = list(map(int, input().split()))
h = [int(eval(input())) for _ in range(N)]
h.sort()
diff = max(h)
for i in range(0, len(h)-K+1):
if diff > h[i+K-1]-h[i]:
diff = h[i+K-1]-h[i]
print(diff) | n,k=list(map(int,input().split()));h=sorted([int(eval(input())) for _ in range(n)])
print((min([h[i+k-1]-h[i] for i in range(n-k+1)]))) | 8 | 2 | 194 | 122 | N, K = list(map(int, input().split()))
h = [int(eval(input())) for _ in range(N)]
h.sort()
diff = max(h)
for i in range(0, len(h) - K + 1):
if diff > h[i + K - 1] - h[i]:
diff = h[i + K - 1] - h[i]
print(diff)
| n, k = list(map(int, input().split()))
h = sorted([int(eval(input())) for _ in range(n)])
print((min([h[i + k - 1] - h[i] for i in range(n - k + 1)])))
| false | 75 | [
"-N, K = list(map(int, input().split()))",
"-h = [int(eval(input())) for _ in range(N)]",
"-h.sort()",
"-diff = max(h)",
"-for i in range(0, len(h) - K + 1):",
"- if diff > h[i + K - 1] - h[i]:",
"- diff = h[i + K - 1] - h[i]",
"-print(diff)",
"+n, k = list(map(int, input().split()))",
"+h = sorted([int(eval(input())) for _ in range(n)])",
"+print((min([h[i + k - 1] - h[i] for i in range(n - k + 1)])))"
]
| false | 0.042597 | 0.038264 | 1.113237 | [
"s982905907",
"s200190901"
]
|
u654470292 | p02574 | python | s944850275 | s670789305 | 1,302 | 851 | 250,344 | 241,208 | Accepted | Accepted | 34.64 | import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
return sys.stdin.readline()[:-1]
def ruiseki(lst):
return [0]+list(accumulate(lst))
def celi(a,b):
return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]
n=int(eval(input()))
a=list(map(int,input().split()))
pc="pairwise coprime"
sc="setwise coprime"
nc="not coprime"
a.sort()
tmp=a[0]
for i in range(n):
tmp=math.gcd(tmp,a[i])
if tmp!=1:
print(nc)
exit()
dic=defaultdict(int)
for i in range(n):dic[a[i]]+=1
ans=0
for i in range(a[-1]):
now=i+1
cnt=0
# print(i)
while now<=a[-1]:
cnt+=dic[now]
now+=i+1
if cnt>1:
ans=i+1
if ans!=1:
print(sc)
else:
print(pc)
# print(ans) | import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
return sys.stdin.readline()[:-1]
def ruiseki(lst):
return [0]+list(accumulate(lst))
def celi(a,b):
return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]
n=int(eval(input()))
a=list(map(int,input().split()))
pc="pairwise coprime"
sc="setwise coprime"
nc="not coprime"
a.sort()
tmp=a[0]
for i in range(n):
tmp=math.gcd(tmp,a[i])
if tmp!=1:
print(nc)
exit()
dic={}
for i in range(n):
if a[i] in dic:
dic[a[i]]+=1
else:
dic[a[i]]=1
ans=0
for i in range(a[-1]):
now=i+1
cnt=0
# print(i)
while now<=a[-1]:
if now in dic:
cnt+=dic[now]
now+=i+1
if cnt>1:
ans=i+1
if ans!=1:
print(sc)
else:
print(pc)
# print(ans) | 48 | 53 | 959 | 1,036 | import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
return sys.stdin.readline()[:-1]
def ruiseki(lst):
return [0] + list(accumulate(lst))
def celi(a, b):
return -(-a // b)
sys.setrecursionlimit(5000000)
mod = pow(10, 9) + 7
al = [chr(ord("a") + i) for i in range(26)]
direction = [[1, 0], [0, 1], [-1, 0], [0, -1]]
n = int(eval(input()))
a = list(map(int, input().split()))
pc = "pairwise coprime"
sc = "setwise coprime"
nc = "not coprime"
a.sort()
tmp = a[0]
for i in range(n):
tmp = math.gcd(tmp, a[i])
if tmp != 1:
print(nc)
exit()
dic = defaultdict(int)
for i in range(n):
dic[a[i]] += 1
ans = 0
for i in range(a[-1]):
now = i + 1
cnt = 0
# print(i)
while now <= a[-1]:
cnt += dic[now]
now += i + 1
if cnt > 1:
ans = i + 1
if ans != 1:
print(sc)
else:
print(pc)
# print(ans)
| import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
return sys.stdin.readline()[:-1]
def ruiseki(lst):
return [0] + list(accumulate(lst))
def celi(a, b):
return -(-a // b)
sys.setrecursionlimit(5000000)
mod = pow(10, 9) + 7
al = [chr(ord("a") + i) for i in range(26)]
direction = [[1, 0], [0, 1], [-1, 0], [0, -1]]
n = int(eval(input()))
a = list(map(int, input().split()))
pc = "pairwise coprime"
sc = "setwise coprime"
nc = "not coprime"
a.sort()
tmp = a[0]
for i in range(n):
tmp = math.gcd(tmp, a[i])
if tmp != 1:
print(nc)
exit()
dic = {}
for i in range(n):
if a[i] in dic:
dic[a[i]] += 1
else:
dic[a[i]] = 1
ans = 0
for i in range(a[-1]):
now = i + 1
cnt = 0
# print(i)
while now <= a[-1]:
if now in dic:
cnt += dic[now]
now += i + 1
if cnt > 1:
ans = i + 1
if ans != 1:
print(sc)
else:
print(pc)
# print(ans)
| false | 9.433962 | [
"-dic = defaultdict(int)",
"+dic = {}",
"- dic[a[i]] += 1",
"+ if a[i] in dic:",
"+ dic[a[i]] += 1",
"+ else:",
"+ dic[a[i]] = 1",
"- cnt += dic[now]",
"+ if now in dic:",
"+ cnt += dic[now]"
]
| false | 0.063118 | 0.038116 | 1.65597 | [
"s944850275",
"s670789305"
]
|
u190405389 | p03760 | python | s381816469 | s454513942 | 23 | 18 | 2,940 | 2,940 | Accepted | Accepted | 21.74 | o = eval(input())
e = eval(input())
ans = ''
for i in range(len(o) - 1):
ans += o[i] + e[i]
ans += o[-1]
if len(o) == len(e):
ans += e[-1]
print(ans)
| o = list(eval(input()))
e = eval(input())
for i in range(len(e)):
o.insert(i*2+1, e[i])
print((''.join(o)))
| 14 | 7 | 164 | 106 | o = eval(input())
e = eval(input())
ans = ""
for i in range(len(o) - 1):
ans += o[i] + e[i]
ans += o[-1]
if len(o) == len(e):
ans += e[-1]
print(ans)
| o = list(eval(input()))
e = eval(input())
for i in range(len(e)):
o.insert(i * 2 + 1, e[i])
print(("".join(o)))
| false | 50 | [
"-o = eval(input())",
"+o = list(eval(input()))",
"-ans = \"\"",
"-for i in range(len(o) - 1):",
"- ans += o[i] + e[i]",
"-ans += o[-1]",
"-if len(o) == len(e):",
"- ans += e[-1]",
"-print(ans)",
"+for i in range(len(e)):",
"+ o.insert(i * 2 + 1, e[i])",
"+print((\"\".join(o)))"
]
| false | 0.042314 | 0.09943 | 0.425567 | [
"s381816469",
"s454513942"
]
|
u886766186 | p01751 | python | s418861952 | s591702772 | 50 | 30 | 7,732 | 7,660 | Accepted | Accepted | 40 | def solve(a, b, c):
l = 0; r = a;
t = 0
for i in range(80):
t = l // 60
p = 60*t + c
if l <= p <= r:
print(p)
exit()
l = r + b
r = l + a
print((-1))
a, b, c = list(map(int, input().split()))
solve(a,b,c) | a, b, c = list(map(int, input().split()))
l = 0; r = a;
for i in range(80):
t = l // 60
p = 60*t + c
if l <= p <= r:
print(p)
exit()
l = r + b
r = l + a
print((-1)) | 17 | 14 | 294 | 208 | def solve(a, b, c):
l = 0
r = a
t = 0
for i in range(80):
t = l // 60
p = 60 * t + c
if l <= p <= r:
print(p)
exit()
l = r + b
r = l + a
print((-1))
a, b, c = list(map(int, input().split()))
solve(a, b, c)
| a, b, c = list(map(int, input().split()))
l = 0
r = a
for i in range(80):
t = l // 60
p = 60 * t + c
if l <= p <= r:
print(p)
exit()
l = r + b
r = l + a
print((-1))
| false | 17.647059 | [
"-def solve(a, b, c):",
"- l = 0",
"- r = a",
"- t = 0",
"- for i in range(80):",
"- t = l // 60",
"- p = 60 * t + c",
"- if l <= p <= r:",
"- print(p)",
"- exit()",
"- l = r + b",
"- r = l + a",
"- print((-1))",
"-",
"-",
"-solve(a, b, c)",
"+l = 0",
"+r = a",
"+for i in range(80):",
"+ t = l // 60",
"+ p = 60 * t + c",
"+ if l <= p <= r:",
"+ print(p)",
"+ exit()",
"+ l = r + b",
"+ r = l + a",
"+print((-1))"
]
| false | 0.041335 | 0.041275 | 1.001458 | [
"s418861952",
"s591702772"
]
|
u316386814 | p03091 | python | s217209749 | s410369822 | 400 | 324 | 40,804 | 28,380 | Accepted | Accepted | 19 | import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return eval(input())
from collections import defaultdict, deque
def main():
N, M = LI()
edges = defaultdict(set)
for _ in range(M):
a, b = LI_()
edges[a].add(b)
edges[b].add(a)
quads = set()
sixes = 0
for i, e in list(edges.items()):
c = len(e)
if c % 2 == 1:
return False
if c >= 6:
sixes += 1
if c == 4:
quads.add(i)
if sixes > 0:
return True
if len(quads) > 2:
return True
if len(quads) < 2:
return False
s = quads.pop()
t = quads.pop()
for v0 in edges[s]:
q = deque([v0])
visited = {s, t}
while len(q) > 0:
v = q.pop()
for to in edges[v]:
if v != v0 and to == s:
return True
if to not in visited:
q.append(to)
visited.add(to)
return False
print(('Yes' if main() else 'No')) | import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return eval(input())
from collections import defaultdict
def main():
N, M = LI()
edges = defaultdict(list)
for _ in range(M):
a, b = LI_()
edges[a].append(b)
edges[b].append(a)
quads = []
large = 0
for i, e in list(edges.items()):
c = len(e)
if c % 2 == 1:
return 'No'
if c >= 6:
large += 1
if c == 4:
quads.append(i)
if large > 0:
return 'Yes'
if len(quads) > 2:
return 'Yes'
if len(quads) < 2:
return 'No'
for v in edges[quads[0]]:
visited = [0] * N
visited[quads[0]] = 1
while v != quads[1]:
visited[v] = 1
for to in edges[v]:
if visited[to] == 0:
v = to
break
if visited[v] == 1:
break
if v != quads[1]:
return 'Yes'
return 'No'
print((main()))
| 53 | 53 | 1,398 | 1,374 | import sys
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def LI_():
return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF():
return [float(x) for x in sys.stdin.readline().split()]
def LS():
return sys.stdin.readline().split()
def II():
return int(sys.stdin.readline())
def SI():
return eval(input())
from collections import defaultdict, deque
def main():
N, M = LI()
edges = defaultdict(set)
for _ in range(M):
a, b = LI_()
edges[a].add(b)
edges[b].add(a)
quads = set()
sixes = 0
for i, e in list(edges.items()):
c = len(e)
if c % 2 == 1:
return False
if c >= 6:
sixes += 1
if c == 4:
quads.add(i)
if sixes > 0:
return True
if len(quads) > 2:
return True
if len(quads) < 2:
return False
s = quads.pop()
t = quads.pop()
for v0 in edges[s]:
q = deque([v0])
visited = {s, t}
while len(q) > 0:
v = q.pop()
for to in edges[v]:
if v != v0 and to == s:
return True
if to not in visited:
q.append(to)
visited.add(to)
return False
print(("Yes" if main() else "No"))
| import sys
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def LI_():
return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF():
return [float(x) for x in sys.stdin.readline().split()]
def LS():
return sys.stdin.readline().split()
def II():
return int(sys.stdin.readline())
def SI():
return eval(input())
from collections import defaultdict
def main():
N, M = LI()
edges = defaultdict(list)
for _ in range(M):
a, b = LI_()
edges[a].append(b)
edges[b].append(a)
quads = []
large = 0
for i, e in list(edges.items()):
c = len(e)
if c % 2 == 1:
return "No"
if c >= 6:
large += 1
if c == 4:
quads.append(i)
if large > 0:
return "Yes"
if len(quads) > 2:
return "Yes"
if len(quads) < 2:
return "No"
for v in edges[quads[0]]:
visited = [0] * N
visited[quads[0]] = 1
while v != quads[1]:
visited[v] = 1
for to in edges[v]:
if visited[to] == 0:
v = to
break
if visited[v] == 1:
break
if v != quads[1]:
return "Yes"
return "No"
print((main()))
| false | 0 | [
"-from collections import defaultdict, deque",
"+from collections import defaultdict",
"- edges = defaultdict(set)",
"+ edges = defaultdict(list)",
"- edges[a].add(b)",
"- edges[b].add(a)",
"- quads = set()",
"- sixes = 0",
"+ edges[a].append(b)",
"+ edges[b].append(a)",
"+ quads = []",
"+ large = 0",
"- return False",
"+ return \"No\"",
"- sixes += 1",
"+ large += 1",
"- quads.add(i)",
"- if sixes > 0:",
"- return True",
"+ quads.append(i)",
"+ if large > 0:",
"+ return \"Yes\"",
"- return True",
"+ return \"Yes\"",
"- return False",
"- s = quads.pop()",
"- t = quads.pop()",
"- for v0 in edges[s]:",
"- q = deque([v0])",
"- visited = {s, t}",
"- while len(q) > 0:",
"- v = q.pop()",
"+ return \"No\"",
"+ for v in edges[quads[0]]:",
"+ visited = [0] * N",
"+ visited[quads[0]] = 1",
"+ while v != quads[1]:",
"+ visited[v] = 1",
"- if v != v0 and to == s:",
"- return True",
"- if to not in visited:",
"- q.append(to)",
"- visited.add(to)",
"- return False",
"+ if visited[to] == 0:",
"+ v = to",
"+ break",
"+ if visited[v] == 1:",
"+ break",
"+ if v != quads[1]:",
"+ return \"Yes\"",
"+ return \"No\"",
"-print((\"Yes\" if main() else \"No\"))",
"+print((main()))"
]
| false | 0.041784 | 0.041436 | 1.008401 | [
"s217209749",
"s410369822"
]
|
u755585099 | p03160 | python | s723031508 | s760325090 | 106 | 76 | 13,928 | 14,184 | Accepted | Accepted | 28.3 | n = int(eval(input()))
hs = list(map(int, input().split()))
a, b = 0, abs(hs[1] - hs[0])
for i in range(2, n):
d1 = a + abs(hs[i] - hs[i-2])
d2 = b + abs(hs[i] - hs[i-1])
a, b = b, d1 if d1 <= d2 else d2
print(b) | def main():
n = int(eval(input()))
hs = tuple(map(int, input().split()))
a, b = 0, abs(hs[1] - hs[0])
for i in range(2, n):
d1 = a + abs(hs[i] - hs[i-2])
d2 = b + abs(hs[i] - hs[i-1])
a, b = b, d1 if d1 <= d2 else d2
print(b)
if __name__ == "__main__":
main() | 11 | 15 | 225 | 295 | n = int(eval(input()))
hs = list(map(int, input().split()))
a, b = 0, abs(hs[1] - hs[0])
for i in range(2, n):
d1 = a + abs(hs[i] - hs[i - 2])
d2 = b + abs(hs[i] - hs[i - 1])
a, b = b, d1 if d1 <= d2 else d2
print(b)
| def main():
n = int(eval(input()))
hs = tuple(map(int, input().split()))
a, b = 0, abs(hs[1] - hs[0])
for i in range(2, n):
d1 = a + abs(hs[i] - hs[i - 2])
d2 = b + abs(hs[i] - hs[i - 1])
a, b = b, d1 if d1 <= d2 else d2
print(b)
if __name__ == "__main__":
main()
| false | 26.666667 | [
"-n = int(eval(input()))",
"-hs = list(map(int, input().split()))",
"-a, b = 0, abs(hs[1] - hs[0])",
"-for i in range(2, n):",
"- d1 = a + abs(hs[i] - hs[i - 2])",
"- d2 = b + abs(hs[i] - hs[i - 1])",
"- a, b = b, d1 if d1 <= d2 else d2",
"-print(b)",
"+def main():",
"+ n = int(eval(input()))",
"+ hs = tuple(map(int, input().split()))",
"+ a, b = 0, abs(hs[1] - hs[0])",
"+ for i in range(2, n):",
"+ d1 = a + abs(hs[i] - hs[i - 2])",
"+ d2 = b + abs(hs[i] - hs[i - 1])",
"+ a, b = b, d1 if d1 <= d2 else d2",
"+ print(b)",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
]
| false | 0.082162 | 0.048432 | 1.69643 | [
"s723031508",
"s760325090"
]
|
u836737505 | p02720 | python | s205415392 | s872084434 | 588 | 378 | 11,424 | 10,916 | Accepted | Accepted | 35.71 | z = int(eval(input()))
l = []
for i in range(1,10):
l.append(i)
for j in range(max(0,i-1),min(10,i+2)):
l.append(int(str(i)+str(j)))
for k in range(max(j-1,0),min(10,j+2)):
l.append(int(str(i)+str(j)+str(k)))
for m in range(max(k-1,0),min(10,k+2)):
l.append(int(str(i)+str(j)+str(k)+str(m)))
for n in range(max(m-1,0),min(10,m+2)):
l.append(int(str(i)+str(j)+str(k)+str(m)+str(n)))
for o in range(max(n-1,0),min(10,n+2)):
l.append(int(str(i)+str(j)+str(k)+str(m)+str(n)+str(o)))
for p in range(max(o-1,0),min(10,o+2)):
l.append(int(str(i)+str(j)+str(k)+str(m)+str(n)+str(o)+str(p)))
for q in range(max(p-1,0),min(10,p+2)):
l.append(int(str(i)+str(j)+str(k)+str(m)+str(n)+str(o)+str(p)+str(q)))
for r in range(max(q-1,0),min(10,q+2)):
l.append(int(str(i)+str(j)+str(k)+str(m)+str(n)+str(o)+str(p)+str(q)+str(r)))
for s in range(max(r-1,0),min(10,r+2)):
l.append(int(str(i)+str(j)+str(k)+str(m)+str(n)+str(o)+str(p)+str(q)+str(r)+str(s)))
l.sort()
print((l[z-1])) | from collections import deque
k = int(eval(input()))
s = deque([1,2,3,4,5,6,7,8,9])
for i in range(k):
c = s.popleft()
d = int(str(c)[-1])
for j in range(max(0,d-1),min(10,d+2)):
s.append(int(str(c)+str(j)))
print(c) | 25 | 9 | 1,378 | 238 | z = int(eval(input()))
l = []
for i in range(1, 10):
l.append(i)
for j in range(max(0, i - 1), min(10, i + 2)):
l.append(int(str(i) + str(j)))
for k in range(max(j - 1, 0), min(10, j + 2)):
l.append(int(str(i) + str(j) + str(k)))
for m in range(max(k - 1, 0), min(10, k + 2)):
l.append(int(str(i) + str(j) + str(k) + str(m)))
for n in range(max(m - 1, 0), min(10, m + 2)):
l.append(int(str(i) + str(j) + str(k) + str(m) + str(n)))
for o in range(max(n - 1, 0), min(10, n + 2)):
l.append(
int(str(i) + str(j) + str(k) + str(m) + str(n) + str(o))
)
for p in range(max(o - 1, 0), min(10, o + 2)):
l.append(
int(
str(i)
+ str(j)
+ str(k)
+ str(m)
+ str(n)
+ str(o)
+ str(p)
)
)
for q in range(max(p - 1, 0), min(10, p + 2)):
l.append(
int(
str(i)
+ str(j)
+ str(k)
+ str(m)
+ str(n)
+ str(o)
+ str(p)
+ str(q)
)
)
for r in range(max(q - 1, 0), min(10, q + 2)):
l.append(
int(
str(i)
+ str(j)
+ str(k)
+ str(m)
+ str(n)
+ str(o)
+ str(p)
+ str(q)
+ str(r)
)
)
for s in range(max(r - 1, 0), min(10, r + 2)):
l.append(
int(
str(i)
+ str(j)
+ str(k)
+ str(m)
+ str(n)
+ str(o)
+ str(p)
+ str(q)
+ str(r)
+ str(s)
)
)
l.sort()
print((l[z - 1]))
| from collections import deque
k = int(eval(input()))
s = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
for i in range(k):
c = s.popleft()
d = int(str(c)[-1])
for j in range(max(0, d - 1), min(10, d + 2)):
s.append(int(str(c) + str(j)))
print(c)
| false | 64 | [
"-z = int(eval(input()))",
"-l = []",
"-for i in range(1, 10):",
"- l.append(i)",
"- for j in range(max(0, i - 1), min(10, i + 2)):",
"- l.append(int(str(i) + str(j)))",
"- for k in range(max(j - 1, 0), min(10, j + 2)):",
"- l.append(int(str(i) + str(j) + str(k)))",
"- for m in range(max(k - 1, 0), min(10, k + 2)):",
"- l.append(int(str(i) + str(j) + str(k) + str(m)))",
"- for n in range(max(m - 1, 0), min(10, m + 2)):",
"- l.append(int(str(i) + str(j) + str(k) + str(m) + str(n)))",
"- for o in range(max(n - 1, 0), min(10, n + 2)):",
"- l.append(",
"- int(str(i) + str(j) + str(k) + str(m) + str(n) + str(o))",
"- )",
"- for p in range(max(o - 1, 0), min(10, o + 2)):",
"- l.append(",
"- int(",
"- str(i)",
"- + str(j)",
"- + str(k)",
"- + str(m)",
"- + str(n)",
"- + str(o)",
"- + str(p)",
"- )",
"- )",
"- for q in range(max(p - 1, 0), min(10, p + 2)):",
"- l.append(",
"- int(",
"- str(i)",
"- + str(j)",
"- + str(k)",
"- + str(m)",
"- + str(n)",
"- + str(o)",
"- + str(p)",
"- + str(q)",
"- )",
"- )",
"- for r in range(max(q - 1, 0), min(10, q + 2)):",
"- l.append(",
"- int(",
"- str(i)",
"- + str(j)",
"- + str(k)",
"- + str(m)",
"- + str(n)",
"- + str(o)",
"- + str(p)",
"- + str(q)",
"- + str(r)",
"- )",
"- )",
"- for s in range(max(r - 1, 0), min(10, r + 2)):",
"- l.append(",
"- int(",
"- str(i)",
"- + str(j)",
"- + str(k)",
"- + str(m)",
"- + str(n)",
"- + str(o)",
"- + str(p)",
"- + str(q)",
"- + str(r)",
"- + str(s)",
"- )",
"- )",
"-l.sort()",
"-print((l[z - 1]))",
"+from collections import deque",
"+",
"+k = int(eval(input()))",
"+s = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])",
"+for i in range(k):",
"+ c = s.popleft()",
"+ d = int(str(c)[-1])",
"+ for j in range(max(0, d - 1), min(10, d + 2)):",
"+ s.append(int(str(c) + str(j)))",
"+print(c)"
]
| false | 1.3134 | 0.107964 | 12.165144 | [
"s205415392",
"s872084434"
]
|
u589886885 | p02267 | python | s936448444 | s358598627 | 50 | 30 | 8,468 | 7,880 | Accepted | Accepted | 40 | import sys
n = int(sys.stdin.readline())
s = [int(x) for x in sys.stdin.readline().split()]
q = int(sys.stdin.readline())
t = [int(x) for x in sys.stdin.readline().split()]
cnt = 0
for i in t:
if i in s:
cnt += 1
print(cnt) | import sys
n = sys.stdin.readline()
s = sys.stdin.readline().split()
q = sys.stdin.readline()
t = sys.stdin.readline().split()
cnt = 0
for i in t:
if i in s:
cnt += 1
print(cnt) | 13 | 13 | 250 | 204 | import sys
n = int(sys.stdin.readline())
s = [int(x) for x in sys.stdin.readline().split()]
q = int(sys.stdin.readline())
t = [int(x) for x in sys.stdin.readline().split()]
cnt = 0
for i in t:
if i in s:
cnt += 1
print(cnt)
| import sys
n = sys.stdin.readline()
s = sys.stdin.readline().split()
q = sys.stdin.readline()
t = sys.stdin.readline().split()
cnt = 0
for i in t:
if i in s:
cnt += 1
print(cnt)
| false | 0 | [
"-n = int(sys.stdin.readline())",
"-s = [int(x) for x in sys.stdin.readline().split()]",
"-q = int(sys.stdin.readline())",
"-t = [int(x) for x in sys.stdin.readline().split()]",
"+n = sys.stdin.readline()",
"+s = sys.stdin.readline().split()",
"+q = sys.stdin.readline()",
"+t = sys.stdin.readline().split()"
]
| false | 0.04071 | 0.037796 | 1.077117 | [
"s936448444",
"s358598627"
]
|
u347600233 | p03011 | python | s597119974 | s813506375 | 31 | 27 | 9,084 | 9,096 | Accepted | Accepted | 12.9 | t = list(map(int, input().split()))
print((sum(t) - max(t))) | p, q, r = list(map(int, input().split()))
print((p + q + r - max(p, q, r))) | 2 | 2 | 59 | 68 | t = list(map(int, input().split()))
print((sum(t) - max(t)))
| p, q, r = list(map(int, input().split()))
print((p + q + r - max(p, q, r)))
| false | 0 | [
"-t = list(map(int, input().split()))",
"-print((sum(t) - max(t)))",
"+p, q, r = list(map(int, input().split()))",
"+print((p + q + r - max(p, q, r)))"
]
| false | 0.07268 | 0.083663 | 0.868723 | [
"s597119974",
"s813506375"
]
|
u241159583 | p02755 | python | s689346291 | s308308997 | 20 | 17 | 2,940 | 2,940 | Accepted | Accepted | 15 | a,b = list(map(int, input().split()))
ans = -1
for i in range(1, 10000):
if int(i*0.08)==a and int(i*0.1)==b:
ans = i
break
print(ans) | a,b = list(map(int, input().split()))
for i in range(1, 1001):
if int(i * 0.08) == a and int(i * 0.1) == b:
print(i)
exit()
print((-1)) | 8 | 7 | 146 | 144 | a, b = list(map(int, input().split()))
ans = -1
for i in range(1, 10000):
if int(i * 0.08) == a and int(i * 0.1) == b:
ans = i
break
print(ans)
| a, b = list(map(int, input().split()))
for i in range(1, 1001):
if int(i * 0.08) == a and int(i * 0.1) == b:
print(i)
exit()
print((-1))
| false | 12.5 | [
"-ans = -1",
"-for i in range(1, 10000):",
"+for i in range(1, 1001):",
"- ans = i",
"- break",
"-print(ans)",
"+ print(i)",
"+ exit()",
"+print((-1))"
]
| false | 0.046878 | 0.04523 | 1.036423 | [
"s689346291",
"s308308997"
]
|
u982896977 | p03162 | python | s189184251 | s714866349 | 697 | 560 | 80,344 | 34,672 | Accepted | Accepted | 19.66 | n = int(eval(input()))
A = []
B = []
C = []
for i in range(n):
a,b,c = list(map(int,input().split()))
A.append(a)
B.append(b)
C.append(c)
dp = [[0 for i in range(3)] for j in range(n)]
dp[0][0] = A[0]
dp[0][1] = B[0]
dp[0][2] = C[0]
for i in range(1,n):
dp[i][0] = max(dp[i-1][1],dp[i-1][2])+A[i]
dp[i][1] = max(dp[i-1][0],dp[i-1][2])+B[i]
dp[i][2] = max(dp[i-1][0],dp[i-1][1])+C[i]
print((max(dp[n-1][0],dp[n-1][1],dp[n-1][2]))) | n = int(eval(input()))
A = []
B = []
C = []
for _ in range(n):
a,b,c = list(map(int,input().split()))
A.append(a)
B.append(b)
C.append(c)
dp = [[0]*3 for i in range(n)]
dp[0][0] = A[0]
dp[0][1] = B[0]
dp[0][2] = C[0]
for i in range(1,n):
dp[i][0] = max(dp[i-1][1]+A[i],dp[i-1][2]+A[i])
dp[i][1] = max(dp[i-1][0]+B[i],dp[i-1][2]+B[i])
dp[i][2] = max(dp[i-1][0]+C[i],dp[i-1][1]+C[i])
print((max(dp[-1]))) | 22 | 18 | 472 | 433 | n = int(eval(input()))
A = []
B = []
C = []
for i in range(n):
a, b, c = list(map(int, input().split()))
A.append(a)
B.append(b)
C.append(c)
dp = [[0 for i in range(3)] for j in range(n)]
dp[0][0] = A[0]
dp[0][1] = B[0]
dp[0][2] = C[0]
for i in range(1, n):
dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + A[i]
dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + B[i]
dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + C[i]
print((max(dp[n - 1][0], dp[n - 1][1], dp[n - 1][2])))
| n = int(eval(input()))
A = []
B = []
C = []
for _ in range(n):
a, b, c = list(map(int, input().split()))
A.append(a)
B.append(b)
C.append(c)
dp = [[0] * 3 for i in range(n)]
dp[0][0] = A[0]
dp[0][1] = B[0]
dp[0][2] = C[0]
for i in range(1, n):
dp[i][0] = max(dp[i - 1][1] + A[i], dp[i - 1][2] + A[i])
dp[i][1] = max(dp[i - 1][0] + B[i], dp[i - 1][2] + B[i])
dp[i][2] = max(dp[i - 1][0] + C[i], dp[i - 1][1] + C[i])
print((max(dp[-1])))
| false | 18.181818 | [
"-for i in range(n):",
"+for _ in range(n):",
"-dp = [[0 for i in range(3)] for j in range(n)]",
"+dp = [[0] * 3 for i in range(n)]",
"- dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + A[i]",
"- dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + B[i]",
"- dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + C[i]",
"-print((max(dp[n - 1][0], dp[n - 1][1], dp[n - 1][2])))",
"+ dp[i][0] = max(dp[i - 1][1] + A[i], dp[i - 1][2] + A[i])",
"+ dp[i][1] = max(dp[i - 1][0] + B[i], dp[i - 1][2] + B[i])",
"+ dp[i][2] = max(dp[i - 1][0] + C[i], dp[i - 1][1] + C[i])",
"+print((max(dp[-1])))"
]
| false | 0.036982 | 0.040092 | 0.922438 | [
"s189184251",
"s714866349"
]
|
u734876600 | p02911 | python | s315427494 | s606616402 | 1,919 | 182 | 27,492 | 11,532 | Accepted | Accepted | 90.52 | import numpy as np
n,k,q = list(map(int, input().split()))
p = np.full(n, k, dtype=np.int)
first = 0
for i in range(q):
a = int(eval(input()))
p -= 1
p[a-1] += 1
for i in p:
if i <= 0:
print("No")
else:
print("Yes") | n,k,q = list(map(int, input().split()))
p = [k-q]*n
first = 0
for i in range(q):
a = int(eval(input()))
p[a-1]+=1
for i in p:
if i <= 0:
print("No")
else:
print("Yes") | 13 | 11 | 251 | 197 | import numpy as np
n, k, q = list(map(int, input().split()))
p = np.full(n, k, dtype=np.int)
first = 0
for i in range(q):
a = int(eval(input()))
p -= 1
p[a - 1] += 1
for i in p:
if i <= 0:
print("No")
else:
print("Yes")
| n, k, q = list(map(int, input().split()))
p = [k - q] * n
first = 0
for i in range(q):
a = int(eval(input()))
p[a - 1] += 1
for i in p:
if i <= 0:
print("No")
else:
print("Yes")
| false | 15.384615 | [
"-import numpy as np",
"-",
"-p = np.full(n, k, dtype=np.int)",
"+p = [k - q] * n",
"- p -= 1"
]
| false | 0.649766 | 0.062599 | 10.379887 | [
"s315427494",
"s606616402"
]
|
u498487134 | p02925 | python | s472334772 | s455447579 | 1,080 | 454 | 62,044 | 87,904 | Accepted | Accepted | 57.96 | N=int(eval(input()))
A=[[] for _ in range(N)]
for i in range(N):
A[i]=list(map(int,input().split()))
NE=[0]*N#i番目の人が,次何番目の試合をするかのリスト
F=[0]*N#i番目の人が,該当する日に試合をしたか記憶しておく
#i+1日目の試合をする人はi日目に試合をした人なので,それを2つのqueueに記憶.
Q=[[],[]]
#初日
for i in range(N):
opp=A[i][0]-1
if A[opp][0]-1==i:
NE[i]+=1
Q[0].append(i)
ans=1
#d日目
for d in range(N*(N-1)//2):
F=[0]*N
a=d%2
b=(d+1)%2
while len(Q[a])!=0:
i=Q[a].pop()
if NE[i]==N-1:
continue
opp=A[i][NE[i]]-1
if F[i]==1 or F[opp]==1:#その日に試合したことがある人はスルー,oppの重複防止
continue
if A[opp][NE[opp]]-1==i:
NE[i]+=1
NE[opp]+=1
F[i]=1
F[opp]=1
if NE[i]!=N-1:
Q[b].append(i)
if NE[opp]!=N-1:
Q[b].append(opp)
ans+=1
if len(Q[a])==0 and len(Q[b])==0:
break
for i in range(N):
if NE[i]!=N-1:
ans=-1
print(ans) | import sys
input = sys.stdin.readline
def I(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def LI(): return list(map(int, input().split()))
def main():
mod=10**9+7
N=I()
A=[]
inf=10**6
for _ in range(N):
a=LI()+[inf]
for j in range(N-1):
a[j]-=1
A.append(a)
cur=[0]*N#i番目の人が何試合消化したか
st=[]# stackに,みるべき人を入れていいく,変化があった人だけ見れば良い
nxt=[]
#初日は全員みる,N>=3より初日で終わることはない
for i in range(N):
for j in range(i+1,N):
if A[i][0]==j and A[j][0]==i:
cur[i]=1
cur[j]=1
st.append(i)
st.append(j)
day=1
while st:
used=[0]*N
day+=1
while st:
i=st.pop()#みる人
j=A[i][cur[i]]#相手候補
if used[i]==0 and used[j]==0:
if A[j][cur[j]]==i:#マッチング
cur[i]+=1
cur[j]+=1
nxt.append(i)
nxt.append(j)
used[i]=1
used[j]=1
while nxt:
a=nxt.pop()
if cur[a]!=N-1:
st.append(a)
if sum(cur)==N*(N-1):
print(day)
else:
print((-1))
main()
| 49 | 67 | 1,012 | 1,435 | N = int(eval(input()))
A = [[] for _ in range(N)]
for i in range(N):
A[i] = list(map(int, input().split()))
NE = [0] * N # i番目の人が,次何番目の試合をするかのリスト
F = [0] * N # i番目の人が,該当する日に試合をしたか記憶しておく
# i+1日目の試合をする人はi日目に試合をした人なので,それを2つのqueueに記憶.
Q = [[], []]
# 初日
for i in range(N):
opp = A[i][0] - 1
if A[opp][0] - 1 == i:
NE[i] += 1
Q[0].append(i)
ans = 1
# d日目
for d in range(N * (N - 1) // 2):
F = [0] * N
a = d % 2
b = (d + 1) % 2
while len(Q[a]) != 0:
i = Q[a].pop()
if NE[i] == N - 1:
continue
opp = A[i][NE[i]] - 1
if F[i] == 1 or F[opp] == 1: # その日に試合したことがある人はスルー,oppの重複防止
continue
if A[opp][NE[opp]] - 1 == i:
NE[i] += 1
NE[opp] += 1
F[i] = 1
F[opp] = 1
if NE[i] != N - 1:
Q[b].append(i)
if NE[opp] != N - 1:
Q[b].append(opp)
ans += 1
if len(Q[a]) == 0 and len(Q[b]) == 0:
break
for i in range(N):
if NE[i] != N - 1:
ans = -1
print(ans)
| import sys
input = sys.stdin.readline
def I():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
def LI():
return list(map(int, input().split()))
def main():
mod = 10**9 + 7
N = I()
A = []
inf = 10**6
for _ in range(N):
a = LI() + [inf]
for j in range(N - 1):
a[j] -= 1
A.append(a)
cur = [0] * N # i番目の人が何試合消化したか
st = [] # stackに,みるべき人を入れていいく,変化があった人だけ見れば良い
nxt = []
# 初日は全員みる,N>=3より初日で終わることはない
for i in range(N):
for j in range(i + 1, N):
if A[i][0] == j and A[j][0] == i:
cur[i] = 1
cur[j] = 1
st.append(i)
st.append(j)
day = 1
while st:
used = [0] * N
day += 1
while st:
i = st.pop() # みる人
j = A[i][cur[i]] # 相手候補
if used[i] == 0 and used[j] == 0:
if A[j][cur[j]] == i: # マッチング
cur[i] += 1
cur[j] += 1
nxt.append(i)
nxt.append(j)
used[i] = 1
used[j] = 1
while nxt:
a = nxt.pop()
if cur[a] != N - 1:
st.append(a)
if sum(cur) == N * (N - 1):
print(day)
else:
print((-1))
main()
| false | 26.865672 | [
"-N = int(eval(input()))",
"-A = [[] for _ in range(N)]",
"-for i in range(N):",
"- A[i] = list(map(int, input().split()))",
"-NE = [0] * N # i番目の人が,次何番目の試合をするかのリスト",
"-F = [0] * N # i番目の人が,該当する日に試合をしたか記憶しておく",
"-# i+1日目の試合をする人はi日目に試合をした人なので,それを2つのqueueに記憶.",
"-Q = [[], []]",
"-# 初日",
"-for i in range(N):",
"- opp = A[i][0] - 1",
"- if A[opp][0] - 1 == i:",
"- NE[i] += 1",
"- Q[0].append(i)",
"-ans = 1",
"-# d日目",
"-for d in range(N * (N - 1) // 2):",
"- F = [0] * N",
"- a = d % 2",
"- b = (d + 1) % 2",
"- while len(Q[a]) != 0:",
"- i = Q[a].pop()",
"- if NE[i] == N - 1:",
"- continue",
"- opp = A[i][NE[i]] - 1",
"- if F[i] == 1 or F[opp] == 1: # その日に試合したことがある人はスルー,oppの重複防止",
"- continue",
"- if A[opp][NE[opp]] - 1 == i:",
"- NE[i] += 1",
"- NE[opp] += 1",
"- F[i] = 1",
"- F[opp] = 1",
"- if NE[i] != N - 1:",
"- Q[b].append(i)",
"- if NE[opp] != N - 1:",
"- Q[b].append(opp)",
"- ans += 1",
"- if len(Q[a]) == 0 and len(Q[b]) == 0:",
"- break",
"-for i in range(N):",
"- if NE[i] != N - 1:",
"- ans = -1",
"-print(ans)",
"+import sys",
"+",
"+input = sys.stdin.readline",
"+",
"+",
"+def I():",
"+ return int(eval(input()))",
"+",
"+",
"+def MI():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+def LI():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+def main():",
"+ mod = 10**9 + 7",
"+ N = I()",
"+ A = []",
"+ inf = 10**6",
"+ for _ in range(N):",
"+ a = LI() + [inf]",
"+ for j in range(N - 1):",
"+ a[j] -= 1",
"+ A.append(a)",
"+ cur = [0] * N # i番目の人が何試合消化したか",
"+ st = [] # stackに,みるべき人を入れていいく,変化があった人だけ見れば良い",
"+ nxt = []",
"+ # 初日は全員みる,N>=3より初日で終わることはない",
"+ for i in range(N):",
"+ for j in range(i + 1, N):",
"+ if A[i][0] == j and A[j][0] == i:",
"+ cur[i] = 1",
"+ cur[j] = 1",
"+ st.append(i)",
"+ st.append(j)",
"+ day = 1",
"+ while st:",
"+ used = [0] * N",
"+ day += 1",
"+ while st:",
"+ i = st.pop() # みる人",
"+ j = A[i][cur[i]] # 相手候補",
"+ if used[i] == 0 and used[j] == 0:",
"+ if A[j][cur[j]] == i: # マッチング",
"+ cur[i] += 1",
"+ cur[j] += 1",
"+ nxt.append(i)",
"+ nxt.append(j)",
"+ used[i] = 1",
"+ used[j] = 1",
"+ while nxt:",
"+ a = nxt.pop()",
"+ if cur[a] != N - 1:",
"+ st.append(a)",
"+ if sum(cur) == N * (N - 1):",
"+ print(day)",
"+ else:",
"+ print((-1))",
"+",
"+",
"+main()"
]
| false | 0.035836 | 0.035706 | 1.003649 | [
"s472334772",
"s455447579"
]
|
u729133443 | p03970 | python | s227614734 | s079203660 | 163 | 18 | 38,384 | 2,940 | Accepted | Accepted | 88.96 | t=list(eval(input()));print((sum([1for i in range(16)if'CODEFESTIVAL2016'[i]!=t[i]]))) | print((sum(a!=b for a,b in zip('CODEFESTIVAL2016',eval(input()))))) | 1 | 1 | 78 | 59 | t = list(eval(input()))
print((sum([1 for i in range(16) if "CODEFESTIVAL2016"[i] != t[i]])))
| print((sum(a != b for a, b in zip("CODEFESTIVAL2016", eval(input())))))
| false | 0 | [
"-t = list(eval(input()))",
"-print((sum([1 for i in range(16) if \"CODEFESTIVAL2016\"[i] != t[i]])))",
"+print((sum(a != b for a, b in zip(\"CODEFESTIVAL2016\", eval(input())))))"
]
| false | 0.035767 | 0.077167 | 0.463508 | [
"s227614734",
"s079203660"
]
|
u561231954 | p02888 | python | s594969032 | s626325972 | 1,397 | 794 | 3,188 | 43,500 | Accepted | Accepted | 43.16 | from bisect import bisect_right
n=int(eval(input()))
L=[int(i) for i in input().split()]
L.sort()
ans=0
for i in range(n-2):
for j in range(i+1,n-1):
c=L[i]+L[j]-1
ans+=bisect_right(L,c)-j-1
print(ans) | n=int(eval(input()))
L=[int(i) for i in input().split()]
L.sort(reverse=True)
def binary(a,b,mid):
if L[mid]+L[j]>L[i]:
return True
else:
return False
ans=0
for i in range(n-2):
for j in range(i+1,n-1):
l=j
r=n
while r-l>1:
mid=(r+l)//2
if binary(i,j,mid):
l=mid
else:
r=mid
ans+=l-j
print(ans)
| 13 | 24 | 224 | 388 | from bisect import bisect_right
n = int(eval(input()))
L = [int(i) for i in input().split()]
L.sort()
ans = 0
for i in range(n - 2):
for j in range(i + 1, n - 1):
c = L[i] + L[j] - 1
ans += bisect_right(L, c) - j - 1
print(ans)
| n = int(eval(input()))
L = [int(i) for i in input().split()]
L.sort(reverse=True)
def binary(a, b, mid):
if L[mid] + L[j] > L[i]:
return True
else:
return False
ans = 0
for i in range(n - 2):
for j in range(i + 1, n - 1):
l = j
r = n
while r - l > 1:
mid = (r + l) // 2
if binary(i, j, mid):
l = mid
else:
r = mid
ans += l - j
print(ans)
| false | 45.833333 | [
"-from bisect import bisect_right",
"-",
"-L.sort()",
"+L.sort(reverse=True)",
"+",
"+",
"+def binary(a, b, mid):",
"+ if L[mid] + L[j] > L[i]:",
"+ return True",
"+ else:",
"+ return False",
"+",
"+",
"- c = L[i] + L[j] - 1",
"- ans += bisect_right(L, c) - j - 1",
"+ l = j",
"+ r = n",
"+ while r - l > 1:",
"+ mid = (r + l) // 2",
"+ if binary(i, j, mid):",
"+ l = mid",
"+ else:",
"+ r = mid",
"+ ans += l - j"
]
| false | 0.07713 | 0.083147 | 0.927636 | [
"s594969032",
"s626325972"
]
|
u600402037 | p02749 | python | s903875963 | s909485074 | 1,697 | 737 | 88,340 | 113,100 | Accepted | Accepted | 56.57 | import sys
import numpy as np
from collections import Counter
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
# 1 mod 3のグループを先に決めてあとは順番に
N = ir()
graph = [[] for _ in range(N+1)] # 1-indexed
for _ in range(N-1):
a, b = lr()
graph[a].append(b)
graph[b].append(a)
root = 1
rank = [0] * (N+1) # 1-indexed
rank[1] = 1
parent = [0] * (N+1) # 1-indexed
order = []
stack = [root]
while stack:
cur = stack.pop()
r = rank[cur]
order.append(cur)
for next in graph[cur]:
if next == parent[cur]:
continue
parent[next] = cur
rank[next] = r + 1
stack.append(next)
counter = [0, 0]
for x in rank[1:]:
counter[x%2] += 1
num0mod3 = N // 2
num1mod3 = (N+2) // 3
num2mod3 = (N+1) // 3
answer = [0] * (N+1)
if max(counter) >= num1mod3 + num2mod3:
#この時ここに1mod3、2mod3を全部入れる
if counter[0] > counter[1]:
index = 0
else:
index = 1
cur = 1
used = set()
for i in range(1, N+1):
if rank[i] % 2 == index:
answer[i] = cur
used.add(cur)
cur += 1
if cur % 3 == 0:
cur += 1
if cur > N:
break
cur = 1
for j in range(1, N+1):
while cur in used:
cur += 1
if answer[j] == 0:
answer[j] = cur
used.add(cur)
else:
#ここではcounterの多い方にnum1mod3を入れる
if counter[0] > counter[1]:
index = 0
else:
index = 1
cur = 1
used = set()
for i in range(1, N+1):
if rank[i] % 2 == index:
answer[i] = cur
used.add(cur)
cur += 3
if cur > N:
break
cur = 2
for i in range(1, N+1):
if rank[i] % 2 == 1-index:
answer[i] = cur
used.add(cur)
cur += 3
if cur > N:
break
cur = 1
for j in range(1, N+1):
while cur in used:
cur += 1
if answer[j] == 0:
answer[j] = cur
used.add(cur)
print((*answer[1:]))
| import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
# 1(mod 3)のグループと2(mod 3)を先に決める
N = ir()
graph = [[] for _ in range(N+1)] # 1-indexed
for _ in range(N-1):
a, b = lr()
graph[a].append(b)
graph[b].append(a)
root = 1
rank = [0] * (N+1) # 1-indexed
rank[1] = 1
parent = [0] * (N+1) # 1-indexed
stack = [root]
while stack:
cur = stack.pop()
r = rank[cur]
for next in graph[cur]:
if next == parent[cur]:
continue
parent[next] = cur
rank[next] = r + 1
stack.append(next)
counter = [0, 0]
for x in rank[1:]:
counter[x%2] += 1
num0mod3 = N // 2
num1mod3 = (N+2) // 3
num2mod3 = (N+1) // 3
answer = [0] * (N+1)
if max(counter) >= num1mod3 + num2mod3:
#この時ここに1mod3、2mod3を全部入れる
if counter[0] > counter[1]:
index = 0
else:
index = 1
cur = 1
used = set()
for i in range(1, N+1):
if rank[i] % 2 == index:
answer[i] = cur
used.add(cur)
cur += 1
if cur % 3 == 0:
cur += 1
if cur > N:
break
cur = 1
for j in range(1, N+1):
while cur in used:
cur += 1
if answer[j] == 0:
answer[j] = cur
used.add(cur)
else:
#ここではcounterの多い方にnum1mod3を入れる
if counter[0] > counter[1]:
index = 0
else:
index = 1
cur = 1
used = set()
for i in range(1, N+1):
if rank[i] % 2 == index:
answer[i] = cur
used.add(cur)
cur += 3
if cur > N:
break
cur = 2
for i in range(1, N+1):
if rank[i] % 2 == 1-index:
answer[i] = cur
used.add(cur)
cur += 3
if cur > N:
break
cur = 1
for j in range(1, N+1):
while cur in used:
cur += 1
if answer[j] == 0:
answer[j] = cur
used.add(cur)
print((*answer[1:]))
| 97 | 92 | 2,219 | 2,133 | import sys
import numpy as np
from collections import Counter
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
# 1 mod 3のグループを先に決めてあとは順番に
N = ir()
graph = [[] for _ in range(N + 1)] # 1-indexed
for _ in range(N - 1):
a, b = lr()
graph[a].append(b)
graph[b].append(a)
root = 1
rank = [0] * (N + 1) # 1-indexed
rank[1] = 1
parent = [0] * (N + 1) # 1-indexed
order = []
stack = [root]
while stack:
cur = stack.pop()
r = rank[cur]
order.append(cur)
for next in graph[cur]:
if next == parent[cur]:
continue
parent[next] = cur
rank[next] = r + 1
stack.append(next)
counter = [0, 0]
for x in rank[1:]:
counter[x % 2] += 1
num0mod3 = N // 2
num1mod3 = (N + 2) // 3
num2mod3 = (N + 1) // 3
answer = [0] * (N + 1)
if max(counter) >= num1mod3 + num2mod3:
# この時ここに1mod3、2mod3を全部入れる
if counter[0] > counter[1]:
index = 0
else:
index = 1
cur = 1
used = set()
for i in range(1, N + 1):
if rank[i] % 2 == index:
answer[i] = cur
used.add(cur)
cur += 1
if cur % 3 == 0:
cur += 1
if cur > N:
break
cur = 1
for j in range(1, N + 1):
while cur in used:
cur += 1
if answer[j] == 0:
answer[j] = cur
used.add(cur)
else:
# ここではcounterの多い方にnum1mod3を入れる
if counter[0] > counter[1]:
index = 0
else:
index = 1
cur = 1
used = set()
for i in range(1, N + 1):
if rank[i] % 2 == index:
answer[i] = cur
used.add(cur)
cur += 3
if cur > N:
break
cur = 2
for i in range(1, N + 1):
if rank[i] % 2 == 1 - index:
answer[i] = cur
used.add(cur)
cur += 3
if cur > N:
break
cur = 1
for j in range(1, N + 1):
while cur in used:
cur += 1
if answer[j] == 0:
answer[j] = cur
used.add(cur)
print((*answer[1:]))
| import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
# 1(mod 3)のグループと2(mod 3)を先に決める
N = ir()
graph = [[] for _ in range(N + 1)] # 1-indexed
for _ in range(N - 1):
a, b = lr()
graph[a].append(b)
graph[b].append(a)
root = 1
rank = [0] * (N + 1) # 1-indexed
rank[1] = 1
parent = [0] * (N + 1) # 1-indexed
stack = [root]
while stack:
cur = stack.pop()
r = rank[cur]
for next in graph[cur]:
if next == parent[cur]:
continue
parent[next] = cur
rank[next] = r + 1
stack.append(next)
counter = [0, 0]
for x in rank[1:]:
counter[x % 2] += 1
num0mod3 = N // 2
num1mod3 = (N + 2) // 3
num2mod3 = (N + 1) // 3
answer = [0] * (N + 1)
if max(counter) >= num1mod3 + num2mod3:
# この時ここに1mod3、2mod3を全部入れる
if counter[0] > counter[1]:
index = 0
else:
index = 1
cur = 1
used = set()
for i in range(1, N + 1):
if rank[i] % 2 == index:
answer[i] = cur
used.add(cur)
cur += 1
if cur % 3 == 0:
cur += 1
if cur > N:
break
cur = 1
for j in range(1, N + 1):
while cur in used:
cur += 1
if answer[j] == 0:
answer[j] = cur
used.add(cur)
else:
# ここではcounterの多い方にnum1mod3を入れる
if counter[0] > counter[1]:
index = 0
else:
index = 1
cur = 1
used = set()
for i in range(1, N + 1):
if rank[i] % 2 == index:
answer[i] = cur
used.add(cur)
cur += 3
if cur > N:
break
cur = 2
for i in range(1, N + 1):
if rank[i] % 2 == 1 - index:
answer[i] = cur
used.add(cur)
cur += 3
if cur > N:
break
cur = 1
for j in range(1, N + 1):
while cur in used:
cur += 1
if answer[j] == 0:
answer[j] = cur
used.add(cur)
print((*answer[1:]))
| false | 5.154639 | [
"-import numpy as np",
"-from collections import Counter",
"-# 1 mod 3のグループを先に決めてあとは順番に",
"+# 1(mod 3)のグループと2(mod 3)を先に決める",
"-order = []",
"- order.append(cur)"
]
| false | 0.208729 | 0.071979 | 2.89986 | [
"s903875963",
"s909485074"
]
|
u973840923 | p03087 | python | s273476267 | s217035303 | 876 | 470 | 7,748 | 30,664 | Accepted | Accepted | 46.35 | N,Q = list(map(int,input().split()))
S = eval(input())
cumu = [0]*(N+1)
for i in range(N):
cumu[i+1] = cumu[i] + (1 if S[i:i+2] == 'AC' else 0)
for i in range(Q):
l,r = list(map(int,input().split()))
print((cumu[r-1]-cumu[l-1])) | N,Q = list(map(int,input().split()))
S = eval(input())
list = [list(map(int,input().split())) for i in range(Q)]
comu = [0]*(N+1)
for i in range(N):
if S[i:i+2] == 'AC':
comu[i+1] = comu[i] + 1
else:
comu[i+1] = comu[i]
for l,r in list:
print((comu[r-1]-comu[l-1])) | 11 | 14 | 233 | 295 | N, Q = list(map(int, input().split()))
S = eval(input())
cumu = [0] * (N + 1)
for i in range(N):
cumu[i + 1] = cumu[i] + (1 if S[i : i + 2] == "AC" else 0)
for i in range(Q):
l, r = list(map(int, input().split()))
print((cumu[r - 1] - cumu[l - 1]))
| N, Q = list(map(int, input().split()))
S = eval(input())
list = [list(map(int, input().split())) for i in range(Q)]
comu = [0] * (N + 1)
for i in range(N):
if S[i : i + 2] == "AC":
comu[i + 1] = comu[i] + 1
else:
comu[i + 1] = comu[i]
for l, r in list:
print((comu[r - 1] - comu[l - 1]))
| false | 21.428571 | [
"-cumu = [0] * (N + 1)",
"+list = [list(map(int, input().split())) for i in range(Q)]",
"+comu = [0] * (N + 1)",
"- cumu[i + 1] = cumu[i] + (1 if S[i : i + 2] == \"AC\" else 0)",
"-for i in range(Q):",
"- l, r = list(map(int, input().split()))",
"- print((cumu[r - 1] - cumu[l - 1]))",
"+ if S[i : i + 2] == \"AC\":",
"+ comu[i + 1] = comu[i] + 1",
"+ else:",
"+ comu[i + 1] = comu[i]",
"+for l, r in list:",
"+ print((comu[r - 1] - comu[l - 1]))"
]
| false | 0.045672 | 0.054296 | 0.841178 | [
"s273476267",
"s217035303"
]
|
u057109575 | p02972 | python | s914599697 | s282929662 | 165 | 151 | 102,488 | 101,732 | Accepted | Accepted | 8.48 | N, *A = list(map(int, open(0).read().split()))
x = [0] * (N + 1)
ans = []
for i in reversed(list(range(1, N + 1))):
tmp = 0
for j in range(i, N + 1, i):
tmp += x[j]
if tmp % 2 != A[i - 1]:
x[i] += 1
ans.append(i)
print((len(ans)))
if ans:
print((*ans))
| N, *A = list(map(int, open(0).read().split()))
x = [0] * (N + 1)
ans = []
for i in reversed(list(range(1, N + 1))):
if sum(x[i::i]) % 2 != A[i - 1]:
x[i] += 1
ans.append(i)
print((len(ans)))
if ans:
print((*ans))
| 17 | 13 | 297 | 236 | N, *A = list(map(int, open(0).read().split()))
x = [0] * (N + 1)
ans = []
for i in reversed(list(range(1, N + 1))):
tmp = 0
for j in range(i, N + 1, i):
tmp += x[j]
if tmp % 2 != A[i - 1]:
x[i] += 1
ans.append(i)
print((len(ans)))
if ans:
print((*ans))
| N, *A = list(map(int, open(0).read().split()))
x = [0] * (N + 1)
ans = []
for i in reversed(list(range(1, N + 1))):
if sum(x[i::i]) % 2 != A[i - 1]:
x[i] += 1
ans.append(i)
print((len(ans)))
if ans:
print((*ans))
| false | 23.529412 | [
"- tmp = 0",
"- for j in range(i, N + 1, i):",
"- tmp += x[j]",
"- if tmp % 2 != A[i - 1]:",
"+ if sum(x[i::i]) % 2 != A[i - 1]:"
]
| false | 0.083098 | 0.037194 | 2.234182 | [
"s914599697",
"s282929662"
]
|
u583507988 | p03103 | python | s942750384 | s800914096 | 397 | 349 | 27,360 | 24,044 | Accepted | Accepted | 12.09 | from operator import itemgetter
n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(n)]
ab.sort()
#print(ab)
i = 0
ans = 0
while m >0:
if ab[i][1]<=m:
m -= ab[i][1]
ans += ab[i][0]*ab[i][1]
else:
ans += ab[i][0]*m
m = 0
i+=1
print(ans) | n,m=list(map(int,input().split()))
ab=[]
for i in range(n):
a,b=list(map(int,input().split()))
ab.append([a,b])
ab.sort()
ans=0
t=m
for i in range(n):
if ab[i][1]<t:
ans+=ab[i][0]*ab[i][1]
t-=ab[i][1]
else:
ans+=ab[i][0]*t
print(ans)
exit() | 17 | 16 | 308 | 271 | from operator import itemgetter
n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(n)]
ab.sort()
# print(ab)
i = 0
ans = 0
while m > 0:
if ab[i][1] <= m:
m -= ab[i][1]
ans += ab[i][0] * ab[i][1]
else:
ans += ab[i][0] * m
m = 0
i += 1
print(ans)
| n, m = list(map(int, input().split()))
ab = []
for i in range(n):
a, b = list(map(int, input().split()))
ab.append([a, b])
ab.sort()
ans = 0
t = m
for i in range(n):
if ab[i][1] < t:
ans += ab[i][0] * ab[i][1]
t -= ab[i][1]
else:
ans += ab[i][0] * t
print(ans)
exit()
| false | 5.882353 | [
"-from operator import itemgetter",
"-",
"-ab = [list(map(int, input().split())) for i in range(n)]",
"+ab = []",
"+for i in range(n):",
"+ a, b = list(map(int, input().split()))",
"+ ab.append([a, b])",
"-# print(ab)",
"-i = 0",
"-while m > 0:",
"- if ab[i][1] <= m:",
"- m -= ab[i][1]",
"+t = m",
"+for i in range(n):",
"+ if ab[i][1] < t:",
"+ t -= ab[i][1]",
"- ans += ab[i][0] * m",
"- m = 0",
"- i += 1",
"-print(ans)",
"+ ans += ab[i][0] * t",
"+ print(ans)",
"+ exit()"
]
| false | 0.040009 | 0.038583 | 1.036942 | [
"s942750384",
"s800914096"
]
|
u079022693 | p02996 | python | s644026062 | s585195859 | 906 | 610 | 53,620 | 53,656 | Accepted | Accepted | 32.67 | def main():
N=int(eval(input()))
AB=[0]*N
for i in range(N):
ab=list(map(int,input().split()))
AB[i]=ab
AB.sort(key=lambda x:x[1])
t=0
flag=True
for i in range(N):
t+=AB[i][0]
if t>AB[i][1]:
print("No")
flag=False
break
if flag:
print("Yes")
if __name__=="__main__":
main() | from sys import stdin
def main():
#入力
readline=stdin.readline
N=int(readline())
li=[]
for i in range(N):
ab=list(map(int,readline().split()))
li.append(ab)
li.sort(key=lambda x:x[1])
t=0
for i in range(N):
task=li[i]
t+=task[0]
if t>task[1]:
print("No")
break
else:
print("Yes")
if __name__=="__main__":
main() | 19 | 22 | 397 | 448 | def main():
N = int(eval(input()))
AB = [0] * N
for i in range(N):
ab = list(map(int, input().split()))
AB[i] = ab
AB.sort(key=lambda x: x[1])
t = 0
flag = True
for i in range(N):
t += AB[i][0]
if t > AB[i][1]:
print("No")
flag = False
break
if flag:
print("Yes")
if __name__ == "__main__":
main()
| from sys import stdin
def main():
# 入力
readline = stdin.readline
N = int(readline())
li = []
for i in range(N):
ab = list(map(int, readline().split()))
li.append(ab)
li.sort(key=lambda x: x[1])
t = 0
for i in range(N):
task = li[i]
t += task[0]
if t > task[1]:
print("No")
break
else:
print("Yes")
if __name__ == "__main__":
main()
| false | 13.636364 | [
"+from sys import stdin",
"+",
"+",
"- N = int(eval(input()))",
"- AB = [0] * N",
"+ # 入力",
"+ readline = stdin.readline",
"+ N = int(readline())",
"+ li = []",
"- ab = list(map(int, input().split()))",
"- AB[i] = ab",
"- AB.sort(key=lambda x: x[1])",
"+ ab = list(map(int, readline().split()))",
"+ li.append(ab)",
"+ li.sort(key=lambda x: x[1])",
"- flag = True",
"- t += AB[i][0]",
"- if t > AB[i][1]:",
"+ task = li[i]",
"+ t += task[0]",
"+ if t > task[1]:",
"- flag = False",
"- if flag:",
"+ else:"
]
| false | 0.042104 | 0.033453 | 1.258616 | [
"s644026062",
"s585195859"
]
|
u116038906 | p03032 | python | s477431564 | s848184593 | 104 | 31 | 10,712 | 9,256 | Accepted | Accepted | 70.19 | # 初期入力
import bisect
import sys
input = sys.stdin.readline
N,K = (int(i) for i in input().split())
V = list(map(int, input().split()))
V_sorted =sorted(V)
#取る個数take_num、返す個数reverse(t +r <=K)個全て決める
ans =[]
take_V =[] #最後に持っている宝石の価値
#Vが全てマイナスなら取らない
if V_sorted[-1] <=0:
ans =0
else:
take_num =min(K,N)
for tak in range(1,take_num +1):
reverse =min(K -tak,tak) #返す数はtake_numではなく、Kから引く
for lef in range(tak+1):
for rev in range(reverse +1):
take =[] #取った宝石
rig =N-(tak -lef ) #lef:左側の取る数 rig:右側の取る数
take.extend(V[ :lef])
take.extend(V[rig: ])
take.sort()
take_V.append(sum(take[rev:]))
ans =max(take_V)
print(ans) | # 初期入力
import bisect
import heapq
import sys
input = sys.stdin.readline
N,K = (int(i) for i in input().split())
V = list(map(int, input().split()))
V_sorted =sorted(V)
#取る個数take_num、返す個数reverse(t +r <=K)個全て決める
ans =[]
take_V =[] #最後に持っている宝石の価値
#Vが全てマイナスなら取らない
if V_sorted[-1] <=0:
ans =0
else:
take_num =min(K,N)
for tak in range(1,take_num +1):
for lef in range(tak+1):
#for rev in range(reverse +1):
take =[] #取った宝石
rig =N-(tak -lef ) #lef:左側の取る数 rig:右側の取る数
take.extend(V[ :lef])
take.extend(V[rig: ])
take.sort()
reverse =min(K -tak,tak) #返す数はtake_numではなく、Kから引く
ind_0 =bisect.bisect_left(take,0)
rev =min(ind_0,reverse,K -tak)
take_V.append(sum(take[rev:])) #返す分を除く
ans =max(take_V)
print(ans) | 31 | 34 | 836 | 948 | # 初期入力
import bisect
import sys
input = sys.stdin.readline
N, K = (int(i) for i in input().split())
V = list(map(int, input().split()))
V_sorted = sorted(V)
# 取る個数take_num、返す個数reverse(t +r <=K)個全て決める
ans = []
take_V = [] # 最後に持っている宝石の価値
# Vが全てマイナスなら取らない
if V_sorted[-1] <= 0:
ans = 0
else:
take_num = min(K, N)
for tak in range(1, take_num + 1):
reverse = min(K - tak, tak) # 返す数はtake_numではなく、Kから引く
for lef in range(tak + 1):
for rev in range(reverse + 1):
take = [] # 取った宝石
rig = N - (tak - lef) # lef:左側の取る数 rig:右側の取る数
take.extend(V[:lef])
take.extend(V[rig:])
take.sort()
take_V.append(sum(take[rev:]))
ans = max(take_V)
print(ans)
| # 初期入力
import bisect
import heapq
import sys
input = sys.stdin.readline
N, K = (int(i) for i in input().split())
V = list(map(int, input().split()))
V_sorted = sorted(V)
# 取る個数take_num、返す個数reverse(t +r <=K)個全て決める
ans = []
take_V = [] # 最後に持っている宝石の価値
# Vが全てマイナスなら取らない
if V_sorted[-1] <= 0:
ans = 0
else:
take_num = min(K, N)
for tak in range(1, take_num + 1):
for lef in range(tak + 1):
# for rev in range(reverse +1):
take = [] # 取った宝石
rig = N - (tak - lef) # lef:左側の取る数 rig:右側の取る数
take.extend(V[:lef])
take.extend(V[rig:])
take.sort()
reverse = min(K - tak, tak) # 返す数はtake_numではなく、Kから引く
ind_0 = bisect.bisect_left(take, 0)
rev = min(ind_0, reverse, K - tak)
take_V.append(sum(take[rev:])) # 返す分を除く
ans = max(take_V)
print(ans)
| false | 8.823529 | [
"+import heapq",
"- reverse = min(K - tak, tak) # 返す数はtake_numではなく、Kから引く",
"- for rev in range(reverse + 1):",
"- take = [] # 取った宝石",
"- rig = N - (tak - lef) # lef:左側の取る数 rig:右側の取る数",
"- take.extend(V[:lef])",
"- take.extend(V[rig:])",
"- take.sort()",
"- take_V.append(sum(take[rev:]))",
"+ # for rev in range(reverse +1):",
"+ take = [] # 取った宝石",
"+ rig = N - (tak - lef) # lef:左側の取る数 rig:右側の取る数",
"+ take.extend(V[:lef])",
"+ take.extend(V[rig:])",
"+ take.sort()",
"+ reverse = min(K - tak, tak) # 返す数はtake_numではなく、Kから引く",
"+ ind_0 = bisect.bisect_left(take, 0)",
"+ rev = min(ind_0, reverse, K - tak)",
"+ take_V.append(sum(take[rev:])) # 返す分を除く"
]
| false | 0.138238 | 0.039204 | 3.526162 | [
"s477431564",
"s848184593"
]
|
u092104621 | p02595 | python | s614175612 | s152632404 | 520 | 421 | 9,184 | 9,068 | Accepted | Accepted | 19.04 | n,d = list(map(int, input().split()))
c=0
for i in range(n):
x,y = list(map(int, input().split()))
if x ** 2 + y ** 2<= d ** 2:
c += 1
print(c) | n,d = list(map(int, input().split()))
c=0
for i in range(n):
x,y = list(map(int, input().split()))
if x * x + y * y <= d * d:
c += 1
print(c) | 7 | 7 | 157 | 155 | n, d = list(map(int, input().split()))
c = 0
for i in range(n):
x, y = list(map(int, input().split()))
if x**2 + y**2 <= d**2:
c += 1
print(c)
| n, d = list(map(int, input().split()))
c = 0
for i in range(n):
x, y = list(map(int, input().split()))
if x * x + y * y <= d * d:
c += 1
print(c)
| false | 0 | [
"- if x**2 + y**2 <= d**2:",
"+ if x * x + y * y <= d * d:"
]
| false | 0.043565 | 0.04188 | 1.040223 | [
"s614175612",
"s152632404"
]
|
u869919400 | p02924 | python | s407437142 | s144712013 | 1,477 | 61 | 38,384 | 61,680 | Accepted | Accepted | 95.87 | n = int(eval(input()))
print((sum(range(n)))) | N = int(eval(input()))
print(((N-1)*N//2))
| 2 | 2 | 38 | 36 | n = int(eval(input()))
print((sum(range(n))))
| N = int(eval(input()))
print(((N - 1) * N // 2))
| false | 0 | [
"-n = int(eval(input()))",
"-print((sum(range(n))))",
"+N = int(eval(input()))",
"+print(((N - 1) * N // 2))"
]
| false | 0.09607 | 0.03874 | 2.479871 | [
"s407437142",
"s144712013"
]
|
u285891772 | p02791 | python | s721580749 | s775547371 | 170 | 144 | 27,196 | 27,192 | Accepted | Accepted | 15.29 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
def ZIP(n): return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
N = INT()
P = LIST()
cnt = 1
MIN = P[0]
for i in range(1, N):
MIN = min(MIN, P[i])
if P[i] == MIN:
cnt += 1
print(cnt) | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
def ZIP(n): return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
N = INT()
P = LIST()
tmp = P[0]
ans = 1
for i in range(1, N):
if P[i] <= tmp:
ans += 1
tmp = P[i]
print(ans) | 32 | 31 | 919 | 908 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input():
return sys.stdin.readline().strip()
def INT():
return int(eval(input()))
def MAP():
return list(map(int, input().split()))
def LIST():
return list(map(int, input().split()))
def ZIP(n):
return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10**9)
INF = float("inf")
mod = 10**9 + 7
N = INT()
P = LIST()
cnt = 1
MIN = P[0]
for i in range(1, N):
MIN = min(MIN, P[i])
if P[i] == MIN:
cnt += 1
print(cnt)
| import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input():
return sys.stdin.readline().strip()
def INT():
return int(eval(input()))
def MAP():
return list(map(int, input().split()))
def LIST():
return list(map(int, input().split()))
def ZIP(n):
return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10**9)
INF = float("inf")
mod = 10**9 + 7
N = INT()
P = LIST()
tmp = P[0]
ans = 1
for i in range(1, N):
if P[i] <= tmp:
ans += 1
tmp = P[i]
print(ans)
| false | 3.125 | [
"-cnt = 1",
"-MIN = P[0]",
"+tmp = P[0]",
"+ans = 1",
"- MIN = min(MIN, P[i])",
"- if P[i] == MIN:",
"- cnt += 1",
"-print(cnt)",
"+ if P[i] <= tmp:",
"+ ans += 1",
"+ tmp = P[i]",
"+print(ans)"
]
| false | 0.048668 | 0.045976 | 1.058555 | [
"s721580749",
"s775547371"
]
|
u852690916 | p02642 | python | s453960241 | s350616289 | 210 | 151 | 108,980 | 106,676 | Accepted | Accepted | 28.1 | import sys
def main():
input = sys.stdin.readline
N = int(eval(input()))
*A, = list(map(int, input().split()))
w = [0] * (10 ** 6 + 1)
for a in A:
w[a] += 1
f = [False] * (10 ** 6 + 1)
for a in A:
if f[a]:
w[a] = 0
continue
for b in range(a * 2, 10 ** 6 + 1, a):
w[b] = 0
f[a] = True
print((sum(w)))
if __name__ == '__main__':
main()
| # でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(N, A):
C = [0] * (10**6 + 1)
for a in A:
if C[a] == 1:
C[a] = -1
continue
if C[a] == -1:
continue
C[a] = 1
for b in range(a + a, 10 ** 6 + 1, a):
C[b] = -1
ans = 0
for a in A:
if C[a] == 1:
ans += 1
print(ans)
if __name__ == '__main__':
input = sys.stdin.readline
N = int(eval(input()))
*A, = list(map(int, input().split()))
main(N, A)
| 20 | 24 | 444 | 551 | import sys
def main():
input = sys.stdin.readline
N = int(eval(input()))
(*A,) = list(map(int, input().split()))
w = [0] * (10**6 + 1)
for a in A:
w[a] += 1
f = [False] * (10**6 + 1)
for a in A:
if f[a]:
w[a] = 0
continue
for b in range(a * 2, 10**6 + 1, a):
w[b] = 0
f[a] = True
print((sum(w)))
if __name__ == "__main__":
main()
| # でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(N, A):
C = [0] * (10**6 + 1)
for a in A:
if C[a] == 1:
C[a] = -1
continue
if C[a] == -1:
continue
C[a] = 1
for b in range(a + a, 10**6 + 1, a):
C[b] = -1
ans = 0
for a in A:
if C[a] == 1:
ans += 1
print(ans)
if __name__ == "__main__":
input = sys.stdin.readline
N = int(eval(input()))
(*A,) = list(map(int, input().split()))
main(N, A)
| false | 16.666667 | [
"+# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)",
"-def main():",
"+def main(N, A):",
"+ C = [0] * (10**6 + 1)",
"+ for a in A:",
"+ if C[a] == 1:",
"+ C[a] = -1",
"+ continue",
"+ if C[a] == -1:",
"+ continue",
"+ C[a] = 1",
"+ for b in range(a + a, 10**6 + 1, a):",
"+ C[b] = -1",
"+ ans = 0",
"+ for a in A:",
"+ if C[a] == 1:",
"+ ans += 1",
"+ print(ans)",
"+",
"+",
"+if __name__ == \"__main__\":",
"- w = [0] * (10**6 + 1)",
"- for a in A:",
"- w[a] += 1",
"- f = [False] * (10**6 + 1)",
"- for a in A:",
"- if f[a]:",
"- w[a] = 0",
"- continue",
"- for b in range(a * 2, 10**6 + 1, a):",
"- w[b] = 0",
"- f[a] = True",
"- print((sum(w)))",
"-",
"-",
"-if __name__ == \"__main__\":",
"- main()",
"+ main(N, A)"
]
| false | 0.108769 | 0.155279 | 0.70047 | [
"s453960241",
"s350616289"
]
|
u188827677 | p03699 | python | s095529433 | s650173336 | 29 | 26 | 9,076 | 9,152 | Accepted | Accepted | 10.34 | n = int(eval(input()))
s = sorted([int(eval(input())) for _ in range(n)])
sumNum = sum(s)
if sumNum % 10 != 0:
print(sumNum)
exit()
else:
ans = 0
for i in s:
if (sumNum - i) % 10 != 0:
ans = max(ans, sumNum - i)
print(ans) | from itertools import combinations
n = int(eval(input()))
s = sorted([int(eval(input())) for _ in range(n)])
ans = sum(s)
if ans % 10 != 0: print(ans)
elif all(i%10 == 0 for i in s): print((0))
else:
for i in range(1,n):
for j in combinations(s,i):
t = sum(j)
if (ans-t)%10 != 0:
print((ans-t))
exit() | 13 | 14 | 243 | 333 | n = int(eval(input()))
s = sorted([int(eval(input())) for _ in range(n)])
sumNum = sum(s)
if sumNum % 10 != 0:
print(sumNum)
exit()
else:
ans = 0
for i in s:
if (sumNum - i) % 10 != 0:
ans = max(ans, sumNum - i)
print(ans)
| from itertools import combinations
n = int(eval(input()))
s = sorted([int(eval(input())) for _ in range(n)])
ans = sum(s)
if ans % 10 != 0:
print(ans)
elif all(i % 10 == 0 for i in s):
print((0))
else:
for i in range(1, n):
for j in combinations(s, i):
t = sum(j)
if (ans - t) % 10 != 0:
print((ans - t))
exit()
| false | 7.142857 | [
"+from itertools import combinations",
"+",
"-sumNum = sum(s)",
"-if sumNum % 10 != 0:",
"- print(sumNum)",
"- exit()",
"+ans = sum(s)",
"+if ans % 10 != 0:",
"+ print(ans)",
"+elif all(i % 10 == 0 for i in s):",
"+ print((0))",
"- ans = 0",
"- for i in s:",
"- if (sumNum - i) % 10 != 0:",
"- ans = max(ans, sumNum - i)",
"- print(ans)",
"+ for i in range(1, n):",
"+ for j in combinations(s, i):",
"+ t = sum(j)",
"+ if (ans - t) % 10 != 0:",
"+ print((ans - t))",
"+ exit()"
]
| false | 0.086664 | 0.033885 | 2.557585 | [
"s095529433",
"s650173336"
]
|
u416758623 | p03448 | python | s027541006 | s644705787 | 55 | 49 | 2,940 | 3,060 | Accepted | Accepted | 10.91 | A,B,C,X = [int(eval(input())) for x in range(4)]
cnt = 0
for i in range(A+1):
for j in range(B+1):
for k in range(C+1):
if X == 500*i + 100*j + 50*k:
cnt+=1
print(cnt) | a = int(eval(input()))
b = int(eval(input()))
c = int(eval(input()))
x = int(eval(input()))
ans = 0
for i in range(a+1):
for j in range(b+1):
for k in range(c+1):
if 500 * i + 100 * j + 50 * k == x:
ans += 1
print(ans) | 8 | 12 | 208 | 246 | A, B, C, X = [int(eval(input())) for x in range(4)]
cnt = 0
for i in range(A + 1):
for j in range(B + 1):
for k in range(C + 1):
if X == 500 * i + 100 * j + 50 * k:
cnt += 1
print(cnt)
| a = int(eval(input()))
b = int(eval(input()))
c = int(eval(input()))
x = int(eval(input()))
ans = 0
for i in range(a + 1):
for j in range(b + 1):
for k in range(c + 1):
if 500 * i + 100 * j + 50 * k == x:
ans += 1
print(ans)
| false | 33.333333 | [
"-A, B, C, X = [int(eval(input())) for x in range(4)]",
"-cnt = 0",
"-for i in range(A + 1):",
"- for j in range(B + 1):",
"- for k in range(C + 1):",
"- if X == 500 * i + 100 * j + 50 * k:",
"- cnt += 1",
"-print(cnt)",
"+a = int(eval(input()))",
"+b = int(eval(input()))",
"+c = int(eval(input()))",
"+x = int(eval(input()))",
"+ans = 0",
"+for i in range(a + 1):",
"+ for j in range(b + 1):",
"+ for k in range(c + 1):",
"+ if 500 * i + 100 * j + 50 * k == x:",
"+ ans += 1",
"+print(ans)"
]
| false | 0.126355 | 0.276228 | 0.457428 | [
"s027541006",
"s644705787"
]
|
u323680411 | p03327 | python | s373544918 | s636368546 | 21 | 17 | 3,316 | 2,940 | Accepted | Accepted | 19.05 | N = int(eval(input()))
print((["ABC", "ABD"][N >= 10 ** 3])) | N = int(eval(input()))
if N <= 999:
print("ABC")
else:
print("ABD") | 3 | 6 | 55 | 75 | N = int(eval(input()))
print((["ABC", "ABD"][N >= 10**3]))
| N = int(eval(input()))
if N <= 999:
print("ABC")
else:
print("ABD")
| false | 50 | [
"-print(([\"ABC\", \"ABD\"][N >= 10**3]))",
"+if N <= 999:",
"+ print(\"ABC\")",
"+else:",
"+ print(\"ABD\")"
]
| false | 0.03922 | 0.042222 | 0.928906 | [
"s373544918",
"s636368546"
]
|
u852690916 | p02762 | python | s520591758 | s071015977 | 796 | 333 | 118,748 | 107,104 | Accepted | Accepted | 58.17 | import sys
def main():
input = sys.stdin.readline
N, M, K = list(map(int, input().split()))
AB = [tuple(map(int, input().split())) for _ in range(M)]
CD = [tuple(map(int, input().split())) for _ in range(K)]
uf = UnionFindTree(N)
friend_or_block = [set() for _ in range(N)]
for a, b in AB:
a, b = a-1, b-1
uf.union(a, b)
friend_or_block[a].add(b)
friend_or_block[b].add(a)
for c, d in CD:
c, d = c-1, d-1
if uf.same(c, d):
friend_or_block[c].add(d)
friend_or_block[d].add(c)
print((*[uf.size(i) - len(friend_or_block[i]) - 1 for i in range(N)]))
class UnionFindTree:
def __init__(self, n):
self.parent = [-1] * n
def find(self, x):
p = self.parent
while p[x] >= 0: x, p[x] = p[x], p[p[x]]
return x
def union(self, x, y):
x, y, p = self.find(x), self.find(y), self.parent
if x == y: return
if p[x] > p[y]: x, y = y, x
p[x], p[y] = p[x] + p[y], x
def same(self, x, y): return self.find(x) == self.find(y)
def size(self, x): return -self.parent[self.find(x)]
if __name__ == '__main__':
main() | # でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
from typing import Iterable
import sys
def main(N, M, K, AB, CD):
friend_chain = UnionFindTree(N)
friend_count = [0] * N
block_count = [0] * N
for a, b in AB:
a, b = a - 1, b - 1
friend_chain.union(a, b)
friend_count[a] += 1
friend_count[b] += 1
for c, d in CD:
c, d = c - 1, d - 1
if friend_chain.same(c, d):
block_count[c] += 1
block_count[d] += 1
print((*[friend_chain.size(i) - 1 - friend_count[i] - block_count[i] for i in range(N)]))
class UnionFindTree:
def __init__(self, n: int) -> None:
self.parent = [-1] * n
def find(self, x: int) -> int:
p = self.parent
while p[x] >= 0: x, p[x] = p[x], p[p[x]]
return x
def union(self, x: int, y: int) -> bool:
x, y, p = self.find(x), self.find(y), self.parent
if x == y: return False
if p[x] > p[y]: x, y = y, x
p[x], p[y] = p[x] + p[y], x
return True
def same(self, x: int, y: int) -> bool:
return self.find(x) == self.find(y)
def size(self, x: int) -> int:
return -self.parent[self.find(x)]
def same_all(self, indices: Iterable[int]) -> bool:
f, v = self.find, self.find(indices[0])
return all(f(i) == v for i in indices)
if __name__ == '__main__':
input = sys.stdin.readline
N, M, K = list(map(int, input().split()))
AB = [tuple(map(int, input().split())) for _ in range(M)]
CD = [tuple(map(int, input().split())) for _ in range(K)]
main(N, M, K, AB, CD)
| 42 | 51 | 1,229 | 1,646 | import sys
def main():
input = sys.stdin.readline
N, M, K = list(map(int, input().split()))
AB = [tuple(map(int, input().split())) for _ in range(M)]
CD = [tuple(map(int, input().split())) for _ in range(K)]
uf = UnionFindTree(N)
friend_or_block = [set() for _ in range(N)]
for a, b in AB:
a, b = a - 1, b - 1
uf.union(a, b)
friend_or_block[a].add(b)
friend_or_block[b].add(a)
for c, d in CD:
c, d = c - 1, d - 1
if uf.same(c, d):
friend_or_block[c].add(d)
friend_or_block[d].add(c)
print((*[uf.size(i) - len(friend_or_block[i]) - 1 for i in range(N)]))
class UnionFindTree:
def __init__(self, n):
self.parent = [-1] * n
def find(self, x):
p = self.parent
while p[x] >= 0:
x, p[x] = p[x], p[p[x]]
return x
def union(self, x, y):
x, y, p = self.find(x), self.find(y), self.parent
if x == y:
return
if p[x] > p[y]:
x, y = y, x
p[x], p[y] = p[x] + p[y], x
def same(self, x, y):
return self.find(x) == self.find(y)
def size(self, x):
return -self.parent[self.find(x)]
if __name__ == "__main__":
main()
| # でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
from typing import Iterable
import sys
def main(N, M, K, AB, CD):
friend_chain = UnionFindTree(N)
friend_count = [0] * N
block_count = [0] * N
for a, b in AB:
a, b = a - 1, b - 1
friend_chain.union(a, b)
friend_count[a] += 1
friend_count[b] += 1
for c, d in CD:
c, d = c - 1, d - 1
if friend_chain.same(c, d):
block_count[c] += 1
block_count[d] += 1
print(
(
*[
friend_chain.size(i) - 1 - friend_count[i] - block_count[i]
for i in range(N)
]
)
)
class UnionFindTree:
def __init__(self, n: int) -> None:
self.parent = [-1] * n
def find(self, x: int) -> int:
p = self.parent
while p[x] >= 0:
x, p[x] = p[x], p[p[x]]
return x
def union(self, x: int, y: int) -> bool:
x, y, p = self.find(x), self.find(y), self.parent
if x == y:
return False
if p[x] > p[y]:
x, y = y, x
p[x], p[y] = p[x] + p[y], x
return True
def same(self, x: int, y: int) -> bool:
return self.find(x) == self.find(y)
def size(self, x: int) -> int:
return -self.parent[self.find(x)]
def same_all(self, indices: Iterable[int]) -> bool:
f, v = self.find, self.find(indices[0])
return all(f(i) == v for i in indices)
if __name__ == "__main__":
input = sys.stdin.readline
N, M, K = list(map(int, input().split()))
AB = [tuple(map(int, input().split())) for _ in range(M)]
CD = [tuple(map(int, input().split())) for _ in range(K)]
main(N, M, K, AB, CD)
| false | 17.647059 | [
"+# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)",
"+from typing import Iterable",
"-def main():",
"- input = sys.stdin.readline",
"- N, M, K = list(map(int, input().split()))",
"- AB = [tuple(map(int, input().split())) for _ in range(M)]",
"- CD = [tuple(map(int, input().split())) for _ in range(K)]",
"- uf = UnionFindTree(N)",
"- friend_or_block = [set() for _ in range(N)]",
"+def main(N, M, K, AB, CD):",
"+ friend_chain = UnionFindTree(N)",
"+ friend_count = [0] * N",
"+ block_count = [0] * N",
"- uf.union(a, b)",
"- friend_or_block[a].add(b)",
"- friend_or_block[b].add(a)",
"+ friend_chain.union(a, b)",
"+ friend_count[a] += 1",
"+ friend_count[b] += 1",
"- if uf.same(c, d):",
"- friend_or_block[c].add(d)",
"- friend_or_block[d].add(c)",
"- print((*[uf.size(i) - len(friend_or_block[i]) - 1 for i in range(N)]))",
"+ if friend_chain.same(c, d):",
"+ block_count[c] += 1",
"+ block_count[d] += 1",
"+ print(",
"+ (",
"+ *[",
"+ friend_chain.size(i) - 1 - friend_count[i] - block_count[i]",
"+ for i in range(N)",
"+ ]",
"+ )",
"+ )",
"- def __init__(self, n):",
"+ def __init__(self, n: int) -> None:",
"- def find(self, x):",
"+ def find(self, x: int) -> int:",
"- def union(self, x, y):",
"+ def union(self, x: int, y: int) -> bool:",
"- return",
"+ return False",
"+ return True",
"- def same(self, x, y):",
"+ def same(self, x: int, y: int) -> bool:",
"- def size(self, x):",
"+ def size(self, x: int) -> int:",
"+",
"+ def same_all(self, indices: Iterable[int]) -> bool:",
"+ f, v = self.find, self.find(indices[0])",
"+ return all(f(i) == v for i in indices)",
"- main()",
"+ input = sys.stdin.readline",
"+ N, M, K = list(map(int, input().split()))",
"+ AB = [tuple(map(int, input().split())) for _ in range(M)]",
"+ CD = [tuple(map(int, input().split())) for _ in range(K)]",
"+ main(N, M, K, AB, CD)"
]
| false | 0.053562 | 0.090644 | 0.590901 | [
"s520591758",
"s071015977"
]
|
u795405022 | p00009 | python | s914965684 | s180167819 | 1,670 | 1,430 | 44,464 | 20,832 | Accepted | Accepted | 14.37 | max = 1000000
candidates = [True for x in range(0, max + 1)]
candidates[0] = False
candidates[1] = False
for i in range(2, max / 2):
if not candidates[i]:
continue
j = i + i
while True:
if max < j:
break
candidates[j] = False
j += i
while True:
try:
n = int(input())
print(len([i for i in candidates[0:n+1] if i]))
except Exception:
break | import math
max = 1000000
candidates = [True for x in range(0, max + 1)]
candidates[0] = False
candidates[1] = False
for i in range(2, int(math.sqrt(max))):
if not candidates[i]:
continue
j = i + i
while True:
if max < j:
break
candidates[j] = False
j += i
while True:
try:
n = int(input())
print(len([i for i in candidates[0:n+1] if i]))
except Exception:
break | 22 | 24 | 453 | 482 | max = 1000000
candidates = [True for x in range(0, max + 1)]
candidates[0] = False
candidates[1] = False
for i in range(2, max / 2):
if not candidates[i]:
continue
j = i + i
while True:
if max < j:
break
candidates[j] = False
j += i
while True:
try:
n = int(input())
print(len([i for i in candidates[0 : n + 1] if i]))
except Exception:
break
| import math
max = 1000000
candidates = [True for x in range(0, max + 1)]
candidates[0] = False
candidates[1] = False
for i in range(2, int(math.sqrt(max))):
if not candidates[i]:
continue
j = i + i
while True:
if max < j:
break
candidates[j] = False
j += i
while True:
try:
n = int(input())
print(len([i for i in candidates[0 : n + 1] if i]))
except Exception:
break
| false | 8.333333 | [
"+import math",
"+",
"-for i in range(2, max / 2):",
"+for i in range(2, int(math.sqrt(max))):"
]
| false | 0.126579 | 1.238615 | 0.102194 | [
"s914965684",
"s180167819"
]
|
u525065967 | p02572 | python | s332387411 | s962096115 | 133 | 110 | 25,052 | 24,924 | Accepted | Accepted | 17.29 | _ = eval(input())
MOD = 10**9 + 7
ans = b = 0
for a in map(int, input().split()):
ans += a * b
ans %= MOD
b += a
print(ans)
| _ = eval(input())
ans = b = 0
for a in map(int, input().split()):
ans += a * b
b += a
print((ans % (10**9 + 7)))
| 8 | 6 | 137 | 118 | _ = eval(input())
MOD = 10**9 + 7
ans = b = 0
for a in map(int, input().split()):
ans += a * b
ans %= MOD
b += a
print(ans)
| _ = eval(input())
ans = b = 0
for a in map(int, input().split()):
ans += a * b
b += a
print((ans % (10**9 + 7)))
| false | 25 | [
"-MOD = 10**9 + 7",
"- ans %= MOD",
"-print(ans)",
"+print((ans % (10**9 + 7)))"
]
| false | 0.044237 | 0.074561 | 0.593304 | [
"s332387411",
"s962096115"
]
|
u811733736 | p00449 | python | s587294420 | s558764556 | 4,210 | 2,800 | 9,016 | 8,668 | Accepted | Accepted | 33.49 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0526
TLE
"""
import sys
from sys import stdin
from heapq import heappush, heappop
from collections import namedtuple
input = stdin.readline
def warshall_floyd(d, V):
for k in range(V):
for i in range(V):
for j in range(V):
new_cost = d[i][k] + d[k][j]
if new_cost < d[i][j]:
d[i][j] = new_cost
def main1(args):
while True:
n, k = list(map(int, input().split()))
if n == 0 and k == 0:
break
d = [[float('inf')] * (n+1) for _ in range(n+1)]
#for i in range(n+1):
# d[i][i] = 0
updated = False
for _ in range(k):
data = [int(x) for x in input().split()]
if data[0] == 0:
if updated:
warshall_floyd(d, n+1)
updated = False
f, t = data[1], data[2]
if d[f][t] == float('inf'):
print((-1))
else:
print((d[f][t]))
else:
f, t, c = data[1], data[2], data[3]
if c < d[f][t]:
d[f][t] = c
updated = True
if c < d[t][f]:
d[t][f] = c
updated = True
edge = namedtuple('edge', ['t', 'c'])
def dijkstra(s, G):
pq = []
d = [float('inf')] * len(G)
d[s] = 0
heappush(pq, (0, s))
while pq:
c, v = heappop(pq)
if d[v] < c:
continue
for e in G[v]: # ?????????v?????£??\??????????????±????????¨?????????????????°?????§?????????????????´??°
if d[e.t] > d[v] + e.c: # ???????????§??\??£?????????????????????????????????v????????±????????????????????????????????????????????°???????????????????????´??°
d[e.t] = d[v] + e.c
heappush(pq, (d[e.t], e.t)) # python???heapq??????????°???????????????????pop?????????????????????????????§???-1??????????????????
return d
def main(args):
while True:
n, k = list(map(int, input().split()))
if n == 0 and k == 0:
break
d = [[] for _ in range(n+1)]
costs = [[float('inf')]*(n+1) for _ in range(n+1)]
updated = False
for _ in range(k):
data = [int(x) for x in input().split()]
if data[0] == 0:
f, t = data[1], data[2]
if updated:
costs[f] = dijkstra(f, d)
if costs[f][t] == float('inf'):
print((-1))
else:
print((costs[f][t]))
else:
f, t, c = data[1], data[2], data[3]
d[f].append(edge(t, c))
d[t].append(edge(f, c))
updated = True
if __name__ == '__main__':
main(sys.argv[1:])
| # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0526
TLE
"""
import sys
from sys import stdin
from heapq import heappush, heappop
input = stdin.readline
def dijkstra(s, G):
pq = []
d = [float('inf')] * len(G)
d[s] = 0
heappush(pq, (0, s))
while pq:
c, v = heappop(pq)
if d[v] < c:
continue
for t, c in list(G[v].items()): # ?????????v?????£??\??????????????±????????¨?????????????????°?????§?????????????????´??°
if d[t] > d[v] + c: # ???????????§??\??£?????????????????????????????????v????????±????????????????????????????????????????????°???????????????????????´??°
d[t] = d[v] + c
heappush(pq, (d[t], t)) # python???heapq??????????°???????????????????pop?????????????????????????????§???-1??????????????????
return d
def main(args):
while True:
n, k = list(map(int, input().split()))
if n == 0 and k == 0:
break
d = [{} for _ in range(n+1)]
costs = [[float('inf')]*(n+1) for _ in range(n+1)]
updated = False
for _ in range(k):
data = [int(x) for x in input().split()]
if data[0] == 0:
f, t = data[1], data[2]
if updated:
costs[f] = dijkstra(f, d)
if costs[f][t] == float('inf'):
print((-1))
else:
print((costs[f][t]))
else:
f, t, c = data[1], data[2], data[3]
if t in d[f]:
d[f][t] = min(d[f][t], c)
else:
d[f][t] = c
if f in d[t]:
d[t][f] = min(d[t][f], c)
else:
d[t][f] = c
updated = True
if __name__ == '__main__':
main(sys.argv[1:])
| 102 | 63 | 3,040 | 1,956 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0526
TLE
"""
import sys
from sys import stdin
from heapq import heappush, heappop
from collections import namedtuple
input = stdin.readline
def warshall_floyd(d, V):
for k in range(V):
for i in range(V):
for j in range(V):
new_cost = d[i][k] + d[k][j]
if new_cost < d[i][j]:
d[i][j] = new_cost
def main1(args):
while True:
n, k = list(map(int, input().split()))
if n == 0 and k == 0:
break
d = [[float("inf")] * (n + 1) for _ in range(n + 1)]
# for i in range(n+1):
# d[i][i] = 0
updated = False
for _ in range(k):
data = [int(x) for x in input().split()]
if data[0] == 0:
if updated:
warshall_floyd(d, n + 1)
updated = False
f, t = data[1], data[2]
if d[f][t] == float("inf"):
print((-1))
else:
print((d[f][t]))
else:
f, t, c = data[1], data[2], data[3]
if c < d[f][t]:
d[f][t] = c
updated = True
if c < d[t][f]:
d[t][f] = c
updated = True
edge = namedtuple("edge", ["t", "c"])
def dijkstra(s, G):
pq = []
d = [float("inf")] * len(G)
d[s] = 0
heappush(pq, (0, s))
while pq:
c, v = heappop(pq)
if d[v] < c:
continue
for e in G[
v
]: # ?????????v?????£??\??????????????±????????¨?????????????????°?????§?????????????????´??°
if (
d[e.t] > d[v] + e.c
): # ???????????§??\??£?????????????????????????????????v????????±????????????????????????????????????????????°???????????????????????´??°
d[e.t] = d[v] + e.c
heappush(
pq, (d[e.t], e.t)
) # python???heapq??????????°???????????????????pop?????????????????????????????§???-1??????????????????
return d
def main(args):
while True:
n, k = list(map(int, input().split()))
if n == 0 and k == 0:
break
d = [[] for _ in range(n + 1)]
costs = [[float("inf")] * (n + 1) for _ in range(n + 1)]
updated = False
for _ in range(k):
data = [int(x) for x in input().split()]
if data[0] == 0:
f, t = data[1], data[2]
if updated:
costs[f] = dijkstra(f, d)
if costs[f][t] == float("inf"):
print((-1))
else:
print((costs[f][t]))
else:
f, t, c = data[1], data[2], data[3]
d[f].append(edge(t, c))
d[t].append(edge(f, c))
updated = True
if __name__ == "__main__":
main(sys.argv[1:])
| # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0526
TLE
"""
import sys
from sys import stdin
from heapq import heappush, heappop
input = stdin.readline
def dijkstra(s, G):
pq = []
d = [float("inf")] * len(G)
d[s] = 0
heappush(pq, (0, s))
while pq:
c, v = heappop(pq)
if d[v] < c:
continue
for t, c in list(
G[v].items()
): # ?????????v?????£??\??????????????±????????¨?????????????????°?????§?????????????????´??°
if (
d[t] > d[v] + c
): # ???????????§??\??£?????????????????????????????????v????????±????????????????????????????????????????????°???????????????????????´??°
d[t] = d[v] + c
heappush(
pq, (d[t], t)
) # python???heapq??????????°???????????????????pop?????????????????????????????§???-1??????????????????
return d
def main(args):
while True:
n, k = list(map(int, input().split()))
if n == 0 and k == 0:
break
d = [{} for _ in range(n + 1)]
costs = [[float("inf")] * (n + 1) for _ in range(n + 1)]
updated = False
for _ in range(k):
data = [int(x) for x in input().split()]
if data[0] == 0:
f, t = data[1], data[2]
if updated:
costs[f] = dijkstra(f, d)
if costs[f][t] == float("inf"):
print((-1))
else:
print((costs[f][t]))
else:
f, t, c = data[1], data[2], data[3]
if t in d[f]:
d[f][t] = min(d[f][t], c)
else:
d[f][t] = c
if f in d[t]:
d[t][f] = min(d[t][f], c)
else:
d[t][f] = c
updated = True
if __name__ == "__main__":
main(sys.argv[1:])
| false | 38.235294 | [
"-from collections import namedtuple",
"-",
"-",
"-def warshall_floyd(d, V):",
"- for k in range(V):",
"- for i in range(V):",
"- for j in range(V):",
"- new_cost = d[i][k] + d[k][j]",
"- if new_cost < d[i][j]:",
"- d[i][j] = new_cost",
"-",
"-",
"-def main1(args):",
"- while True:",
"- n, k = list(map(int, input().split()))",
"- if n == 0 and k == 0:",
"- break",
"- d = [[float(\"inf\")] * (n + 1) for _ in range(n + 1)]",
"- # for i in range(n+1):",
"- # d[i][i] = 0",
"- updated = False",
"- for _ in range(k):",
"- data = [int(x) for x in input().split()]",
"- if data[0] == 0:",
"- if updated:",
"- warshall_floyd(d, n + 1)",
"- updated = False",
"- f, t = data[1], data[2]",
"- if d[f][t] == float(\"inf\"):",
"- print((-1))",
"- else:",
"- print((d[f][t]))",
"- else:",
"- f, t, c = data[1], data[2], data[3]",
"- if c < d[f][t]:",
"- d[f][t] = c",
"- updated = True",
"- if c < d[t][f]:",
"- d[t][f] = c",
"- updated = True",
"-",
"-",
"-edge = namedtuple(\"edge\", [\"t\", \"c\"])",
"- for e in G[",
"- v",
"- ]: # ?????????v?????£??\\??????????????±????????¨?????????????????°?????§?????????????????´??°",
"+ for t, c in list(",
"+ G[v].items()",
"+ ): # ?????????v?????£??\\??????????????±????????¨?????????????????°?????§?????????????????´??°",
"- d[e.t] > d[v] + e.c",
"+ d[t] > d[v] + c",
"- d[e.t] = d[v] + e.c",
"+ d[t] = d[v] + c",
"- pq, (d[e.t], e.t)",
"+ pq, (d[t], t)",
"- d = [[] for _ in range(n + 1)]",
"+ d = [{} for _ in range(n + 1)]",
"- d[f].append(edge(t, c))",
"- d[t].append(edge(f, c))",
"+ if t in d[f]:",
"+ d[f][t] = min(d[f][t], c)",
"+ else:",
"+ d[f][t] = c",
"+ if f in d[t]:",
"+ d[t][f] = min(d[t][f], c)",
"+ else:",
"+ d[t][f] = c"
]
| false | 0.100964 | 0.046107 | 2.18976 | [
"s587294420",
"s558764556"
]
|
u299856014 | p02813 | python | s262893737 | s657214201 | 156 | 31 | 3,064 | 8,052 | Accepted | Accepted | 80.13 | import itertools
n = int(eval(input()))
p = input().replace(' ', '')
q = input().replace(' ', '')
for i, num in enumerate(itertools.permutations(list(range(1,n+1)))):
num = ''.join(map(str, list(num)))
if num == p:
break
for j, num in enumerate(itertools.permutations(list(range(1,n+1)))):
num = ''.join(map(str, list(num)))
if num == q:
break
print((abs(i-j))) | import itertools
n = int(eval(input()))
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
N = list(itertools.permutations(list(range(1, n+1))))
def f(val):
for i, x in enumerate(N):
if x == val:
return i+1
print((abs(f(p) - f(q))))
| 15 | 14 | 389 | 283 | import itertools
n = int(eval(input()))
p = input().replace(" ", "")
q = input().replace(" ", "")
for i, num in enumerate(itertools.permutations(list(range(1, n + 1)))):
num = "".join(map(str, list(num)))
if num == p:
break
for j, num in enumerate(itertools.permutations(list(range(1, n + 1)))):
num = "".join(map(str, list(num)))
if num == q:
break
print((abs(i - j)))
| import itertools
n = int(eval(input()))
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
N = list(itertools.permutations(list(range(1, n + 1))))
def f(val):
for i, x in enumerate(N):
if x == val:
return i + 1
print((abs(f(p) - f(q))))
| false | 6.666667 | [
"-p = input().replace(\" \", \"\")",
"-q = input().replace(\" \", \"\")",
"-for i, num in enumerate(itertools.permutations(list(range(1, n + 1)))):",
"- num = \"\".join(map(str, list(num)))",
"- if num == p:",
"- break",
"-for j, num in enumerate(itertools.permutations(list(range(1, n + 1)))):",
"- num = \"\".join(map(str, list(num)))",
"- if num == q:",
"- break",
"-print((abs(i - j)))",
"+p = tuple(map(int, input().split()))",
"+q = tuple(map(int, input().split()))",
"+N = list(itertools.permutations(list(range(1, n + 1))))",
"+",
"+",
"+def f(val):",
"+ for i, x in enumerate(N):",
"+ if x == val:",
"+ return i + 1",
"+",
"+",
"+print((abs(f(p) - f(q))))"
]
| false | 0.161067 | 0.03735 | 4.31237 | [
"s262893737",
"s657214201"
]
|
u221679506 | p00276 | python | s463856597 | s185596137 | 40 | 20 | 7,632 | 7,652 | Accepted | Accepted | 50 | for i in range(int(eval(input()))):
c,a,n = list(map(int,input().split()))
cnt = 0
while True:
if c<1 or a<1 or n<1:
break
c -= 1
a -= 1
n -= 1
cnt += 1
while True:
if c<2 or a<1:
break
c -= 2
a -= 1
cnt += 1
while True:
if c<3:
break
c -= 3
cnt += 1
print(cnt) | for i in range(int(eval(input()))):
c,a,n = list(map(int,input().split()))
cnt1 = min(c,a,n)
c -= cnt1
a -= cnt1
cnt2 = min(c//2,a)
c -= cnt2*2
cnt3 = c//3
print((cnt1+cnt2+cnt3)) | 22 | 9 | 309 | 181 | for i in range(int(eval(input()))):
c, a, n = list(map(int, input().split()))
cnt = 0
while True:
if c < 1 or a < 1 or n < 1:
break
c -= 1
a -= 1
n -= 1
cnt += 1
while True:
if c < 2 or a < 1:
break
c -= 2
a -= 1
cnt += 1
while True:
if c < 3:
break
c -= 3
cnt += 1
print(cnt)
| for i in range(int(eval(input()))):
c, a, n = list(map(int, input().split()))
cnt1 = min(c, a, n)
c -= cnt1
a -= cnt1
cnt2 = min(c // 2, a)
c -= cnt2 * 2
cnt3 = c // 3
print((cnt1 + cnt2 + cnt3))
| false | 59.090909 | [
"- cnt = 0",
"- while True:",
"- if c < 1 or a < 1 or n < 1:",
"- break",
"- c -= 1",
"- a -= 1",
"- n -= 1",
"- cnt += 1",
"- while True:",
"- if c < 2 or a < 1:",
"- break",
"- c -= 2",
"- a -= 1",
"- cnt += 1",
"- while True:",
"- if c < 3:",
"- break",
"- c -= 3",
"- cnt += 1",
"- print(cnt)",
"+ cnt1 = min(c, a, n)",
"+ c -= cnt1",
"+ a -= cnt1",
"+ cnt2 = min(c // 2, a)",
"+ c -= cnt2 * 2",
"+ cnt3 = c // 3",
"+ print((cnt1 + cnt2 + cnt3))"
]
| false | 0.046147 | 0.047006 | 0.981726 | [
"s463856597",
"s185596137"
]
|
u753803401 | p02936 | python | s156672881 | s981170803 | 1,677 | 1,066 | 128,488 | 123,864 | Accepted | Accepted | 36.43 | def slove():
import sys
import collections
input = sys.stdin.readline
n, q = list(map(int, input().rstrip('\n').split()))
d = collections.defaultdict(list)
for i in range(n-1):
a, b = list(map(int, input().rstrip('\n').split()))
d[a] += [b]
d[b] += [a]
score = collections.defaultdict(int)
for i in range(q):
p, x = list(map(int, input().rstrip('\n').split()))
score[p] += x
ql = collections.deque()
ql.append(1)
fq = collections.defaultdict(list)
fq[1]
while True:
if len(ql) != 0:
p = ql.popleft()
for v in d[p]:
if v not in fq:
score[v] += score[p]
fq[v]
ql.append(v)
else:
break
print((*[score[i] for i in range(1, n + 1)]))
if __name__ == '__main__':
slove()
| import sys
import collections
def solve():
input = sys.stdin.readline
mod = 10 ** 9 + 7
n, q = list(map(int, input().rstrip('\n').split()))
d = collections.defaultdict(list)
for i in range(n-1):
a, b = list(map(int, input().rstrip('\n').split()))
d[a-1] += [b-1]
d[b-1] += [a-1]
ls = [0] * n
for i in range(q):
p, x = list(map(int, input().rstrip('\n').split()))
ls[p-1] += x
ql = collections.deque([0])
fq = collections.defaultdict(int)
fq[0]
while True:
if len(ql) != 0:
p = ql.popleft()
for v in d[p]:
if v not in fq:
ls[v] += ls[p]
ql.appendleft(v)
fq[p]
else:
print((*ls))
exit()
if __name__ == '__main__':
solve()
| 35 | 35 | 928 | 884 | def slove():
import sys
import collections
input = sys.stdin.readline
n, q = list(map(int, input().rstrip("\n").split()))
d = collections.defaultdict(list)
for i in range(n - 1):
a, b = list(map(int, input().rstrip("\n").split()))
d[a] += [b]
d[b] += [a]
score = collections.defaultdict(int)
for i in range(q):
p, x = list(map(int, input().rstrip("\n").split()))
score[p] += x
ql = collections.deque()
ql.append(1)
fq = collections.defaultdict(list)
fq[1]
while True:
if len(ql) != 0:
p = ql.popleft()
for v in d[p]:
if v not in fq:
score[v] += score[p]
fq[v]
ql.append(v)
else:
break
print((*[score[i] for i in range(1, n + 1)]))
if __name__ == "__main__":
slove()
| import sys
import collections
def solve():
input = sys.stdin.readline
mod = 10**9 + 7
n, q = list(map(int, input().rstrip("\n").split()))
d = collections.defaultdict(list)
for i in range(n - 1):
a, b = list(map(int, input().rstrip("\n").split()))
d[a - 1] += [b - 1]
d[b - 1] += [a - 1]
ls = [0] * n
for i in range(q):
p, x = list(map(int, input().rstrip("\n").split()))
ls[p - 1] += x
ql = collections.deque([0])
fq = collections.defaultdict(int)
fq[0]
while True:
if len(ql) != 0:
p = ql.popleft()
for v in d[p]:
if v not in fq:
ls[v] += ls[p]
ql.appendleft(v)
fq[p]
else:
print((*ls))
exit()
if __name__ == "__main__":
solve()
| false | 0 | [
"-def slove():",
"- import sys",
"- import collections",
"+import sys",
"+import collections",
"+",
"+def solve():",
"+ mod = 10**9 + 7",
"- d[a] += [b]",
"- d[b] += [a]",
"- score = collections.defaultdict(int)",
"+ d[a - 1] += [b - 1]",
"+ d[b - 1] += [a - 1]",
"+ ls = [0] * n",
"- score[p] += x",
"- ql = collections.deque()",
"- ql.append(1)",
"- fq = collections.defaultdict(list)",
"- fq[1]",
"+ ls[p - 1] += x",
"+ ql = collections.deque([0])",
"+ fq = collections.defaultdict(int)",
"+ fq[0]",
"- score[v] += score[p]",
"- fq[v]",
"- ql.append(v)",
"+ ls[v] += ls[p]",
"+ ql.appendleft(v)",
"+ fq[p]",
"- break",
"- print((*[score[i] for i in range(1, n + 1)]))",
"+ print((*ls))",
"+ exit()",
"- slove()",
"+ solve()"
]
| false | 0.044542 | 0.007532 | 5.914105 | [
"s156672881",
"s981170803"
]
|
u150984829 | p00445 | python | s165846191 | s240848874 | 30 | 20 | 5,604 | 6,096 | Accepted | Accepted | 33.33 | import sys
for e in sys.stdin:
s=sum((e[i:i+3]=='JOI')+1j*(e[i:i+3]=='IOI')for i in range(len(e)-3))
print((int(s.real)))
print((int(s.imag)))
| import sys
for e in sys.stdin:
s=[e[i:i+3]for i in range(len(e)-3)]
for w in['JOI','IOI']:print((s.count(w)))
| 5 | 4 | 146 | 113 | import sys
for e in sys.stdin:
s = sum(
(e[i : i + 3] == "JOI") + 1j * (e[i : i + 3] == "IOI")
for i in range(len(e) - 3)
)
print((int(s.real)))
print((int(s.imag)))
| import sys
for e in sys.stdin:
s = [e[i : i + 3] for i in range(len(e) - 3)]
for w in ["JOI", "IOI"]:
print((s.count(w)))
| false | 20 | [
"- s = sum(",
"- (e[i : i + 3] == \"JOI\") + 1j * (e[i : i + 3] == \"IOI\")",
"- for i in range(len(e) - 3)",
"- )",
"- print((int(s.real)))",
"- print((int(s.imag)))",
"+ s = [e[i : i + 3] for i in range(len(e) - 3)]",
"+ for w in [\"JOI\", \"IOI\"]:",
"+ print((s.count(w)))"
]
| false | 0.04803 | 0.047686 | 1.007217 | [
"s165846191",
"s240848874"
]
|
u644907318 | p03304 | python | s499090660 | s252796787 | 169 | 77 | 38,256 | 61,868 | Accepted | Accepted | 54.44 | n,m,d = list(map(int,input().split()))
if d==0:
print(((m-1)/n))
else:
print((2*(n-d)*(m-1)/n**2)) | n,m,d = list(map(int,input().split()))
if d==0:
print(((1*n-2*d)*(m-1)/n**2))
elif n>=2*d:
print(((2*n-2*d)*(m-1)/n**2))
else:
print((2*d*(m-1)/n**2)) | 5 | 7 | 100 | 156 | n, m, d = list(map(int, input().split()))
if d == 0:
print(((m - 1) / n))
else:
print((2 * (n - d) * (m - 1) / n**2))
| n, m, d = list(map(int, input().split()))
if d == 0:
print(((1 * n - 2 * d) * (m - 1) / n**2))
elif n >= 2 * d:
print(((2 * n - 2 * d) * (m - 1) / n**2))
else:
print((2 * d * (m - 1) / n**2))
| false | 28.571429 | [
"- print(((m - 1) / n))",
"+ print(((1 * n - 2 * d) * (m - 1) / n**2))",
"+elif n >= 2 * d:",
"+ print(((2 * n - 2 * d) * (m - 1) / n**2))",
"- print((2 * (n - d) * (m - 1) / n**2))",
"+ print((2 * d * (m - 1) / n**2))"
]
| false | 0.085899 | 0.045743 | 1.87787 | [
"s499090660",
"s252796787"
]
|
u595905528 | p02762 | python | s879315587 | s143782782 | 1,793 | 1,598 | 55,104 | 62,528 | Accepted | Accepted | 10.88 | import sys
sys.setrecursionlimit(10**5+10)
N, M, K = list(map(int,input().split()))
class UnionFind:
def __init__(self, N):
self.par = [-1 for i in range(N+1)]
self.rank = [1]*(N+1)
def find(self, x):
if self.par[x] < 0:
return x
else:
self.par[x] = self.find(self.par[x])
return self.par[x]
def same_check(self, x, y):
return self.find(x) == self.find(y)
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if self.rank[x] > self.rank[y]:
self.par[x] += self.par[y]
self.par[y] = x
else:
self.par[y] += self.par[x]
self.par[x] = y
if self.rank[x] == self.rank[y]:
self.rank[x] += 1
UF = UnionFind(N)
friendlist = [[] for _ in range(N+1)]
for n in range(M):
A, B = list(map(int,input().split()))
friendlist[A].append(B)
friendlist[B].append(A)
if not UF.same_check(A,B):
UF.union(A, B)
blocklist = [[] for _ in range(N+1)]
for n in range(K):
C, D = list(map(int, input().split()))
blocklist[C].append(D)
blocklist[D].append(C)
for person in range(1,N+1):
root = UF.find(person)
ans = -UF.par[root]-1
ans -= len(friendlist[person])
for l in blocklist[person]:
if UF.same_check(person,l):
ans -= 1
print(ans) | def main():
import sys
sys.setrecursionlimit(10**5+10)
N, M, K = list(map(int,input().split()))
class UnionFind:
def __init__(self, N):
self.par = [-1 for i in range(N+1)]
self.rank = [1]*(N+1)
def find(self, x):
if self.par[x] < 0:
return x
else:
self.par[x] = self.find(self.par[x])
return self.par[x]
def same_check(self, x, y):
return self.find(x) == self.find(y)
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if self.rank[x] > self.rank[y]:
self.par[x] += self.par[y]
self.par[y] = x
else:
self.par[y] += self.par[x]
self.par[x] = y
if self.rank[x] == self.rank[y]:
self.rank[x] += 1
UF = UnionFind(N)
friendlist = [[] for _ in range(N+1)]
for n in range(M):
A, B = list(map(int,input().split()))
friendlist[A].append(B)
friendlist[B].append(A)
if not UF.same_check(A,B):
UF.union(A, B)
blocklist = [[] for _ in range(N+1)]
for n in range(K):
C, D = list(map(int, input().split()))
blocklist[C].append(D)
blocklist[D].append(C)
for person in range(1,N+1):
root = UF.find(person)
ans = -UF.par[root]-1
ans -= len(friendlist[person])
for l in blocklist[person]:
if UF.same_check(person,l):
ans -= 1
print(ans)
if __name__ == '__main__':
main()
| 53 | 57 | 1,451 | 1,575 | import sys
sys.setrecursionlimit(10**5 + 10)
N, M, K = list(map(int, input().split()))
class UnionFind:
def __init__(self, N):
self.par = [-1 for i in range(N + 1)]
self.rank = [1] * (N + 1)
def find(self, x):
if self.par[x] < 0:
return x
else:
self.par[x] = self.find(self.par[x])
return self.par[x]
def same_check(self, x, y):
return self.find(x) == self.find(y)
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if self.rank[x] > self.rank[y]:
self.par[x] += self.par[y]
self.par[y] = x
else:
self.par[y] += self.par[x]
self.par[x] = y
if self.rank[x] == self.rank[y]:
self.rank[x] += 1
UF = UnionFind(N)
friendlist = [[] for _ in range(N + 1)]
for n in range(M):
A, B = list(map(int, input().split()))
friendlist[A].append(B)
friendlist[B].append(A)
if not UF.same_check(A, B):
UF.union(A, B)
blocklist = [[] for _ in range(N + 1)]
for n in range(K):
C, D = list(map(int, input().split()))
blocklist[C].append(D)
blocklist[D].append(C)
for person in range(1, N + 1):
root = UF.find(person)
ans = -UF.par[root] - 1
ans -= len(friendlist[person])
for l in blocklist[person]:
if UF.same_check(person, l):
ans -= 1
print(ans)
| def main():
import sys
sys.setrecursionlimit(10**5 + 10)
N, M, K = list(map(int, input().split()))
class UnionFind:
def __init__(self, N):
self.par = [-1 for i in range(N + 1)]
self.rank = [1] * (N + 1)
def find(self, x):
if self.par[x] < 0:
return x
else:
self.par[x] = self.find(self.par[x])
return self.par[x]
def same_check(self, x, y):
return self.find(x) == self.find(y)
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if self.rank[x] > self.rank[y]:
self.par[x] += self.par[y]
self.par[y] = x
else:
self.par[y] += self.par[x]
self.par[x] = y
if self.rank[x] == self.rank[y]:
self.rank[x] += 1
UF = UnionFind(N)
friendlist = [[] for _ in range(N + 1)]
for n in range(M):
A, B = list(map(int, input().split()))
friendlist[A].append(B)
friendlist[B].append(A)
if not UF.same_check(A, B):
UF.union(A, B)
blocklist = [[] for _ in range(N + 1)]
for n in range(K):
C, D = list(map(int, input().split()))
blocklist[C].append(D)
blocklist[D].append(C)
for person in range(1, N + 1):
root = UF.find(person)
ans = -UF.par[root] - 1
ans -= len(friendlist[person])
for l in blocklist[person]:
if UF.same_check(person, l):
ans -= 1
print(ans)
if __name__ == "__main__":
main()
| false | 7.017544 | [
"-import sys",
"+def main():",
"+ import sys",
"-sys.setrecursionlimit(10**5 + 10)",
"-N, M, K = list(map(int, input().split()))",
"+ sys.setrecursionlimit(10**5 + 10)",
"+ N, M, K = list(map(int, input().split()))",
"+",
"+ class UnionFind:",
"+ def __init__(self, N):",
"+ self.par = [-1 for i in range(N + 1)]",
"+ self.rank = [1] * (N + 1)",
"+",
"+ def find(self, x):",
"+ if self.par[x] < 0:",
"+ return x",
"+ else:",
"+ self.par[x] = self.find(self.par[x])",
"+ return self.par[x]",
"+",
"+ def same_check(self, x, y):",
"+ return self.find(x) == self.find(y)",
"+",
"+ def union(self, x, y):",
"+ x = self.find(x)",
"+ y = self.find(y)",
"+ if self.rank[x] > self.rank[y]:",
"+ self.par[x] += self.par[y]",
"+ self.par[y] = x",
"+ else:",
"+ self.par[y] += self.par[x]",
"+ self.par[x] = y",
"+ if self.rank[x] == self.rank[y]:",
"+ self.rank[x] += 1",
"+",
"+ UF = UnionFind(N)",
"+ friendlist = [[] for _ in range(N + 1)]",
"+ for n in range(M):",
"+ A, B = list(map(int, input().split()))",
"+ friendlist[A].append(B)",
"+ friendlist[B].append(A)",
"+ if not UF.same_check(A, B):",
"+ UF.union(A, B)",
"+ blocklist = [[] for _ in range(N + 1)]",
"+ for n in range(K):",
"+ C, D = list(map(int, input().split()))",
"+ blocklist[C].append(D)",
"+ blocklist[D].append(C)",
"+ for person in range(1, N + 1):",
"+ root = UF.find(person)",
"+ ans = -UF.par[root] - 1",
"+ ans -= len(friendlist[person])",
"+ for l in blocklist[person]:",
"+ if UF.same_check(person, l):",
"+ ans -= 1",
"+ print(ans)",
"-class UnionFind:",
"- def __init__(self, N):",
"- self.par = [-1 for i in range(N + 1)]",
"- self.rank = [1] * (N + 1)",
"-",
"- def find(self, x):",
"- if self.par[x] < 0:",
"- return x",
"- else:",
"- self.par[x] = self.find(self.par[x])",
"- return self.par[x]",
"-",
"- def same_check(self, x, y):",
"- return self.find(x) == self.find(y)",
"-",
"- def union(self, x, y):",
"- x = self.find(x)",
"- y = self.find(y)",
"- if self.rank[x] > self.rank[y]:",
"- self.par[x] += self.par[y]",
"- self.par[y] = x",
"- else:",
"- self.par[y] += self.par[x]",
"- self.par[x] = y",
"- if self.rank[x] == self.rank[y]:",
"- self.rank[x] += 1",
"-",
"-",
"-UF = UnionFind(N)",
"-friendlist = [[] for _ in range(N + 1)]",
"-for n in range(M):",
"- A, B = list(map(int, input().split()))",
"- friendlist[A].append(B)",
"- friendlist[B].append(A)",
"- if not UF.same_check(A, B):",
"- UF.union(A, B)",
"-blocklist = [[] for _ in range(N + 1)]",
"-for n in range(K):",
"- C, D = list(map(int, input().split()))",
"- blocklist[C].append(D)",
"- blocklist[D].append(C)",
"-for person in range(1, N + 1):",
"- root = UF.find(person)",
"- ans = -UF.par[root] - 1",
"- ans -= len(friendlist[person])",
"- for l in blocklist[person]:",
"- if UF.same_check(person, l):",
"- ans -= 1",
"- print(ans)",
"+if __name__ == \"__main__\":",
"+ main()"
]
| false | 0.039176 | 0.047651 | 0.822138 | [
"s879315587",
"s143782782"
]
|
u254871849 | p03608 | python | s391354311 | s282336208 | 367 | 337 | 26,820 | 27,720 | Accepted | Accepted | 8.17 | import sys
import numpy as np
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix
from itertools import permutations
I = np.array(sys.stdin.read().split(), dtype=np.int64)
n, m, R = I[:3]
r = I[3:3+R] - 1
a, b, c = I[3+R:].reshape(-1, 3).T
a -= 1; b -= 1
graph = csr_matrix((c, (a, b)), shape=(n, n))
def main():
dist = floyd_warshall(graph, directed=False).astype(np.int64)
*perms, = permutations(r)
perms = np.array(perms)
res = dist[perms[:, :-1], perms[:, 1:]]
ans = np.amin(np.sum(res, axis=1))
return ans
if __name__ == '__main__':
ans = main()
print(ans) | import sys
import numpy as np
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix
from itertools import permutations
I = np.array(sys.stdin.read().split(), dtype=np.int64)
n, m, R = I[:3]
r = I[3:3+R] - 1
a, b, c = I[3+R:].reshape(-1, 3).T
graph = csr_matrix((c, (a-1, b-1)), shape=(n, n))
def main():
dist = floyd_warshall(graph, directed=False).astype(np.int64)
perms = np.array(list(permutations(r)))
res = dist[perms[:, :-1], perms[:, 1:]]
ans = np.amin(np.sum(res, axis=1))
return ans
if __name__ == '__main__':
ans = main()
print(ans) | 24 | 23 | 652 | 631 | import sys
import numpy as np
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix
from itertools import permutations
I = np.array(sys.stdin.read().split(), dtype=np.int64)
n, m, R = I[:3]
r = I[3 : 3 + R] - 1
a, b, c = I[3 + R :].reshape(-1, 3).T
a -= 1
b -= 1
graph = csr_matrix((c, (a, b)), shape=(n, n))
def main():
dist = floyd_warshall(graph, directed=False).astype(np.int64)
(*perms,) = permutations(r)
perms = np.array(perms)
res = dist[perms[:, :-1], perms[:, 1:]]
ans = np.amin(np.sum(res, axis=1))
return ans
if __name__ == "__main__":
ans = main()
print(ans)
| import sys
import numpy as np
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix
from itertools import permutations
I = np.array(sys.stdin.read().split(), dtype=np.int64)
n, m, R = I[:3]
r = I[3 : 3 + R] - 1
a, b, c = I[3 + R :].reshape(-1, 3).T
graph = csr_matrix((c, (a - 1, b - 1)), shape=(n, n))
def main():
dist = floyd_warshall(graph, directed=False).astype(np.int64)
perms = np.array(list(permutations(r)))
res = dist[perms[:, :-1], perms[:, 1:]]
ans = np.amin(np.sum(res, axis=1))
return ans
if __name__ == "__main__":
ans = main()
print(ans)
| false | 4.166667 | [
"-a -= 1",
"-b -= 1",
"-graph = csr_matrix((c, (a, b)), shape=(n, n))",
"+graph = csr_matrix((c, (a - 1, b - 1)), shape=(n, n))",
"- (*perms,) = permutations(r)",
"- perms = np.array(perms)",
"+ perms = np.array(list(permutations(r)))"
]
| false | 0.27651 | 0.385003 | 0.718203 | [
"s391354311",
"s282336208"
]
|
u094191970 | p03608 | python | s220785932 | s342108288 | 713 | 596 | 23,420 | 15,376 | Accepted | Accepted | 16.41 | import itertools
from scipy.sparse.csgraph import floyd_warshall
n,m,r=list(map(int,input().split()))
r_l=list(map(int,input().split()))
l=[list(map(int,input().split())) for i in range(m)]
d=[[float('inf')]*n for i in range(n)]
for i in range(n):
d[i][i]=0
for i in l:
d[i[0]-1][i[1]-1]=i[2]
d[i[1]-1][i[0]-1]=i[2]
d=floyd_warshall(d)
ans=10**9
for i in itertools.permutations(r_l):
t_ans=0
for j in range(len(i)-1):
t_ans+=d[i[j]-1][i[j+1]-1]
ans=min(ans,t_ans)
print((int(ans))) | from scipy.sparse.csgraph import floyd_warshall
from itertools import permutations
from sys import stdin
nii=lambda:list(map(int,stdin.readline().split()))
n,m,r=nii()
r=list(nii())
s=[[float('inf')]*n for i in range(n)]
for i in range(n):
for j in range(n):
s[i][j]=0
for i in range(m):
a,b,c=nii()
a-=1
b-=1
s[a][b]=c
s[b][a]=c
ws=floyd_warshall(s)
ans=10**9
for i in permutations(r):
t_ans=0
for j in range(1,len(i)):
t_ans+=ws[i[j-1]-1][i[j]-1]
ans=min(ans,t_ans)
print((int(ans))) | 22 | 28 | 529 | 534 | import itertools
from scipy.sparse.csgraph import floyd_warshall
n, m, r = list(map(int, input().split()))
r_l = list(map(int, input().split()))
l = [list(map(int, input().split())) for i in range(m)]
d = [[float("inf")] * n for i in range(n)]
for i in range(n):
d[i][i] = 0
for i in l:
d[i[0] - 1][i[1] - 1] = i[2]
d[i[1] - 1][i[0] - 1] = i[2]
d = floyd_warshall(d)
ans = 10**9
for i in itertools.permutations(r_l):
t_ans = 0
for j in range(len(i) - 1):
t_ans += d[i[j] - 1][i[j + 1] - 1]
ans = min(ans, t_ans)
print((int(ans)))
| from scipy.sparse.csgraph import floyd_warshall
from itertools import permutations
from sys import stdin
nii = lambda: list(map(int, stdin.readline().split()))
n, m, r = nii()
r = list(nii())
s = [[float("inf")] * n for i in range(n)]
for i in range(n):
for j in range(n):
s[i][j] = 0
for i in range(m):
a, b, c = nii()
a -= 1
b -= 1
s[a][b] = c
s[b][a] = c
ws = floyd_warshall(s)
ans = 10**9
for i in permutations(r):
t_ans = 0
for j in range(1, len(i)):
t_ans += ws[i[j - 1] - 1][i[j] - 1]
ans = min(ans, t_ans)
print((int(ans)))
| false | 21.428571 | [
"-import itertools",
"+from itertools import permutations",
"+from sys import stdin",
"-n, m, r = list(map(int, input().split()))",
"-r_l = list(map(int, input().split()))",
"-l = [list(map(int, input().split())) for i in range(m)]",
"-d = [[float(\"inf\")] * n for i in range(n)]",
"+nii = lambda: list(map(int, stdin.readline().split()))",
"+n, m, r = nii()",
"+r = list(nii())",
"+s = [[float(\"inf\")] * n for i in range(n)]",
"- d[i][i] = 0",
"-for i in l:",
"- d[i[0] - 1][i[1] - 1] = i[2]",
"- d[i[1] - 1][i[0] - 1] = i[2]",
"-d = floyd_warshall(d)",
"+ for j in range(n):",
"+ s[i][j] = 0",
"+for i in range(m):",
"+ a, b, c = nii()",
"+ a -= 1",
"+ b -= 1",
"+ s[a][b] = c",
"+ s[b][a] = c",
"+ws = floyd_warshall(s)",
"-for i in itertools.permutations(r_l):",
"+for i in permutations(r):",
"- for j in range(len(i) - 1):",
"- t_ans += d[i[j] - 1][i[j + 1] - 1]",
"+ for j in range(1, len(i)):",
"+ t_ans += ws[i[j - 1] - 1][i[j] - 1]"
]
| false | 0.264673 | 0.315044 | 0.840115 | [
"s220785932",
"s342108288"
]
|
u260216890 | p03061 | python | s179673879 | s556184124 | 1,952 | 394 | 14,672 | 98,280 | Accepted | Accepted | 79.82 | n=int(eval(input()))
A=list(map(int,input().split()))
#####単位元######
ide_ele = 0
#num:n以上の最小の2のべき乗
num=2**(n-1).bit_length()
seg=[ide_ele]*2*num
from fractions import gcd
def segfunc(x,y):
return gcd(x,y)
def init(init_val):
#set_val
for i in range(n):
seg[i+num-1]=init_val[i]
#built
for i in range(num-2,-1,-1) :
seg[i]=segfunc(seg[2*i+1],seg[2*i+2])
def update(k,x):
k += num-1
seg[k] = x
while k:
k = (k-1)//2
seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
def query(p,q):
if q<=p:
return ide_ele
p += num-1
q += num-2
res=ide_ele
while q-p>1:
if p&1 == 0:
res = segfunc(res,seg[p])
if q&1 == 1:
res = segfunc(res,seg[q])
q -= 1
p = p//2
q = (q-1)//2
if p == q:
res = segfunc(res,seg[p])
else:
res = segfunc(segfunc(res,seg[p]),seg[q])
return res
init(A)
ans=-1
for i in range(n):
ans=max(ans, gcd(query(0,i),query(i+1,n)))
print(ans) | n=int(eval(input()))
a=list(map(int,input().split()))
from fractions import gcd
L=[0]
R=[]
l=a[0]
r=a[-1]
for i in range(n-1):
l=gcd(a[i], l)
L.append(l)
r=gcd(a[-i-1], r)
R.append(r)
R=R[::-1]
R.append(0)
M=[]
#print(L,R)
for i in range(n):
m=gcd(L[i],R[i])
M.append(m)
print((max(M))) | 55 | 20 | 1,093 | 321 | n = int(eval(input()))
A = list(map(int, input().split()))
#####単位元######
ide_ele = 0
# num:n以上の最小の2のべき乗
num = 2 ** (n - 1).bit_length()
seg = [ide_ele] * 2 * num
from fractions import gcd
def segfunc(x, y):
return gcd(x, y)
def init(init_val):
# set_val
for i in range(n):
seg[i + num - 1] = init_val[i]
# built
for i in range(num - 2, -1, -1):
seg[i] = segfunc(seg[2 * i + 1], seg[2 * i + 2])
def update(k, x):
k += num - 1
seg[k] = x
while k:
k = (k - 1) // 2
seg[k] = segfunc(seg[k * 2 + 1], seg[k * 2 + 2])
def query(p, q):
if q <= p:
return ide_ele
p += num - 1
q += num - 2
res = ide_ele
while q - p > 1:
if p & 1 == 0:
res = segfunc(res, seg[p])
if q & 1 == 1:
res = segfunc(res, seg[q])
q -= 1
p = p // 2
q = (q - 1) // 2
if p == q:
res = segfunc(res, seg[p])
else:
res = segfunc(segfunc(res, seg[p]), seg[q])
return res
init(A)
ans = -1
for i in range(n):
ans = max(ans, gcd(query(0, i), query(i + 1, n)))
print(ans)
| n = int(eval(input()))
a = list(map(int, input().split()))
from fractions import gcd
L = [0]
R = []
l = a[0]
r = a[-1]
for i in range(n - 1):
l = gcd(a[i], l)
L.append(l)
r = gcd(a[-i - 1], r)
R.append(r)
R = R[::-1]
R.append(0)
M = []
# print(L,R)
for i in range(n):
m = gcd(L[i], R[i])
M.append(m)
print((max(M)))
| false | 63.636364 | [
"-A = list(map(int, input().split()))",
"-#####単位元######",
"-ide_ele = 0",
"-# num:n以上の最小の2のべき乗",
"-num = 2 ** (n - 1).bit_length()",
"-seg = [ide_ele] * 2 * num",
"+a = list(map(int, input().split()))",
"-",
"-def segfunc(x, y):",
"- return gcd(x, y)",
"-",
"-",
"-def init(init_val):",
"- # set_val",
"- for i in range(n):",
"- seg[i + num - 1] = init_val[i]",
"- # built",
"- for i in range(num - 2, -1, -1):",
"- seg[i] = segfunc(seg[2 * i + 1], seg[2 * i + 2])",
"-",
"-",
"-def update(k, x):",
"- k += num - 1",
"- seg[k] = x",
"- while k:",
"- k = (k - 1) // 2",
"- seg[k] = segfunc(seg[k * 2 + 1], seg[k * 2 + 2])",
"-",
"-",
"-def query(p, q):",
"- if q <= p:",
"- return ide_ele",
"- p += num - 1",
"- q += num - 2",
"- res = ide_ele",
"- while q - p > 1:",
"- if p & 1 == 0:",
"- res = segfunc(res, seg[p])",
"- if q & 1 == 1:",
"- res = segfunc(res, seg[q])",
"- q -= 1",
"- p = p // 2",
"- q = (q - 1) // 2",
"- if p == q:",
"- res = segfunc(res, seg[p])",
"- else:",
"- res = segfunc(segfunc(res, seg[p]), seg[q])",
"- return res",
"-",
"-",
"-init(A)",
"-ans = -1",
"+L = [0]",
"+R = []",
"+l = a[0]",
"+r = a[-1]",
"+for i in range(n - 1):",
"+ l = gcd(a[i], l)",
"+ L.append(l)",
"+ r = gcd(a[-i - 1], r)",
"+ R.append(r)",
"+R = R[::-1]",
"+R.append(0)",
"+M = []",
"+# print(L,R)",
"- ans = max(ans, gcd(query(0, i), query(i + 1, n)))",
"-print(ans)",
"+ m = gcd(L[i], R[i])",
"+ M.append(m)",
"+print((max(M)))"
]
| false | 0.052213 | 0.052755 | 0.989724 | [
"s179673879",
"s556184124"
]
|
u116002573 | p02952 | python | s625736210 | s041993592 | 61 | 51 | 2,940 | 2,940 | Accepted | Accepted | 16.39 | N = int(eval(input()))
count = 0
for i in range(1, N+1):
s = str(i)
if len(s) % 2 == 1:
count += 1
print(count) | def main():
N = int(eval(input()))
ans = 0
for i in range(1, N+1):
s = str(i)
if(len(s) % 2 == 1): ans +=1
return ans
if __name__ == '__main__':
print((main())) | 8 | 12 | 129 | 202 | N = int(eval(input()))
count = 0
for i in range(1, N + 1):
s = str(i)
if len(s) % 2 == 1:
count += 1
print(count)
| def main():
N = int(eval(input()))
ans = 0
for i in range(1, N + 1):
s = str(i)
if len(s) % 2 == 1:
ans += 1
return ans
if __name__ == "__main__":
print((main()))
| false | 33.333333 | [
"-N = int(eval(input()))",
"-count = 0",
"-for i in range(1, N + 1):",
"- s = str(i)",
"- if len(s) % 2 == 1:",
"- count += 1",
"-print(count)",
"+def main():",
"+ N = int(eval(input()))",
"+ ans = 0",
"+ for i in range(1, N + 1):",
"+ s = str(i)",
"+ if len(s) % 2 == 1:",
"+ ans += 1",
"+ return ans",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ print((main()))"
]
| false | 0.053884 | 0.173166 | 0.311172 | [
"s625736210",
"s041993592"
]
|
u990900604 | p02264 | python | s361164309 | s124770049 | 750 | 430 | 25,152 | 28,292 | Accepted | Accepted | 42.67 | #!/usr/bin/env python
#-*- coding: utf-8 -*-
class Queue:
def __init__(self):
self.l = []
def enqueue(self, x):
self.l.append(x)
def dequeue(self):
x = self.l[0]
del self.l[0]
return x
def is_empty(self):
return len(self.l) == 0
class Process:
def __init__(self, name, time):
self.name = name
self.time = time
if __name__ == '__main__':
n, q = list(map(int, input().split()))
Q = Queue()
i = 0
while i != n:
tmp = input().split()
Q.enqueue(Process(tmp[0], int(tmp[1])))
i += 1
cnt = 0
while not Q.is_empty():
p = Q.dequeue()
if p.time > q:
p.time -= q
cnt += q
Q.enqueue(p)
else:
cnt += p.time
print(p.name, cnt)
|
class Queue:
def __init__(self, n):
self.A = [0 for i in range(n)]
self.head = 0
self.tail = 0
self.len = n
def is_empty(self):
return self.head == self.tail
def is_full(self):
return (self.tail + 1) % self.len == self.head
def enqueue(self, x):
if not self.is_full():
self.A[self.tail] = x
self.tail += 1
if self.tail == self.len:
self.tail = 0
def dequeue(self):
if not self.is_empty():
x = self.A[self.head]
self.head += 1
if self.head == self.len:
self.head = 0
return x
class Task:
def __init__(self, name, time):
self.name = name
self.time = time
if __name__ == '__main__':
Q = Queue(100005)
n, q = list(map(int, input().split()))
for i in range(n):
l = input().split()
t = Task(l[0], int(l[1]))
Q.enqueue(t)
cnt = 0
while not Q.is_empty():
t = Q.dequeue()
if t.time > q:
cnt += q
t.time -= q
Q.enqueue(t)
else:
cnt += t.time
print(t.name, cnt)
pass
| 44 | 56 | 882 | 1,275 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
class Queue:
def __init__(self):
self.l = []
def enqueue(self, x):
self.l.append(x)
def dequeue(self):
x = self.l[0]
del self.l[0]
return x
def is_empty(self):
return len(self.l) == 0
class Process:
def __init__(self, name, time):
self.name = name
self.time = time
if __name__ == "__main__":
n, q = list(map(int, input().split()))
Q = Queue()
i = 0
while i != n:
tmp = input().split()
Q.enqueue(Process(tmp[0], int(tmp[1])))
i += 1
cnt = 0
while not Q.is_empty():
p = Q.dequeue()
if p.time > q:
p.time -= q
cnt += q
Q.enqueue(p)
else:
cnt += p.time
print(p.name, cnt)
| class Queue:
def __init__(self, n):
self.A = [0 for i in range(n)]
self.head = 0
self.tail = 0
self.len = n
def is_empty(self):
return self.head == self.tail
def is_full(self):
return (self.tail + 1) % self.len == self.head
def enqueue(self, x):
if not self.is_full():
self.A[self.tail] = x
self.tail += 1
if self.tail == self.len:
self.tail = 0
def dequeue(self):
if not self.is_empty():
x = self.A[self.head]
self.head += 1
if self.head == self.len:
self.head = 0
return x
class Task:
def __init__(self, name, time):
self.name = name
self.time = time
if __name__ == "__main__":
Q = Queue(100005)
n, q = list(map(int, input().split()))
for i in range(n):
l = input().split()
t = Task(l[0], int(l[1]))
Q.enqueue(t)
cnt = 0
while not Q.is_empty():
t = Q.dequeue()
if t.time > q:
cnt += q
t.time -= q
Q.enqueue(t)
else:
cnt += t.time
print(t.name, cnt)
pass
| false | 21.428571 | [
"-#!/usr/bin/env python",
"-# -*- coding: utf-8 -*-",
"- def __init__(self):",
"- self.l = []",
"+ def __init__(self, n):",
"+ self.A = [0 for i in range(n)]",
"+ self.head = 0",
"+ self.tail = 0",
"+ self.len = n",
"+",
"+ def is_empty(self):",
"+ return self.head == self.tail",
"+",
"+ def is_full(self):",
"+ return (self.tail + 1) % self.len == self.head",
"- self.l.append(x)",
"+ if not self.is_full():",
"+ self.A[self.tail] = x",
"+ self.tail += 1",
"+ if self.tail == self.len:",
"+ self.tail = 0",
"- x = self.l[0]",
"- del self.l[0]",
"- return x",
"-",
"- def is_empty(self):",
"- return len(self.l) == 0",
"+ if not self.is_empty():",
"+ x = self.A[self.head]",
"+ self.head += 1",
"+ if self.head == self.len:",
"+ self.head = 0",
"+ return x",
"-class Process:",
"+class Task:",
"+ Q = Queue(100005)",
"- Q = Queue()",
"- i = 0",
"- while i != n:",
"- tmp = input().split()",
"- Q.enqueue(Process(tmp[0], int(tmp[1])))",
"- i += 1",
"+ for i in range(n):",
"+ l = input().split()",
"+ t = Task(l[0], int(l[1]))",
"+ Q.enqueue(t)",
"- p = Q.dequeue()",
"- if p.time > q:",
"- p.time -= q",
"+ t = Q.dequeue()",
"+ if t.time > q:",
"- Q.enqueue(p)",
"+ t.time -= q",
"+ Q.enqueue(t)",
"- cnt += p.time",
"- print(p.name, cnt)",
"+ cnt += t.time",
"+ print(t.name, cnt)",
"+ pass"
]
| false | 0.093164 | 0.077838 | 1.196902 | [
"s361164309",
"s124770049"
]
|
u413165887 | p02852 | python | s834805896 | s881326438 | 240 | 141 | 51,676 | 10,560 | Accepted | Accepted | 41.25 | n, m = list(map(int, input().split()))
s = eval(input())
dp = [-1 for _i in range(n+1)]
dp[0] = 0
f = 0
from collections import deque
q = deque([0])
c = 0
for i in range(1, n+1):
if s[i]=="0":
c = 0
while i-f > m:
f = q.popleft()
dp[i] = f
q.append(i)
else:
c += 1
if c >= m:
break
if dp[n] >= 0:
r = []
p = n
while p > 0:
nex = dp[p]
r.append(p-nex)
p = nex
print((*r[::-1]))
else:
print((-1)) | n, m = list(map(int, input().split()))
s = eval(input())
dp = [-1 for _i in range(n+1)]
dp[0] = 0
f = 0
from collections import deque
q = deque([0])
c = 0
for i in range(1, n+1):
if s[i]=="0":
c = 0
while i-f > m:
f = q.popleft()
dp[i] = f
q.append(i)
elif c < m-1:
c += 1
else:
break
if dp[n] >= 0:
r = []
p = n
while p > 0:
nex = dp[p]
r.append(p-nex)
p = nex
print((*r[::-1]))
else:
print((-1)) | 30 | 30 | 532 | 527 | n, m = list(map(int, input().split()))
s = eval(input())
dp = [-1 for _i in range(n + 1)]
dp[0] = 0
f = 0
from collections import deque
q = deque([0])
c = 0
for i in range(1, n + 1):
if s[i] == "0":
c = 0
while i - f > m:
f = q.popleft()
dp[i] = f
q.append(i)
else:
c += 1
if c >= m:
break
if dp[n] >= 0:
r = []
p = n
while p > 0:
nex = dp[p]
r.append(p - nex)
p = nex
print((*r[::-1]))
else:
print((-1))
| n, m = list(map(int, input().split()))
s = eval(input())
dp = [-1 for _i in range(n + 1)]
dp[0] = 0
f = 0
from collections import deque
q = deque([0])
c = 0
for i in range(1, n + 1):
if s[i] == "0":
c = 0
while i - f > m:
f = q.popleft()
dp[i] = f
q.append(i)
elif c < m - 1:
c += 1
else:
break
if dp[n] >= 0:
r = []
p = n
while p > 0:
nex = dp[p]
r.append(p - nex)
p = nex
print((*r[::-1]))
else:
print((-1))
| false | 0 | [
"+ elif c < m - 1:",
"+ c += 1",
"- c += 1",
"- if c >= m:",
"- break",
"+ break"
]
| false | 0.0436 | 0.121393 | 0.359167 | [
"s834805896",
"s881326438"
]
|
u254871849 | p03488 | python | s558434588 | s998471373 | 1,197 | 656 | 3,444 | 3,188 | Accepted | Accepted | 45.2 | import sys
s = sys.stdin.readline().rstrip()
x, y = list(map(int, sys.stdin.readline().split()))
def reachable(deltas, goal):
if not deltas:
if goal == 0:
return True
else:
return False
s = sum(deltas)
if goal < -s or s < goal:
return False
res = [False] * (s * 2 + 1)
res[s] = True
for d in deltas:
prev = res.copy()
res = [False] * (s * 2 + 1)
for i in range(s*2+1):
if prev[i]:
res[i+d] = res[i-d] = True
return res[s + goal]
def main():
gx = x; gy = y
dx = []
dy = []
direction = 0
origin_x = 0
for i in s:
if i == 'T':
break
origin_x += 1
gx -= origin_x
tmp = 0
for i in s[origin_x:] + 'T':
if i == 'T':
if direction == 0:
if tmp != 0:
dx.append(tmp)
direction = 1
else:
if tmp != 0:
dy.append(tmp)
direction = 0
tmp = 0
else:
tmp += 1
return 'Yes' if reachable(dx, gx) & reachable(dy, gy) else 'No'
if __name__ == '__main__':
ans = main()
print(ans) | import sys
s = sys.stdin.readline().rstrip()
x, y = list(map(int, sys.stdin.readline().split()))
def reachable(deltas, goal):
if not deltas:
if goal == 0:
return True
else:
return False
s = sum(deltas)
if goal < -s or s < goal:
return False
if (s - goal) & 1:
return False
a = (s - goal) // 2
res = [False] * (a + 1)
res[0] = True
for d in deltas:
for i in range(a, -1, -1):
if res[i] and i + d <= a:
res[i+d] = True
return res[a]
def main():
gx = x; gy = y
dx = []
dy = []
direction = 0
origin_x = 0
for i in s:
if i == 'T':
break
origin_x += 1
gx -= origin_x
tmp = 0
for i in s[origin_x:] + 'T':
if i == 'T':
if direction == 0:
if tmp != 0:
dx.append(tmp)
direction = 1
else:
if tmp != 0:
dy.append(tmp)
direction = 0
tmp = 0
else:
tmp += 1
return 'Yes' if reachable(dx, gx) & reachable(dy, gy) else 'No'
if __name__ == '__main__':
ans = main()
print(ans) | 62 | 63 | 1,307 | 1,305 | import sys
s = sys.stdin.readline().rstrip()
x, y = list(map(int, sys.stdin.readline().split()))
def reachable(deltas, goal):
if not deltas:
if goal == 0:
return True
else:
return False
s = sum(deltas)
if goal < -s or s < goal:
return False
res = [False] * (s * 2 + 1)
res[s] = True
for d in deltas:
prev = res.copy()
res = [False] * (s * 2 + 1)
for i in range(s * 2 + 1):
if prev[i]:
res[i + d] = res[i - d] = True
return res[s + goal]
def main():
gx = x
gy = y
dx = []
dy = []
direction = 0
origin_x = 0
for i in s:
if i == "T":
break
origin_x += 1
gx -= origin_x
tmp = 0
for i in s[origin_x:] + "T":
if i == "T":
if direction == 0:
if tmp != 0:
dx.append(tmp)
direction = 1
else:
if tmp != 0:
dy.append(tmp)
direction = 0
tmp = 0
else:
tmp += 1
return "Yes" if reachable(dx, gx) & reachable(dy, gy) else "No"
if __name__ == "__main__":
ans = main()
print(ans)
| import sys
s = sys.stdin.readline().rstrip()
x, y = list(map(int, sys.stdin.readline().split()))
def reachable(deltas, goal):
if not deltas:
if goal == 0:
return True
else:
return False
s = sum(deltas)
if goal < -s or s < goal:
return False
if (s - goal) & 1:
return False
a = (s - goal) // 2
res = [False] * (a + 1)
res[0] = True
for d in deltas:
for i in range(a, -1, -1):
if res[i] and i + d <= a:
res[i + d] = True
return res[a]
def main():
gx = x
gy = y
dx = []
dy = []
direction = 0
origin_x = 0
for i in s:
if i == "T":
break
origin_x += 1
gx -= origin_x
tmp = 0
for i in s[origin_x:] + "T":
if i == "T":
if direction == 0:
if tmp != 0:
dx.append(tmp)
direction = 1
else:
if tmp != 0:
dy.append(tmp)
direction = 0
tmp = 0
else:
tmp += 1
return "Yes" if reachable(dx, gx) & reachable(dy, gy) else "No"
if __name__ == "__main__":
ans = main()
print(ans)
| false | 1.587302 | [
"- res = [False] * (s * 2 + 1)",
"- res[s] = True",
"+ if (s - goal) & 1:",
"+ return False",
"+ a = (s - goal) // 2",
"+ res = [False] * (a + 1)",
"+ res[0] = True",
"- prev = res.copy()",
"- res = [False] * (s * 2 + 1)",
"- for i in range(s * 2 + 1):",
"- if prev[i]:",
"- res[i + d] = res[i - d] = True",
"- return res[s + goal]",
"+ for i in range(a, -1, -1):",
"+ if res[i] and i + d <= a:",
"+ res[i + d] = True",
"+ return res[a]"
]
| false | 0.039172 | 0.046853 | 0.836063 | [
"s558434588",
"s998471373"
]
|
u620084012 | p03986 | python | s245399741 | s542048062 | 186 | 70 | 46,944 | 67,016 | Accepted | Accepted | 62.37 | from collections import deque
X = eval(input())
L = deque([])
for e in X:
if e == "T" and len(L) > 0 and L[-1] == "S":
L.pop()
else:
L.append(e)
print((len(L)))
| X = eval(input())
N = len(X)
c = 0
s, t = 0, 0
for k in range(N):
if X[k] == "S":
s += 1
else:
t += 1
if s > 0 and t > 0:
s -= 1
t -= 1
c += 2
print((N-c))
| 10 | 14 | 187 | 229 | from collections import deque
X = eval(input())
L = deque([])
for e in X:
if e == "T" and len(L) > 0 and L[-1] == "S":
L.pop()
else:
L.append(e)
print((len(L)))
| X = eval(input())
N = len(X)
c = 0
s, t = 0, 0
for k in range(N):
if X[k] == "S":
s += 1
else:
t += 1
if s > 0 and t > 0:
s -= 1
t -= 1
c += 2
print((N - c))
| false | 28.571429 | [
"-from collections import deque",
"-",
"-L = deque([])",
"-for e in X:",
"- if e == \"T\" and len(L) > 0 and L[-1] == \"S\":",
"- L.pop()",
"+N = len(X)",
"+c = 0",
"+s, t = 0, 0",
"+for k in range(N):",
"+ if X[k] == \"S\":",
"+ s += 1",
"- L.append(e)",
"-print((len(L)))",
"+ t += 1",
"+ if s > 0 and t > 0:",
"+ s -= 1",
"+ t -= 1",
"+ c += 2",
"+print((N - c))"
]
| false | 0.046199 | 0.045633 | 1.012391 | [
"s245399741",
"s542048062"
]
|
u840579553 | p02720 | python | s895825291 | s544279875 | 509 | 187 | 100,316 | 40,688 | Accepted | Accepted | 63.26 | """
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np
inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
nx = j + dx; ny = i + dy
if 0 <= nx < w and 0 <= ny < h:'''
"""
from collections import defaultdict
import sys
sys.setrecursionlimit(10 ** 7)
def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def ws(): return sys.stdin.readline().split()
def si(): return int(sys.stdin.readline()) # SingleInt
def ss(): return eval(input())
def hi(n): return [si() for _ in range(n)]
def hs(n): return [ss() for _ in range(n)] # HeightString
def s_list(): return list(eval(input()))
def mi(n): return [wi() for _ in range(n)] # MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
0]] for _ in range(n)] # NumberGrid
def grid(n): return [s_list() for _ in range(n)]
def gcd(a, b):
while b:
a, b = b, a % b
return a
def round_up(a, b):
""" a/b の切り上げ """
c = (a + b - 1) / b
return c
def lcm(a, b):
"""a,bの最小公倍数"""
return a * b // gcd(a, b)
def floor(a, b):
"""floor(a/b) 整数値を返す"""
c = (a - a % b)/b
return int(c)
def main():
def dfs(x):
lunlun.append(x)
d = x % 10
if len(str(x)) == 11:
return
for v in [d+1, d, d-1]:
if 0 <= v <= 9:
dfs(x*10+v)
K = int(eval(input()))
cnt = 0
lunlun = []
for i in range(1, 10):
dfs(i)
lunlun.sort()
print((lunlun[K-1]))
if __name__ == '__main__':
main()
| """
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np
inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
nx = j + dx; ny = i + dy
if 0 <= nx < w and 0 <= ny < h:'''
"""
from collections import deque
import sys
sys.setrecursionlimit(10 ** 7)
def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def ws(): return sys.stdin.readline().split()
def si(): return int(sys.stdin.readline()) # SingleInt
def ss(): return eval(input())
def hi(n): return [si() for _ in range(n)]
def hs(n): return [ss() for _ in range(n)] # HeightString
def s_list(): return list(eval(input()))
def mi(n): return [wi() for _ in range(n)] # MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
0]] for _ in range(n)] # NumberGrid
def grid(n): return [s_list() for _ in range(n)]
def gcd(a, b):
while b:
a, b = b, a % b
return a
def round_up(a, b):
""" a/b の切り上げ """
c = (a + b - 1) / b
return c
def lcm(a, b):
"""a,bの最小公倍数"""
return a * b // gcd(a, b)
def floor(a, b):
"""floor(a/b) 整数値を返す"""
c = (a - a % b)/b
return int(c)
def main():
K = int(eval(input()))
q = deque()
for i in range(1, 10):
q.append(i)
cnt = 9
if cnt >= K:
print((q[K-1]))
sys.exit()
while cnt < K:
x = q.popleft()
d = x % 10
for v in [d-1, d, d+1]:
if 0 <= v <= 9:
y = x*10 + v
q.append(y)
cnt += 1
if cnt == K:
break
print(y)
if __name__ == '__main__':
main()
| 127 | 127 | 2,421 | 2,508 | """
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np
inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
nx = j + dx; ny = i + dy
if 0 <= nx < w and 0 <= ny < h:'''
"""
from collections import defaultdict
import sys
sys.setrecursionlimit(10**7)
def wi():
return list(map(int, sys.stdin.readline().split()))
# WideIntPoint
def wip():
return [int(x) - 1 for x in sys.stdin.readline().split()]
def ws():
return sys.stdin.readline().split()
def si():
return int(sys.stdin.readline()) # SingleInt
def ss():
return eval(input())
def hi(n):
return [si() for _ in range(n)]
def hs(n):
return [ss() for _ in range(n)] # HeightString
def s_list():
return list(eval(input()))
def mi(n):
return [wi() for _ in range(n)] # MatrixInt
def mip(n):
return [wip() for _ in range(n)]
def ms(n):
return [ws() for _ in range(n)]
def num_grid(n):
return [
[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)
] # NumberGrid
def grid(n):
return [s_list() for _ in range(n)]
def gcd(a, b):
while b:
a, b = b, a % b
return a
def round_up(a, b):
"""a/b の切り上げ"""
c = (a + b - 1) / b
return c
def lcm(a, b):
"""a,bの最小公倍数"""
return a * b // gcd(a, b)
def floor(a, b):
"""floor(a/b) 整数値を返す"""
c = (a - a % b) / b
return int(c)
def main():
def dfs(x):
lunlun.append(x)
d = x % 10
if len(str(x)) == 11:
return
for v in [d + 1, d, d - 1]:
if 0 <= v <= 9:
dfs(x * 10 + v)
K = int(eval(input()))
cnt = 0
lunlun = []
for i in range(1, 10):
dfs(i)
lunlun.sort()
print((lunlun[K - 1]))
if __name__ == "__main__":
main()
| """
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np
inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
nx = j + dx; ny = i + dy
if 0 <= nx < w and 0 <= ny < h:'''
"""
from collections import deque
import sys
sys.setrecursionlimit(10**7)
def wi():
return list(map(int, sys.stdin.readline().split()))
# WideIntPoint
def wip():
return [int(x) - 1 for x in sys.stdin.readline().split()]
def ws():
return sys.stdin.readline().split()
def si():
return int(sys.stdin.readline()) # SingleInt
def ss():
return eval(input())
def hi(n):
return [si() for _ in range(n)]
def hs(n):
return [ss() for _ in range(n)] # HeightString
def s_list():
return list(eval(input()))
def mi(n):
return [wi() for _ in range(n)] # MatrixInt
def mip(n):
return [wip() for _ in range(n)]
def ms(n):
return [ws() for _ in range(n)]
def num_grid(n):
return [
[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)
] # NumberGrid
def grid(n):
return [s_list() for _ in range(n)]
def gcd(a, b):
while b:
a, b = b, a % b
return a
def round_up(a, b):
"""a/b の切り上げ"""
c = (a + b - 1) / b
return c
def lcm(a, b):
"""a,bの最小公倍数"""
return a * b // gcd(a, b)
def floor(a, b):
"""floor(a/b) 整数値を返す"""
c = (a - a % b) / b
return int(c)
def main():
K = int(eval(input()))
q = deque()
for i in range(1, 10):
q.append(i)
cnt = 9
if cnt >= K:
print((q[K - 1]))
sys.exit()
while cnt < K:
x = q.popleft()
d = x % 10
for v in [d - 1, d, d + 1]:
if 0 <= v <= 9:
y = x * 10 + v
q.append(y)
cnt += 1
if cnt == K:
break
print(y)
if __name__ == "__main__":
main()
| false | 0 | [
"-from collections import defaultdict",
"+from collections import deque",
"- def dfs(x):",
"- lunlun.append(x)",
"+ K = int(eval(input()))",
"+ q = deque()",
"+ for i in range(1, 10):",
"+ q.append(i)",
"+ cnt = 9",
"+ if cnt >= K:",
"+ print((q[K - 1]))",
"+ sys.exit()",
"+ while cnt < K:",
"+ x = q.popleft()",
"- if len(str(x)) == 11:",
"- return",
"- for v in [d + 1, d, d - 1]:",
"+ for v in [d - 1, d, d + 1]:",
"- dfs(x * 10 + v)",
"-",
"- K = int(eval(input()))",
"- cnt = 0",
"- lunlun = []",
"- for i in range(1, 10):",
"- dfs(i)",
"- lunlun.sort()",
"- print((lunlun[K - 1]))",
"+ y = x * 10 + v",
"+ q.append(y)",
"+ cnt += 1",
"+ if cnt == K:",
"+ break",
"+ print(y)"
]
| false | 1.078314 | 0.052762 | 20.437318 | [
"s895825291",
"s544279875"
]
|
u047393579 | p03435 | python | s602434350 | s020104416 | 636 | 227 | 3,064 | 3,064 | Accepted | Accepted | 64.31 | lis1 = []
lis2 = []
lis3 = []
count = 0
for num in input().split():
lis1.append(int(num))
for num in input().split():
lis2.append(int(num))
for num in input().split():
lis3.append(int(num))
for a1 in range(101):
for a2 in range(101):
for a3 in range(101):
count = 0
if lis1[0] - a1 == lis2[0] - a2 == lis3[0] - a3:
count += 1
if lis1[1] - a1 == lis2[1] - a2 == lis3[1] - a3:
count += 1
if lis1[2] - a1 == lis2[2] - a2 == lis3[2] - a3:
count += 1
if count == 3:
print("Yes")
break
if count == 3:
break
if count == 3:
break
if a1 == 100 and count != 3:
print("No") | lis1 = []
lis2 = []
lis3 = []
count = 0
flag = 0
for num in input().split():
lis1.append(int(num))
for num in input().split():
lis2.append(int(num))
for num in input().split():
lis3.append(int(num))
for a1 in range(101):
for a2 in range(101):
for a3 in range(101):
if lis1[0] - a1 == lis2[0] - a2 == lis3[0] - a3:
if lis1[1] - a1 == lis2[1] - a2 == lis3[1] - a3:
if lis1[2] - a1 == lis2[2] - a2 == lis3[2] - a3:
print("Yes")
flag = 1
break
if flag == 1:
break
if flag == 1:
break
if a1 == 100 and flag == 0:
print("No") | 29 | 26 | 794 | 701 | lis1 = []
lis2 = []
lis3 = []
count = 0
for num in input().split():
lis1.append(int(num))
for num in input().split():
lis2.append(int(num))
for num in input().split():
lis3.append(int(num))
for a1 in range(101):
for a2 in range(101):
for a3 in range(101):
count = 0
if lis1[0] - a1 == lis2[0] - a2 == lis3[0] - a3:
count += 1
if lis1[1] - a1 == lis2[1] - a2 == lis3[1] - a3:
count += 1
if lis1[2] - a1 == lis2[2] - a2 == lis3[2] - a3:
count += 1
if count == 3:
print("Yes")
break
if count == 3:
break
if count == 3:
break
if a1 == 100 and count != 3:
print("No")
| lis1 = []
lis2 = []
lis3 = []
count = 0
flag = 0
for num in input().split():
lis1.append(int(num))
for num in input().split():
lis2.append(int(num))
for num in input().split():
lis3.append(int(num))
for a1 in range(101):
for a2 in range(101):
for a3 in range(101):
if lis1[0] - a1 == lis2[0] - a2 == lis3[0] - a3:
if lis1[1] - a1 == lis2[1] - a2 == lis3[1] - a3:
if lis1[2] - a1 == lis2[2] - a2 == lis3[2] - a3:
print("Yes")
flag = 1
break
if flag == 1:
break
if flag == 1:
break
if a1 == 100 and flag == 0:
print("No")
| false | 10.344828 | [
"+flag = 0",
"- count = 0",
"- count += 1",
"- if lis1[1] - a1 == lis2[1] - a2 == lis3[1] - a3:",
"- count += 1",
"- if lis1[2] - a1 == lis2[2] - a2 == lis3[2] - a3:",
"- count += 1",
"- if count == 3:",
"- print(\"Yes\")",
"- break",
"- if count == 3:",
"+ if lis1[1] - a1 == lis2[1] - a2 == lis3[1] - a3:",
"+ if lis1[2] - a1 == lis2[2] - a2 == lis3[2] - a3:",
"+ print(\"Yes\")",
"+ flag = 1",
"+ break",
"+ if flag == 1:",
"- if count == 3:",
"+ if flag == 1:",
"- if a1 == 100 and count != 3:",
"+ if a1 == 100 and flag == 0:"
]
| false | 0.607794 | 0.713528 | 0.851815 | [
"s602434350",
"s020104416"
]
|
u014333473 | p03474 | python | s735810517 | s185416449 | 38 | 34 | 9,900 | 9,864 | Accepted | Accepted | 10.53 | import re
n,m=input().split();print(('YNeos'[re.match(r'[0-9]{'+n+'}-[0-9]{'+m+'}',eval(input())) is None::2])) | import re
n,m=input().split();print(('YNeos'[not re.match(r'[0-9]{'+n+'}-[0-9]{'+m+'}',eval(input()))::2])) | 2 | 2 | 104 | 100 | import re
n, m = input().split()
print(
(
"YNeos"[
re.match(r"[0-9]{" + n + "}-[0-9]{" + m + "}", eval(input())) is None :: 2
]
)
)
| import re
n, m = input().split()
print(("YNeos"[not re.match(r"[0-9]{" + n + "}-[0-9]{" + m + "}", eval(input())) :: 2]))
| false | 0 | [
"-print(",
"- (",
"- \"YNeos\"[",
"- re.match(r\"[0-9]{\" + n + \"}-[0-9]{\" + m + \"}\", eval(input())) is None :: 2",
"- ]",
"- )",
"-)",
"+print((\"YNeos\"[not re.match(r\"[0-9]{\" + n + \"}-[0-9]{\" + m + \"}\", eval(input())) :: 2]))"
]
| false | 0.082229 | 0.083198 | 0.988351 | [
"s735810517",
"s185416449"
]
|
u280552586 | p03475 | python | s996917228 | s353355890 | 110 | 91 | 3,188 | 3,188 | Accepted | Accepted | 17.27 | n = int(eval(input()))
CSF = [tuple(map(int, input().split())) for _ in range(n-1)]
for i in range(n-1):
t = 0
for j in range(i, n-1):
if t <= CSF[j][1]:
t = CSF[j][1]
elif t % CSF[j][2] == 0:
pass
else:
t += CSF[j][2] - t % CSF[j][2]
t += CSF[j][0]
print(t)
print((0))
| n = int(eval(input()))
CSF = [tuple(map(int, input().split())) for _ in range(n-1)]
for i in range(n-1):
t = 0
for j in range(i, n-1):
c, s, f = CSF[j]
if t <= s:
t = s
elif t % f == 0:
pass
else:
t += f - t % f
t += c
print(t)
print((0))
| 16 | 17 | 359 | 337 | n = int(eval(input()))
CSF = [tuple(map(int, input().split())) for _ in range(n - 1)]
for i in range(n - 1):
t = 0
for j in range(i, n - 1):
if t <= CSF[j][1]:
t = CSF[j][1]
elif t % CSF[j][2] == 0:
pass
else:
t += CSF[j][2] - t % CSF[j][2]
t += CSF[j][0]
print(t)
print((0))
| n = int(eval(input()))
CSF = [tuple(map(int, input().split())) for _ in range(n - 1)]
for i in range(n - 1):
t = 0
for j in range(i, n - 1):
c, s, f = CSF[j]
if t <= s:
t = s
elif t % f == 0:
pass
else:
t += f - t % f
t += c
print(t)
print((0))
| false | 5.882353 | [
"- if t <= CSF[j][1]:",
"- t = CSF[j][1]",
"- elif t % CSF[j][2] == 0:",
"+ c, s, f = CSF[j]",
"+ if t <= s:",
"+ t = s",
"+ elif t % f == 0:",
"- t += CSF[j][2] - t % CSF[j][2]",
"- t += CSF[j][0]",
"+ t += f - t % f",
"+ t += c"
]
| false | 0.07102 | 0.043549 | 1.630793 | [
"s996917228",
"s353355890"
]
|
u969848070 | p02773 | python | s535800219 | s887150249 | 770 | 517 | 35,220 | 35,952 | Accepted | Accepted | 32.86 | N = int(eval(input()))
S = []
for i in range(N):
S.append(eval(input()))
T = {}
for i in range(N):
if S[i] in T:
T[S[i]] += 1
else:
T.setdefault(S[i],1)
A = max(T.values())
keys = [k for k, v in list(T.items()) if v == A]
U =sorted(keys)
for i in range(len(U)):
print((U[i])) | from collections import Counter
n = int(eval(input()))
a = [eval(input()) for x in range(n)]
b = Counter(a)
c = max(b.values())
s = [s for s, g in list(b.items()) if g == c]
s.sort()
print(('\n'.join(s))) | 17 | 9 | 291 | 193 | N = int(eval(input()))
S = []
for i in range(N):
S.append(eval(input()))
T = {}
for i in range(N):
if S[i] in T:
T[S[i]] += 1
else:
T.setdefault(S[i], 1)
A = max(T.values())
keys = [k for k, v in list(T.items()) if v == A]
U = sorted(keys)
for i in range(len(U)):
print((U[i]))
| from collections import Counter
n = int(eval(input()))
a = [eval(input()) for x in range(n)]
b = Counter(a)
c = max(b.values())
s = [s for s, g in list(b.items()) if g == c]
s.sort()
print(("\n".join(s)))
| false | 47.058824 | [
"-N = int(eval(input()))",
"-S = []",
"-for i in range(N):",
"- S.append(eval(input()))",
"-T = {}",
"-for i in range(N):",
"- if S[i] in T:",
"- T[S[i]] += 1",
"- else:",
"- T.setdefault(S[i], 1)",
"-A = max(T.values())",
"-keys = [k for k, v in list(T.items()) if v == A]",
"-U = sorted(keys)",
"-for i in range(len(U)):",
"- print((U[i]))",
"+from collections import Counter",
"+",
"+n = int(eval(input()))",
"+a = [eval(input()) for x in range(n)]",
"+b = Counter(a)",
"+c = max(b.values())",
"+s = [s for s, g in list(b.items()) if g == c]",
"+s.sort()",
"+print((\"\\n\".join(s)))"
]
| false | 0.094287 | 0.040079 | 2.352546 | [
"s535800219",
"s887150249"
]
|
u380524497 | p03624 | python | s895682061 | s490982562 | 39 | 19 | 3,188 | 3,188 | Accepted | Accepted | 51.28 | text = eval(input())
alphabet = 'abcdefghijklmnopqrstuvwxyz'
for s in text:
alphabet = alphabet.replace(s, '')
if alphabet is '':
print('None')
else:
print((alphabet[0])) | alpha = [chr(ord('a') + i) for i in range(26)]
S = set(eval(input()))
if len(set(alpha)) == len(S):
print('None')
else:
for s in alpha:
if s not in S:
print(s)
exit() | 10 | 11 | 185 | 212 | text = eval(input())
alphabet = "abcdefghijklmnopqrstuvwxyz"
for s in text:
alphabet = alphabet.replace(s, "")
if alphabet is "":
print("None")
else:
print((alphabet[0]))
| alpha = [chr(ord("a") + i) for i in range(26)]
S = set(eval(input()))
if len(set(alpha)) == len(S):
print("None")
else:
for s in alpha:
if s not in S:
print(s)
exit()
| false | 9.090909 | [
"-text = eval(input())",
"-alphabet = \"abcdefghijklmnopqrstuvwxyz\"",
"-for s in text:",
"- alphabet = alphabet.replace(s, \"\")",
"-if alphabet is \"\":",
"+alpha = [chr(ord(\"a\") + i) for i in range(26)]",
"+S = set(eval(input()))",
"+if len(set(alpha)) == len(S):",
"- print((alphabet[0]))",
"+ for s in alpha:",
"+ if s not in S:",
"+ print(s)",
"+ exit()"
]
| false | 0.049534 | 0.036886 | 1.342883 | [
"s895682061",
"s490982562"
]
|
u519939795 | p02836 | python | s173334372 | s267080126 | 19 | 17 | 3,060 | 2,940 | Accepted | Accepted | 10.53 | s=eval(input())
ans=0
for i in range(len(s)//2):
if s[i]!=s[-i-1]:
ans+=1
print(ans) | s = eval(input())
ans = 0
for f, b in zip(s, s[::-1]):
if f!=b:
ans+=1
print((ans//2)) | 6 | 6 | 95 | 95 | s = eval(input())
ans = 0
for i in range(len(s) // 2):
if s[i] != s[-i - 1]:
ans += 1
print(ans)
| s = eval(input())
ans = 0
for f, b in zip(s, s[::-1]):
if f != b:
ans += 1
print((ans // 2))
| false | 0 | [
"-for i in range(len(s) // 2):",
"- if s[i] != s[-i - 1]:",
"+for f, b in zip(s, s[::-1]):",
"+ if f != b:",
"-print(ans)",
"+print((ans // 2))"
]
| false | 0.06333 | 0.063423 | 0.998519 | [
"s173334372",
"s267080126"
]
|
u678167152 | p02845 | python | s201920991 | s943474950 | 233 | 106 | 52,952 | 99,260 | Accepted | Accepted | 54.51 | N = int(eval(input()))
A = list(map(int, input().split()))
mod = 10**9+7
color = [0]*3
ans = 1
for i in range(N):
if A[i] not in color:
ans = 0
break
ind = color.index(A[i])
ans *= len([c for c in color if c == A[i]])
ans %= mod
color[ind] += 1
#ans = rec(color,0)
print(ans) | from collections import defaultdict
def solve():
d = defaultdict(lambda: 0)
N = int(eval(input()))
A = list(map(int, input().split()))
mod = 10**9+7
d[0] = 3
ans = 1
for i in range(N):
if d[A[i]]==0:
return 0
ans *= d[A[i]]
ans %= mod
d[A[i]] -= 1
d[A[i]+1] += 1
return ans
print((solve())) | 16 | 17 | 303 | 340 | N = int(eval(input()))
A = list(map(int, input().split()))
mod = 10**9 + 7
color = [0] * 3
ans = 1
for i in range(N):
if A[i] not in color:
ans = 0
break
ind = color.index(A[i])
ans *= len([c for c in color if c == A[i]])
ans %= mod
color[ind] += 1
# ans = rec(color,0)
print(ans)
| from collections import defaultdict
def solve():
d = defaultdict(lambda: 0)
N = int(eval(input()))
A = list(map(int, input().split()))
mod = 10**9 + 7
d[0] = 3
ans = 1
for i in range(N):
if d[A[i]] == 0:
return 0
ans *= d[A[i]]
ans %= mod
d[A[i]] -= 1
d[A[i] + 1] += 1
return ans
print((solve()))
| false | 5.882353 | [
"-N = int(eval(input()))",
"-A = list(map(int, input().split()))",
"-mod = 10**9 + 7",
"-color = [0] * 3",
"-ans = 1",
"-for i in range(N):",
"- if A[i] not in color:",
"- ans = 0",
"- break",
"- ind = color.index(A[i])",
"- ans *= len([c for c in color if c == A[i]])",
"- ans %= mod",
"- color[ind] += 1",
"-# ans = rec(color,0)",
"-print(ans)",
"+from collections import defaultdict",
"+",
"+",
"+def solve():",
"+ d = defaultdict(lambda: 0)",
"+ N = int(eval(input()))",
"+ A = list(map(int, input().split()))",
"+ mod = 10**9 + 7",
"+ d[0] = 3",
"+ ans = 1",
"+ for i in range(N):",
"+ if d[A[i]] == 0:",
"+ return 0",
"+ ans *= d[A[i]]",
"+ ans %= mod",
"+ d[A[i]] -= 1",
"+ d[A[i] + 1] += 1",
"+ return ans",
"+",
"+",
"+print((solve()))"
]
| false | 0.042816 | 0.084623 | 0.505959 | [
"s201920991",
"s943474950"
]
|
u187205913 | p03560 | python | s255252617 | s545456118 | 1,451 | 172 | 20,736 | 19,724 | Accepted | Accepted | 88.15 | k = int(eval(input()))
from collections import deque
dic = {1:1}
queue = deque([[1,1]])
while queue:
v,cost = queue.popleft()
v_ = (v+1)%k
if not v_ in dic or cost+1<dic[v_]:
dic[v_] = cost+1
queue.appendleft([v_,cost+1])
v_ = v*10%k
if not v_ in dic or cost<dic[v_]:
dic[v_] = cost
queue.append([v_,cost])
print((dic[0])) | from collections import deque
K = int(eval(input()))
d={1:1}
q = deque()
q.append([1,1])
while q:
a,c = q.popleft()
a_ = (a*10)%K
if(a_ not in d or c < d[a_]):
d[a_]=c
q.appendleft([a_,c])
b_ = (a+1)%K
if(b_ not in d or c < d[b_]):
d[b_] = c+1
q.append([b_,c+1])
print((d[0]))
| 16 | 19 | 382 | 346 | k = int(eval(input()))
from collections import deque
dic = {1: 1}
queue = deque([[1, 1]])
while queue:
v, cost = queue.popleft()
v_ = (v + 1) % k
if not v_ in dic or cost + 1 < dic[v_]:
dic[v_] = cost + 1
queue.appendleft([v_, cost + 1])
v_ = v * 10 % k
if not v_ in dic or cost < dic[v_]:
dic[v_] = cost
queue.append([v_, cost])
print((dic[0]))
| from collections import deque
K = int(eval(input()))
d = {1: 1}
q = deque()
q.append([1, 1])
while q:
a, c = q.popleft()
a_ = (a * 10) % K
if a_ not in d or c < d[a_]:
d[a_] = c
q.appendleft([a_, c])
b_ = (a + 1) % K
if b_ not in d or c < d[b_]:
d[b_] = c + 1
q.append([b_, c + 1])
print((d[0]))
| false | 15.789474 | [
"-k = int(eval(input()))",
"-dic = {1: 1}",
"-queue = deque([[1, 1]])",
"-while queue:",
"- v, cost = queue.popleft()",
"- v_ = (v + 1) % k",
"- if not v_ in dic or cost + 1 < dic[v_]:",
"- dic[v_] = cost + 1",
"- queue.appendleft([v_, cost + 1])",
"- v_ = v * 10 % k",
"- if not v_ in dic or cost < dic[v_]:",
"- dic[v_] = cost",
"- queue.append([v_, cost])",
"-print((dic[0]))",
"+K = int(eval(input()))",
"+d = {1: 1}",
"+q = deque()",
"+q.append([1, 1])",
"+while q:",
"+ a, c = q.popleft()",
"+ a_ = (a * 10) % K",
"+ if a_ not in d or c < d[a_]:",
"+ d[a_] = c",
"+ q.appendleft([a_, c])",
"+ b_ = (a + 1) % K",
"+ if b_ not in d or c < d[b_]:",
"+ d[b_] = c + 1",
"+ q.append([b_, c + 1])",
"+print((d[0]))"
]
| false | 0.112064 | 0.041755 | 2.683825 | [
"s255252617",
"s545456118"
]
|
u754022296 | p04006 | python | s324209185 | s108558398 | 1,695 | 184 | 3,188 | 12,508 | Accepted | Accepted | 89.14 | n, x = list(map(int, input().split()))
A = list(map(int, input().split()))[::-1]*2
B = A[:n]
ans = float("inf")
for k in range(n):
t = x*k + sum(B)
ans = min(ans, t)
for j in range(n):
B[j] = min(B[j], A[j+k+1])
print(ans) | import numpy as np
n, x = list(map(int, input().split()))
A = np.array(input().split()[::-1]*2, dtype=np.int64)
B = A.copy()[:n]
ans = float("inf")
for k in range(n):
t = x*k + B.sum()
ans = min(ans, t)
np.minimum(B, A[k+1:k+n+1], out=B)
print(ans) | 10 | 10 | 235 | 257 | n, x = list(map(int, input().split()))
A = list(map(int, input().split()))[::-1] * 2
B = A[:n]
ans = float("inf")
for k in range(n):
t = x * k + sum(B)
ans = min(ans, t)
for j in range(n):
B[j] = min(B[j], A[j + k + 1])
print(ans)
| import numpy as np
n, x = list(map(int, input().split()))
A = np.array(input().split()[::-1] * 2, dtype=np.int64)
B = A.copy()[:n]
ans = float("inf")
for k in range(n):
t = x * k + B.sum()
ans = min(ans, t)
np.minimum(B, A[k + 1 : k + n + 1], out=B)
print(ans)
| false | 0 | [
"+import numpy as np",
"+",
"-A = list(map(int, input().split()))[::-1] * 2",
"-B = A[:n]",
"+A = np.array(input().split()[::-1] * 2, dtype=np.int64)",
"+B = A.copy()[:n]",
"- t = x * k + sum(B)",
"+ t = x * k + B.sum()",
"- for j in range(n):",
"- B[j] = min(B[j], A[j + k + 1])",
"+ np.minimum(B, A[k + 1 : k + n + 1], out=B)"
]
| false | 0.048019 | 0.216496 | 0.221799 | [
"s324209185",
"s108558398"
]
|
u496821919 | p02628 | python | s960466930 | s518882761 | 40 | 31 | 9,236 | 9,160 | Accepted | Accepted | 22.5 | n,k = list(map(int,input().split()))
P = list(map(int,input().split()))
ans = 0
for i in range(k):
m = min(P)
ans += m
P.remove(m)
print(ans) | import heapq
n,k = list(map(int,input().split()))
P = list(map(int,input().split()))
ans = 0
heapq.heapify(P)
for i in range(k):
ans += heapq.heappop(P)
print(ans) | 8 | 8 | 154 | 168 | n, k = list(map(int, input().split()))
P = list(map(int, input().split()))
ans = 0
for i in range(k):
m = min(P)
ans += m
P.remove(m)
print(ans)
| import heapq
n, k = list(map(int, input().split()))
P = list(map(int, input().split()))
ans = 0
heapq.heapify(P)
for i in range(k):
ans += heapq.heappop(P)
print(ans)
| false | 0 | [
"+import heapq",
"+",
"+heapq.heapify(P)",
"- m = min(P)",
"- ans += m",
"- P.remove(m)",
"+ ans += heapq.heappop(P)"
]
| false | 0.03912 | 0.038872 | 1.006385 | [
"s960466930",
"s518882761"
]
|
u133936772 | p03043 | python | s000120130 | s871636505 | 77 | 62 | 9,072 | 9,024 | Accepted | Accepted | 19.48 | n,k=list(map(int,input().split()))
p=0
for i in range(1,n+1): p+=[1,4/2**len(bin(~-k//i))][i<k]
print((p/n)) | n,k=list(map(int,input().split()))
print((sum([1,4/2**len(bin(~-k//i))][i<k] for i in range(1,n+1))/n)) | 4 | 2 | 103 | 96 | n, k = list(map(int, input().split()))
p = 0
for i in range(1, n + 1):
p += [1, 4 / 2 ** len(bin(~-k // i))][i < k]
print((p / n))
| n, k = list(map(int, input().split()))
print((sum([1, 4 / 2 ** len(bin(~-k // i))][i < k] for i in range(1, n + 1)) / n))
| false | 50 | [
"-p = 0",
"-for i in range(1, n + 1):",
"- p += [1, 4 / 2 ** len(bin(~-k // i))][i < k]",
"-print((p / n))",
"+print((sum([1, 4 / 2 ** len(bin(~-k // i))][i < k] for i in range(1, n + 1)) / n))"
]
| false | 0.204717 | 0.103287 | 1.982028 | [
"s000120130",
"s871636505"
]
|
u416011173 | p02595 | python | s537959307 | s274684693 | 534 | 417 | 24,992 | 25,008 | Accepted | Accepted | 21.91 | # -*- coding: utf-8 -*-
# モジュールのインポート
import math
# 標準入力を取得
N, D = list(map(int, input().split()))
X, Y = [], []
for n in range(N):
X_n, Y_n = list(map(int, input().split()))
X.append(X_n)
Y.append(Y_n)
# 求解処理
def get_distance(p: int, q: int) -> float:
return math.sqrt(math.pow(p, 2) + math.pow(q, 2))
ans = 0
for n in range(N):
distance = get_distance(X[n], Y[n])
if distance <= D:
ans += 1
# 結果出力
print(ans)
| # -*- coding: utf-8 -*-
def get_input() -> tuple:
"""
標準入力を取得する.
Returns:\n
tuple: 標準入力
"""
N, D = list(map(int, input().split()))
X, Y = [], []
for n in range(N):
X_n, Y_n = list(map(int, input().split()))
X.append(X_n)
Y.append(Y_n)
return N, D, X, Y
def main(N: int, D: int, X: list, Y: list) -> None:
"""
メイン処理.
Args:\n
N (int): 点の個数
D (int): 距離
X (list): x座標
Y (list): y座標
"""
# 求解処理
ans = 0
for n in range(N):
X_n = X[n]
Y_n = Y[n]
if X_n * X_n + Y_n * Y_n <= D * D:
ans += 1
# 結果出力
print(ans)
if __name__ == "__main__":
# 標準入力を取得
N, D, X, Y = get_input()
# メイン処理
main(N, D, X, Y)
| 27 | 47 | 476 | 827 | # -*- coding: utf-8 -*-
# モジュールのインポート
import math
# 標準入力を取得
N, D = list(map(int, input().split()))
X, Y = [], []
for n in range(N):
X_n, Y_n = list(map(int, input().split()))
X.append(X_n)
Y.append(Y_n)
# 求解処理
def get_distance(p: int, q: int) -> float:
return math.sqrt(math.pow(p, 2) + math.pow(q, 2))
ans = 0
for n in range(N):
distance = get_distance(X[n], Y[n])
if distance <= D:
ans += 1
# 結果出力
print(ans)
| # -*- coding: utf-8 -*-
def get_input() -> tuple:
"""
標準入力を取得する.
Returns:\n
tuple: 標準入力
"""
N, D = list(map(int, input().split()))
X, Y = [], []
for n in range(N):
X_n, Y_n = list(map(int, input().split()))
X.append(X_n)
Y.append(Y_n)
return N, D, X, Y
def main(N: int, D: int, X: list, Y: list) -> None:
"""
メイン処理.
Args:\n
N (int): 点の個数
D (int): 距離
X (list): x座標
Y (list): y座標
"""
# 求解処理
ans = 0
for n in range(N):
X_n = X[n]
Y_n = Y[n]
if X_n * X_n + Y_n * Y_n <= D * D:
ans += 1
# 結果出力
print(ans)
if __name__ == "__main__":
# 標準入力を取得
N, D, X, Y = get_input()
# メイン処理
main(N, D, X, Y)
| false | 42.553191 | [
"-# モジュールのインポート",
"-import math",
"-",
"-# 標準入力を取得",
"-N, D = list(map(int, input().split()))",
"-X, Y = [], []",
"-for n in range(N):",
"- X_n, Y_n = list(map(int, input().split()))",
"- X.append(X_n)",
"- Y.append(Y_n)",
"-# 求解処理",
"-def get_distance(p: int, q: int) -> float:",
"- return math.sqrt(math.pow(p, 2) + math.pow(q, 2))",
"+def get_input() -> tuple:",
"+ \"\"\"",
"+ 標準入力を取得する.",
"+ Returns:\\n",
"+ tuple: 標準入力",
"+ \"\"\"",
"+ N, D = list(map(int, input().split()))",
"+ X, Y = [], []",
"+ for n in range(N):",
"+ X_n, Y_n = list(map(int, input().split()))",
"+ X.append(X_n)",
"+ Y.append(Y_n)",
"+ return N, D, X, Y",
"-ans = 0",
"-for n in range(N):",
"- distance = get_distance(X[n], Y[n])",
"- if distance <= D:",
"- ans += 1",
"-# 結果出力",
"-print(ans)",
"+def main(N: int, D: int, X: list, Y: list) -> None:",
"+ \"\"\"",
"+ メイン処理.",
"+ Args:\\n",
"+ N (int): 点の個数",
"+ D (int): 距離",
"+ X (list): x座標",
"+ Y (list): y座標",
"+ \"\"\"",
"+ # 求解処理",
"+ ans = 0",
"+ for n in range(N):",
"+ X_n = X[n]",
"+ Y_n = Y[n]",
"+ if X_n * X_n + Y_n * Y_n <= D * D:",
"+ ans += 1",
"+ # 結果出力",
"+ print(ans)",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ # 標準入力を取得",
"+ N, D, X, Y = get_input()",
"+ # メイン処理",
"+ main(N, D, X, Y)"
]
| false | 0.039726 | 0.038636 | 1.028216 | [
"s537959307",
"s274684693"
]
|
u357751375 | p04005 | python | s932756536 | s576302269 | 29 | 25 | 9,168 | 9,040 | Accepted | Accepted | 13.79 | a = list(map(int,input().split()))
a.sort(reverse = True)
if a[0] % 2 == 0 or a[1] % 2 == 0 or a[2] % 2 == 0:
print((0))
exit(0)
block = a[0] * a[1] * a[2]
a[0] = a[0] // 2
x = a[0] * a[1] * a[2]
y = block - x
print((abs(x - y))) | a = list(map(int,input().split()))
if a[0] % 2 == 0 or a[1] % 2 == 0 or a[2] % 2 == 0:
print((0))
else:
print((min(a[0]*a[1],a[1]*a[2],a[0]*a[2]))) | 10 | 5 | 242 | 155 | a = list(map(int, input().split()))
a.sort(reverse=True)
if a[0] % 2 == 0 or a[1] % 2 == 0 or a[2] % 2 == 0:
print((0))
exit(0)
block = a[0] * a[1] * a[2]
a[0] = a[0] // 2
x = a[0] * a[1] * a[2]
y = block - x
print((abs(x - y)))
| a = list(map(int, input().split()))
if a[0] % 2 == 0 or a[1] % 2 == 0 or a[2] % 2 == 0:
print((0))
else:
print((min(a[0] * a[1], a[1] * a[2], a[0] * a[2])))
| false | 50 | [
"-a.sort(reverse=True)",
"- exit(0)",
"-block = a[0] * a[1] * a[2]",
"-a[0] = a[0] // 2",
"-x = a[0] * a[1] * a[2]",
"-y = block - x",
"-print((abs(x - y)))",
"+else:",
"+ print((min(a[0] * a[1], a[1] * a[2], a[0] * a[2])))"
]
| false | 0.074603 | 0.09625 | 0.775093 | [
"s932756536",
"s576302269"
]
|
u761529120 | p03330 | python | s384825547 | s601700070 | 422 | 174 | 43,228 | 75,176 | Accepted | Accepted | 58.77 | from itertools import permutations
def main():
N, C = list(map(int, input().split()))
D = list(list(map(int, input().split())) for _ in range(C))
c = list(list(map(int, input().split())) for _ in range(N))
cost = [[0] * (C + 5) for _ in range(3)]
for k in range(C):
for i in range(N):
for j in range(N):
cost[(i + j) % 3][k + 1] += D[c[i][j]-1][k]
ans = float('inf')
for a, b, c in permutations(list(range(1,C+1)), 3):
tmp = cost[0][a] + cost[1][b] + cost[2][c]
ans = min(tmp, ans)
print(ans)
if __name__ == "__main__":
main() | from itertools import permutations
def main():
N, C = list(map(int, input().split()))
D = [list(map(int, input().split())) for _ in range(C)]
c = [list(map(int, input().split())) for _ in range(N)]
score = [[0] * 3 for _ in range(C)]
for i in range(N):
for j in range(N):
for k in range(C):
score[k][(i+j)%3] += D[c[i][j]-1][k]
ans = float('inf')
for balls in permutations(list(range(C)),3):
tmp = 0
for i in range(3):
tmp += score[balls[i]][i]
ans = min(ans, tmp)
print(ans)
if __name__ == "__main__":
main() | 32 | 26 | 652 | 637 | from itertools import permutations
def main():
N, C = list(map(int, input().split()))
D = list(list(map(int, input().split())) for _ in range(C))
c = list(list(map(int, input().split())) for _ in range(N))
cost = [[0] * (C + 5) for _ in range(3)]
for k in range(C):
for i in range(N):
for j in range(N):
cost[(i + j) % 3][k + 1] += D[c[i][j] - 1][k]
ans = float("inf")
for a, b, c in permutations(list(range(1, C + 1)), 3):
tmp = cost[0][a] + cost[1][b] + cost[2][c]
ans = min(tmp, ans)
print(ans)
if __name__ == "__main__":
main()
| from itertools import permutations
def main():
N, C = list(map(int, input().split()))
D = [list(map(int, input().split())) for _ in range(C)]
c = [list(map(int, input().split())) for _ in range(N)]
score = [[0] * 3 for _ in range(C)]
for i in range(N):
for j in range(N):
for k in range(C):
score[k][(i + j) % 3] += D[c[i][j] - 1][k]
ans = float("inf")
for balls in permutations(list(range(C)), 3):
tmp = 0
for i in range(3):
tmp += score[balls[i]][i]
ans = min(ans, tmp)
print(ans)
if __name__ == "__main__":
main()
| false | 18.75 | [
"- D = list(list(map(int, input().split())) for _ in range(C))",
"- c = list(list(map(int, input().split())) for _ in range(N))",
"- cost = [[0] * (C + 5) for _ in range(3)]",
"- for k in range(C):",
"- for i in range(N):",
"- for j in range(N):",
"- cost[(i + j) % 3][k + 1] += D[c[i][j] - 1][k]",
"+ D = [list(map(int, input().split())) for _ in range(C)]",
"+ c = [list(map(int, input().split())) for _ in range(N)]",
"+ score = [[0] * 3 for _ in range(C)]",
"+ for i in range(N):",
"+ for j in range(N):",
"+ for k in range(C):",
"+ score[k][(i + j) % 3] += D[c[i][j] - 1][k]",
"- for a, b, c in permutations(list(range(1, C + 1)), 3):",
"- tmp = cost[0][a] + cost[1][b] + cost[2][c]",
"- ans = min(tmp, ans)",
"+ for balls in permutations(list(range(C)), 3):",
"+ tmp = 0",
"+ for i in range(3):",
"+ tmp += score[balls[i]][i]",
"+ ans = min(ans, tmp)"
]
| false | 0.038364 | 0.078137 | 0.490985 | [
"s384825547",
"s601700070"
]
|
u815878613 | p02630 | python | s040806945 | s178639204 | 287 | 245 | 40,280 | 34,688 | Accepted | Accepted | 14.63 | from collections import Counter
import sys
readline = sys.stdin.buffer.readline
N = int(readline())
A = tuple(map(int, readline().split()))
Q = int(readline())
BC = [list(map(int, readline().split())) for _ in range(Q)]
d = Counter(A)
sub_s = sum(A)
for b, c in BC:
sub_s += d[b] * (c - b)
d[c] += d[b]
d[b] = 0
print(sub_s)
| import sys
from collections import Counter
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
A = tuple(map(int, readline().split()))
Q = int(readline())
BC = list(map(int, read().split()))
d = Counter(A)
sub_s = sum(A)
for b, c in zip(BC, BC):
sub_s += d[b] * (c - b)
d[c] += d[b]
d[b] = 0
print(sub_s)
| 22 | 22 | 370 | 415 | from collections import Counter
import sys
readline = sys.stdin.buffer.readline
N = int(readline())
A = tuple(map(int, readline().split()))
Q = int(readline())
BC = [list(map(int, readline().split())) for _ in range(Q)]
d = Counter(A)
sub_s = sum(A)
for b, c in BC:
sub_s += d[b] * (c - b)
d[c] += d[b]
d[b] = 0
print(sub_s)
| import sys
from collections import Counter
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
A = tuple(map(int, readline().split()))
Q = int(readline())
BC = list(map(int, read().split()))
d = Counter(A)
sub_s = sum(A)
for b, c in zip(BC, BC):
sub_s += d[b] * (c - b)
d[c] += d[b]
d[b] = 0
print(sub_s)
| false | 0 | [
"+import sys",
"-import sys",
"+read = sys.stdin.buffer.read",
"+readlines = sys.stdin.buffer.readlines",
"-BC = [list(map(int, readline().split())) for _ in range(Q)]",
"+BC = list(map(int, read().split()))",
"-for b, c in BC:",
"+for b, c in zip(BC, BC):"
]
| false | 0.049344 | 0.049649 | 0.993872 | [
"s040806945",
"s178639204"
]
|
u729133443 | p02586 | python | s143356978 | s988324368 | 2,009 | 767 | 424,916 | 413,348 | Accepted | Accepted | 61.82 | c=[[0]*3001for _ in range(3001)]
dp=[[[0]*3001for _ in range(3001)]for _ in range(4)]
h,w,k=list(map(int,input().split()))
for i in range(k):
y,x,v=list(map(int,input().split()))
c[y][x]=v
for i in range(1,h+1):
for j in range(1,w+1):
x=max(dp[0][i-1][j],dp[1][i-1][j],dp[2][i-1][j],dp[3][i-1][j])
for k in range(4):
if k:dp[k][i][j]=max(dp[k][i][j-1],dp[k-1][i][j-1]+c[i][j])
else:dp[k][i][j]=max(dp[k][i][j-1],x)
dp[1][i][j]=max(dp[1][i][j],x+c[i][j])
print((max(dp[0][h][w],dp[1][h][w],dp[2][h][w],dp[3][h][w]))) | import sys
from numpy import*
def main(h,w,k,t):
c=zeros((3001,3001),int_)
dp=zeros((4,3001,3001),int_)
for i in range(k):
y,x,v=t[i]
c[y,x]=v
for i in range(1,h+1):
for j in range(1,w+1):
x=max(dp[:,i-1,j])
for k in range(4):
if k:dp[k,i,j]=max(dp[k,i,j-1],dp[k-1,i,j-1]+c[i,j])
else:dp[k,i,j]=max(dp[k,i,j-1],x)
dp[1,i,j]=max(dp[1,i,j],x+c[i,j])
return max(dp[:,h,w])
if sys.argv[-1]=='ONLINE_JUDGE':
from numba.pycc import CC
cc=CC('my_module')
cc.export('main','i8(i8,i8,i8,i8[:,:])')(main)
cc.compile()
exit()
from my_module import main
(h,w,k),*t=[int_(t.split())for t in open(0)]
print((main(h,w,k,int_(t)))) | 14 | 25 | 574 | 759 | c = [[0] * 3001 for _ in range(3001)]
dp = [[[0] * 3001 for _ in range(3001)] for _ in range(4)]
h, w, k = list(map(int, input().split()))
for i in range(k):
y, x, v = list(map(int, input().split()))
c[y][x] = v
for i in range(1, h + 1):
for j in range(1, w + 1):
x = max(dp[0][i - 1][j], dp[1][i - 1][j], dp[2][i - 1][j], dp[3][i - 1][j])
for k in range(4):
if k:
dp[k][i][j] = max(dp[k][i][j - 1], dp[k - 1][i][j - 1] + c[i][j])
else:
dp[k][i][j] = max(dp[k][i][j - 1], x)
dp[1][i][j] = max(dp[1][i][j], x + c[i][j])
print((max(dp[0][h][w], dp[1][h][w], dp[2][h][w], dp[3][h][w])))
| import sys
from numpy import *
def main(h, w, k, t):
c = zeros((3001, 3001), int_)
dp = zeros((4, 3001, 3001), int_)
for i in range(k):
y, x, v = t[i]
c[y, x] = v
for i in range(1, h + 1):
for j in range(1, w + 1):
x = max(dp[:, i - 1, j])
for k in range(4):
if k:
dp[k, i, j] = max(dp[k, i, j - 1], dp[k - 1, i, j - 1] + c[i, j])
else:
dp[k, i, j] = max(dp[k, i, j - 1], x)
dp[1, i, j] = max(dp[1, i, j], x + c[i, j])
return max(dp[:, h, w])
if sys.argv[-1] == "ONLINE_JUDGE":
from numba.pycc import CC
cc = CC("my_module")
cc.export("main", "i8(i8,i8,i8,i8[:,:])")(main)
cc.compile()
exit()
from my_module import main
(h, w, k), *t = [int_(t.split()) for t in open(0)]
print((main(h, w, k, int_(t))))
| false | 44 | [
"-c = [[0] * 3001 for _ in range(3001)]",
"-dp = [[[0] * 3001 for _ in range(3001)] for _ in range(4)]",
"-h, w, k = list(map(int, input().split()))",
"-for i in range(k):",
"- y, x, v = list(map(int, input().split()))",
"- c[y][x] = v",
"-for i in range(1, h + 1):",
"- for j in range(1, w + 1):",
"- x = max(dp[0][i - 1][j], dp[1][i - 1][j], dp[2][i - 1][j], dp[3][i - 1][j])",
"- for k in range(4):",
"- if k:",
"- dp[k][i][j] = max(dp[k][i][j - 1], dp[k - 1][i][j - 1] + c[i][j])",
"- else:",
"- dp[k][i][j] = max(dp[k][i][j - 1], x)",
"- dp[1][i][j] = max(dp[1][i][j], x + c[i][j])",
"-print((max(dp[0][h][w], dp[1][h][w], dp[2][h][w], dp[3][h][w])))",
"+import sys",
"+from numpy import *",
"+",
"+",
"+def main(h, w, k, t):",
"+ c = zeros((3001, 3001), int_)",
"+ dp = zeros((4, 3001, 3001), int_)",
"+ for i in range(k):",
"+ y, x, v = t[i]",
"+ c[y, x] = v",
"+ for i in range(1, h + 1):",
"+ for j in range(1, w + 1):",
"+ x = max(dp[:, i - 1, j])",
"+ for k in range(4):",
"+ if k:",
"+ dp[k, i, j] = max(dp[k, i, j - 1], dp[k - 1, i, j - 1] + c[i, j])",
"+ else:",
"+ dp[k, i, j] = max(dp[k, i, j - 1], x)",
"+ dp[1, i, j] = max(dp[1, i, j], x + c[i, j])",
"+ return max(dp[:, h, w])",
"+",
"+",
"+if sys.argv[-1] == \"ONLINE_JUDGE\":",
"+ from numba.pycc import CC",
"+",
"+ cc = CC(\"my_module\")",
"+ cc.export(\"main\", \"i8(i8,i8,i8,i8[:,:])\")(main)",
"+ cc.compile()",
"+ exit()",
"+from my_module import main",
"+",
"+(h, w, k), *t = [int_(t.split()) for t in open(0)]",
"+print((main(h, w, k, int_(t))))"
]
| false | 0.987812 | 0.205416 | 4.808844 | [
"s143356978",
"s988324368"
]
|
u936985471 | p03032 | python | s873116309 | s733945753 | 29 | 22 | 3,064 | 3,064 | Accepted | Accepted | 24.14 | N,K=list(map(int,input().split()))
V=list(map(int,input().split()))
Vrev=V[::-1]
# 左からA個取る
# 右からB個取る
# A+B<=min(N,K)
# K-(A+B)個詰め直す。負の数で絶対値の大きいものから順に。
# A,Bを、0からA+B=min(N,K)まで全探索
MAX=min(N,K)
ans=0
for a in range(MAX+1):
for b in range(MAX-a+1):
jewels=V[:a]+Vrev[:b]
jewels=sorted(jewels)
drop=K-(a+b)
for i in range(drop):
if i>=len(jewels):
break
if jewels[i]>=0:
break
else:
jewels[i]=0
if ans<sum(jewels):
ans=sum(jewels)
print(ans) | # 左から取り出すパターンは最大50通り
# 右から取り出すパターンは最大50通り
# その組み合わせは2500通り
# その全通りに対して、マイナスの石を引けるだけ引くパターンを試すと50
# 125000
# すべて試す
import sys
readline = sys.stdin.readline
N,K = list(map(int,readline().split()))
V = [0] + list(map(int,readline().split())) + [0]
N += 2
K += 2
leftsum = 0
leftminus = []
ans = -(10 ** 9)
for left in range(min(N,K)):
leftsum += V[left]
if V[left] < 0:
leftminus += [V[left]]
rightsum = 0
rightminus = []
limit = min(N - (left + 1) , K - (left + 1))
for right in range(N - 1, N - limit - 1, -1):
rightsum += V[right]
if V[right] < 0:
rightminus += [V[right]]
allsum = leftsum + rightsum
rest = max(K - ((left + 1) + (N - right)),0)
allminus = sorted(leftminus + rightminus)
allsum -= sum(allminus[:rest])
if allsum > ans:
ans = allsum
print(ans) | 26 | 36 | 527 | 846 | N, K = list(map(int, input().split()))
V = list(map(int, input().split()))
Vrev = V[::-1]
# 左からA個取る
# 右からB個取る
# A+B<=min(N,K)
# K-(A+B)個詰め直す。負の数で絶対値の大きいものから順に。
# A,Bを、0からA+B=min(N,K)まで全探索
MAX = min(N, K)
ans = 0
for a in range(MAX + 1):
for b in range(MAX - a + 1):
jewels = V[:a] + Vrev[:b]
jewels = sorted(jewels)
drop = K - (a + b)
for i in range(drop):
if i >= len(jewels):
break
if jewels[i] >= 0:
break
else:
jewels[i] = 0
if ans < sum(jewels):
ans = sum(jewels)
print(ans)
| # 左から取り出すパターンは最大50通り
# 右から取り出すパターンは最大50通り
# その組み合わせは2500通り
# その全通りに対して、マイナスの石を引けるだけ引くパターンを試すと50
# 125000
# すべて試す
import sys
readline = sys.stdin.readline
N, K = list(map(int, readline().split()))
V = [0] + list(map(int, readline().split())) + [0]
N += 2
K += 2
leftsum = 0
leftminus = []
ans = -(10**9)
for left in range(min(N, K)):
leftsum += V[left]
if V[left] < 0:
leftminus += [V[left]]
rightsum = 0
rightminus = []
limit = min(N - (left + 1), K - (left + 1))
for right in range(N - 1, N - limit - 1, -1):
rightsum += V[right]
if V[right] < 0:
rightminus += [V[right]]
allsum = leftsum + rightsum
rest = max(K - ((left + 1) + (N - right)), 0)
allminus = sorted(leftminus + rightminus)
allsum -= sum(allminus[:rest])
if allsum > ans:
ans = allsum
print(ans)
| false | 27.777778 | [
"-N, K = list(map(int, input().split()))",
"-V = list(map(int, input().split()))",
"-Vrev = V[::-1]",
"-# 左からA個取る",
"-# 右からB個取る",
"-# A+B<=min(N,K)",
"-# K-(A+B)個詰め直す。負の数で絶対値の大きいものから順に。",
"-# A,Bを、0からA+B=min(N,K)まで全探索",
"-MAX = min(N, K)",
"-ans = 0",
"-for a in range(MAX + 1):",
"- for b in range(MAX - a + 1):",
"- jewels = V[:a] + Vrev[:b]",
"- jewels = sorted(jewels)",
"- drop = K - (a + b)",
"- for i in range(drop):",
"- if i >= len(jewels):",
"- break",
"- if jewels[i] >= 0:",
"- break",
"- else:",
"- jewels[i] = 0",
"- if ans < sum(jewels):",
"- ans = sum(jewels)",
"+# 左から取り出すパターンは最大50通り",
"+# 右から取り出すパターンは最大50通り",
"+# その組み合わせは2500通り",
"+# その全通りに対して、マイナスの石を引けるだけ引くパターンを試すと50",
"+# 125000",
"+# すべて試す",
"+import sys",
"+",
"+readline = sys.stdin.readline",
"+N, K = list(map(int, readline().split()))",
"+V = [0] + list(map(int, readline().split())) + [0]",
"+N += 2",
"+K += 2",
"+leftsum = 0",
"+leftminus = []",
"+ans = -(10**9)",
"+for left in range(min(N, K)):",
"+ leftsum += V[left]",
"+ if V[left] < 0:",
"+ leftminus += [V[left]]",
"+ rightsum = 0",
"+ rightminus = []",
"+ limit = min(N - (left + 1), K - (left + 1))",
"+ for right in range(N - 1, N - limit - 1, -1):",
"+ rightsum += V[right]",
"+ if V[right] < 0:",
"+ rightminus += [V[right]]",
"+ allsum = leftsum + rightsum",
"+ rest = max(K - ((left + 1) + (N - right)), 0)",
"+ allminus = sorted(leftminus + rightminus)",
"+ allsum -= sum(allminus[:rest])",
"+ if allsum > ans:",
"+ ans = allsum"
]
| false | 0.065885 | 0.040331 | 1.633606 | [
"s873116309",
"s733945753"
]
|
u777923818 | p03102 | python | s666721114 | s879589432 | 309 | 122 | 20,644 | 27,272 | Accepted | Accepted | 60.52 | # -*- coding: utf-8 -*-
import numpy as np
def inpl(): return list(map(int, input().split()))
N, M, C = inpl()
B = np.array(inpl(), dtype=np.int64).reshape(1, -1)
A = np.zeros((N, M), dtype=np.int64)
for i in range(N):
A[i] = inpl()
print((((A*B).sum(axis=1) + C >0).sum())) | # -*- coding: utf-8 -*-
import numpy as np
def inpl(): return list(map(int, input().split()))
N, M, C = inpl()
B = np.array(inpl(), dtype=np.int64)
ans = 0
for _ in range(N):
A = np.array(inpl(), dtype=np.int64)
ans += np.sum(A*B)+C > 0
print(ans)
| 12 | 10 | 290 | 265 | # -*- coding: utf-8 -*-
import numpy as np
def inpl():
return list(map(int, input().split()))
N, M, C = inpl()
B = np.array(inpl(), dtype=np.int64).reshape(1, -1)
A = np.zeros((N, M), dtype=np.int64)
for i in range(N):
A[i] = inpl()
print((((A * B).sum(axis=1) + C > 0).sum()))
| # -*- coding: utf-8 -*-
import numpy as np
def inpl():
return list(map(int, input().split()))
N, M, C = inpl()
B = np.array(inpl(), dtype=np.int64)
ans = 0
for _ in range(N):
A = np.array(inpl(), dtype=np.int64)
ans += np.sum(A * B) + C > 0
print(ans)
| false | 16.666667 | [
"-B = np.array(inpl(), dtype=np.int64).reshape(1, -1)",
"-A = np.zeros((N, M), dtype=np.int64)",
"-for i in range(N):",
"- A[i] = inpl()",
"-print((((A * B).sum(axis=1) + C > 0).sum()))",
"+B = np.array(inpl(), dtype=np.int64)",
"+ans = 0",
"+for _ in range(N):",
"+ A = np.array(inpl(), dtype=np.int64)",
"+ ans += np.sum(A * B) + C > 0",
"+print(ans)"
]
| false | 0.775398 | 0.458265 | 1.692029 | [
"s666721114",
"s879589432"
]
|
u089376182 | p03805 | python | s102974158 | s618459782 | 56 | 43 | 3,572 | 3,064 | Accepted | Accepted | 23.21 | import itertools
n, m = list(map(int, input().split()))
ab_list = [tuple(map(int, input().split())) for _ in range(m)]
path_list = sorted(iter for iter in itertools.permutations(list(range(2, n+1)), n-1))
counter = 0
for path_i in path_list:
path = (1, )+path_i
result_list = [True for s_e in zip(path, path[1:]) if tuple(sorted(s_e)) in ab_list]
if sum(result_list) == len(path)-1: counter += 1
print(counter) | import itertools
n,m = list(map(int, input().split()))
edge_set = {tuple(map(int, input().split())) for _ in range(m)}
counter = 0
for i in itertools.permutations(list(range(2, n+1)), n-1):
path = [1] + list(i)
path_set = {tuple(sorted(edge)) for edge in zip(path, path[1:])}
if path_set <= edge_set:
counter += 1
print(counter) | 16 | 15 | 433 | 350 | import itertools
n, m = list(map(int, input().split()))
ab_list = [tuple(map(int, input().split())) for _ in range(m)]
path_list = sorted(
iter for iter in itertools.permutations(list(range(2, n + 1)), n - 1)
)
counter = 0
for path_i in path_list:
path = (1,) + path_i
result_list = [True for s_e in zip(path, path[1:]) if tuple(sorted(s_e)) in ab_list]
if sum(result_list) == len(path) - 1:
counter += 1
print(counter)
| import itertools
n, m = list(map(int, input().split()))
edge_set = {tuple(map(int, input().split())) for _ in range(m)}
counter = 0
for i in itertools.permutations(list(range(2, n + 1)), n - 1):
path = [1] + list(i)
path_set = {tuple(sorted(edge)) for edge in zip(path, path[1:])}
if path_set <= edge_set:
counter += 1
print(counter)
| false | 6.25 | [
"-ab_list = [tuple(map(int, input().split())) for _ in range(m)]",
"-path_list = sorted(",
"- iter for iter in itertools.permutations(list(range(2, n + 1)), n - 1)",
"-)",
"+edge_set = {tuple(map(int, input().split())) for _ in range(m)}",
"-for path_i in path_list:",
"- path = (1,) + path_i",
"- result_list = [True for s_e in zip(path, path[1:]) if tuple(sorted(s_e)) in ab_list]",
"- if sum(result_list) == len(path) - 1:",
"+for i in itertools.permutations(list(range(2, n + 1)), n - 1):",
"+ path = [1] + list(i)",
"+ path_set = {tuple(sorted(edge)) for edge in zip(path, path[1:])}",
"+ if path_set <= edge_set:"
]
| false | 0.082668 | 0.053132 | 1.555888 | [
"s102974158",
"s618459782"
]
|
u352394527 | p00483 | python | s041170486 | s803228121 | 2,820 | 2,420 | 195,744 | 200,052 | Accepted | Accepted | 14.18 | def solve():
m, n = list(map(int,input().split()))
k = int(eval(input()))
mp = [eval(input()) for i in range(m)]
dp = [[[0] * 3 for j in range(n + 1)] for i in range(m + 1)]
dic = {"J":0, "O":1, "I":2}
for i in range(1, m + 1):
dpi = dp[i]
dpi_1 = dp[i - 1]
for j in range(1, n + 1):
dpij = dpi[j]
dpij_1 = dpi[j - 1]
dpi_1j = dpi_1[j]
dpi_1j_1 = dpi_1[j - 1]
for p in range(3):
#dp[i][j][p] = dp[i][j - 1][p] + dp[i - 1][j][p] - dp[i - 1][j - 1][p]
dpij[p] = dpij_1[p] + dpi_1j[p] - dpi_1j_1[p]
#dp[i][j][mp[i - 1][j - 1]] += 1
dpij[dic[mp[i - 1][j - 1]]] += 1
for i in range(k):
x1,y1,x2,y2 = list(map(int,input().split()))
dpx2 = dp[x2]
dpx1 = dp[x1 - 1]
dpx2y2 = dpx2[y2]
dpx2y1 = dpx2[y1 - 1]
dpx1y2 = dpx1[y2]
dpx1y1 = dpx1[y1 - 1]
#print(dp[x2][y2][0] - dp[x1 - 1][y2][0] - dp[x2][y1 - 1][0] + dp[x1 - 1][y1 - 1][0], dp[x2][y2][1] - dp[x1 - 1][y2][1] - dp[x2][y1 - 1][1] + dp[x1 - 1][y1 - 1][1], dp[x2][y2][2] - dp[x1 - 1][y2][2] - dp[x2][y1 - 1][2] + dp[x1 - 1][y1 - 1][2])
print((dpx2y2[0] - dpx1y2[0] - dpx2y1[0] + dpx1y1[0], dpx2y2[1] - dpx1y2[1] - dpx2y1[1] + dpx1y1[1], dpx2y2[2] - dpx1y2[2] - dpx2y1[2] + dpx1y1[2]))
solve()
| def solve():
m, n = list(map(int,input().split()))
k = int(eval(input()))
mp = [eval(input()) for i in range(m)]
dp = [[[0] * 3 for j in range(n + 1)] for i in range(m + 1)]
dic = {"J":0, "O":1, "I":2}
for i in range(1, m + 1):
dpi = dp[i]
dpi_1 = dp[i - 1]
for j in range(1, n + 1):
dpij = dpi[j]
dpij_1 = dpi[j - 1]
dpi_1j = dpi_1[j]
dpi_1j_1 = dpi_1[j - 1]
for p in range(3):
#dp[i][j][p] = dp[i][j - 1][p] + dp[i - 1][j][p] - dp[i - 1][j - 1][p]
dpij[p] = dpij_1[p] + dpi_1j[p] - dpi_1j_1[p]
#dp[i][j][mp[i - 1][j - 1]] += 1
dpij[dic[mp[i - 1][j - 1]]] += 1
ans = ""
for i in range(k):
x1,y1,x2,y2 = list(map(int,input().split()))
dpx2 = dp[x2]
dpx1 = dp[x1 - 1]
dpx2y2 = dpx2[y2]
dpx2y1 = dpx2[y1 - 1]
dpx1y2 = dpx1[y2]
dpx1y1 = dpx1[y1 - 1]
#print(dp[x2][y2][0] - dp[x1 - 1][y2][0] - dp[x2][y1 - 1][0] + dp[x1 - 1][y1 - 1][0], dp[x2][y2][1] - dp[x1 - 1][y2][1] - dp[x2][y1 - 1][1] + dp[x1 - 1][y1 - 1][1], dp[x2][y2][2] - dp[x1 - 1][y2][2] - dp[x2][y1 - 1][2] + dp[x1 - 1][y1 - 1][2])
ans += str(dpx2y2[0] - dpx1y2[0] - dpx2y1[0] + dpx1y1[0]) + " " + str(dpx2y2[1] - dpx1y2[1] - dpx2y1[1] + dpx1y1[1]) + " " + str(dpx2y2[2] - dpx1y2[2] - dpx2y1[2] + dpx1y1[2]) + "\n"
ans = ans.rstrip()
print(ans)
solve()
| 36 | 40 | 1,279 | 1,365 | def solve():
m, n = list(map(int, input().split()))
k = int(eval(input()))
mp = [eval(input()) for i in range(m)]
dp = [[[0] * 3 for j in range(n + 1)] for i in range(m + 1)]
dic = {"J": 0, "O": 1, "I": 2}
for i in range(1, m + 1):
dpi = dp[i]
dpi_1 = dp[i - 1]
for j in range(1, n + 1):
dpij = dpi[j]
dpij_1 = dpi[j - 1]
dpi_1j = dpi_1[j]
dpi_1j_1 = dpi_1[j - 1]
for p in range(3):
# dp[i][j][p] = dp[i][j - 1][p] + dp[i - 1][j][p] - dp[i - 1][j - 1][p]
dpij[p] = dpij_1[p] + dpi_1j[p] - dpi_1j_1[p]
# dp[i][j][mp[i - 1][j - 1]] += 1
dpij[dic[mp[i - 1][j - 1]]] += 1
for i in range(k):
x1, y1, x2, y2 = list(map(int, input().split()))
dpx2 = dp[x2]
dpx1 = dp[x1 - 1]
dpx2y2 = dpx2[y2]
dpx2y1 = dpx2[y1 - 1]
dpx1y2 = dpx1[y2]
dpx1y1 = dpx1[y1 - 1]
# print(dp[x2][y2][0] - dp[x1 - 1][y2][0] - dp[x2][y1 - 1][0] + dp[x1 - 1][y1 - 1][0], dp[x2][y2][1] - dp[x1 - 1][y2][1] - dp[x2][y1 - 1][1] + dp[x1 - 1][y1 - 1][1], dp[x2][y2][2] - dp[x1 - 1][y2][2] - dp[x2][y1 - 1][2] + dp[x1 - 1][y1 - 1][2])
print(
(
dpx2y2[0] - dpx1y2[0] - dpx2y1[0] + dpx1y1[0],
dpx2y2[1] - dpx1y2[1] - dpx2y1[1] + dpx1y1[1],
dpx2y2[2] - dpx1y2[2] - dpx2y1[2] + dpx1y1[2],
)
)
solve()
| def solve():
m, n = list(map(int, input().split()))
k = int(eval(input()))
mp = [eval(input()) for i in range(m)]
dp = [[[0] * 3 for j in range(n + 1)] for i in range(m + 1)]
dic = {"J": 0, "O": 1, "I": 2}
for i in range(1, m + 1):
dpi = dp[i]
dpi_1 = dp[i - 1]
for j in range(1, n + 1):
dpij = dpi[j]
dpij_1 = dpi[j - 1]
dpi_1j = dpi_1[j]
dpi_1j_1 = dpi_1[j - 1]
for p in range(3):
# dp[i][j][p] = dp[i][j - 1][p] + dp[i - 1][j][p] - dp[i - 1][j - 1][p]
dpij[p] = dpij_1[p] + dpi_1j[p] - dpi_1j_1[p]
# dp[i][j][mp[i - 1][j - 1]] += 1
dpij[dic[mp[i - 1][j - 1]]] += 1
ans = ""
for i in range(k):
x1, y1, x2, y2 = list(map(int, input().split()))
dpx2 = dp[x2]
dpx1 = dp[x1 - 1]
dpx2y2 = dpx2[y2]
dpx2y1 = dpx2[y1 - 1]
dpx1y2 = dpx1[y2]
dpx1y1 = dpx1[y1 - 1]
# print(dp[x2][y2][0] - dp[x1 - 1][y2][0] - dp[x2][y1 - 1][0] + dp[x1 - 1][y1 - 1][0], dp[x2][y2][1] - dp[x1 - 1][y2][1] - dp[x2][y1 - 1][1] + dp[x1 - 1][y1 - 1][1], dp[x2][y2][2] - dp[x1 - 1][y2][2] - dp[x2][y1 - 1][2] + dp[x1 - 1][y1 - 1][2])
ans += (
str(dpx2y2[0] - dpx1y2[0] - dpx2y1[0] + dpx1y1[0])
+ " "
+ str(dpx2y2[1] - dpx1y2[1] - dpx2y1[1] + dpx1y1[1])
+ " "
+ str(dpx2y2[2] - dpx1y2[2] - dpx2y1[2] + dpx1y1[2])
+ "\n"
)
ans = ans.rstrip()
print(ans)
solve()
| false | 10 | [
"+ ans = \"\"",
"- print(",
"- (",
"- dpx2y2[0] - dpx1y2[0] - dpx2y1[0] + dpx1y1[0],",
"- dpx2y2[1] - dpx1y2[1] - dpx2y1[1] + dpx1y1[1],",
"- dpx2y2[2] - dpx1y2[2] - dpx2y1[2] + dpx1y1[2],",
"- )",
"+ ans += (",
"+ str(dpx2y2[0] - dpx1y2[0] - dpx2y1[0] + dpx1y1[0])",
"+ + \" \"",
"+ + str(dpx2y2[1] - dpx1y2[1] - dpx2y1[1] + dpx1y1[1])",
"+ + \" \"",
"+ + str(dpx2y2[2] - dpx1y2[2] - dpx2y1[2] + dpx1y1[2])",
"+ + \"\\n\"",
"+ ans = ans.rstrip()",
"+ print(ans)"
]
| false | 0.057902 | 0.057868 | 1.000577 | [
"s041170486",
"s803228121"
]
|
u072717685 | p03607 | python | s853838073 | s580236298 | 176 | 69 | 19,708 | 23,536 | Accepted | Accepted | 60.8 | from collections import Counter
def main():
n = int(eval(input()))
l1 = []
for _ in range(n):
l1.append(eval(input()))
l1c = Counter(l1)
l1c2 = [c for c in l1c if l1c[c]%2 != 0]
print((len(l1c2)))
if __name__ == '__main__':
main()
| import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import Counter
def main():
n = eval(input())
a = tuple(map(int, readlines()))
ac = Counter(a)
ac2 = [c % 2 for c in list(ac.values())]
r = sum(ac2)
print(r)
if __name__ == '__main__':
main()
| 12 | 13 | 265 | 301 | from collections import Counter
def main():
n = int(eval(input()))
l1 = []
for _ in range(n):
l1.append(eval(input()))
l1c = Counter(l1)
l1c2 = [c for c in l1c if l1c[c] % 2 != 0]
print((len(l1c2)))
if __name__ == "__main__":
main()
| import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import Counter
def main():
n = eval(input())
a = tuple(map(int, readlines()))
ac = Counter(a)
ac2 = [c % 2 for c in list(ac.values())]
r = sum(ac2)
print(r)
if __name__ == "__main__":
main()
| false | 7.692308 | [
"+import sys",
"+",
"+read = sys.stdin.read",
"+readlines = sys.stdin.readlines",
"- n = int(eval(input()))",
"- l1 = []",
"- for _ in range(n):",
"- l1.append(eval(input()))",
"- l1c = Counter(l1)",
"- l1c2 = [c for c in l1c if l1c[c] % 2 != 0]",
"- print((len(l1c2)))",
"+ n = eval(input())",
"+ a = tuple(map(int, readlines()))",
"+ ac = Counter(a)",
"+ ac2 = [c % 2 for c in list(ac.values())]",
"+ r = sum(ac2)",
"+ print(r)"
]
| false | 0.061344 | 0.037297 | 1.644755 | [
"s853838073",
"s580236298"
]
|
u678167152 | p03775 | python | s463990376 | s745026007 | 34 | 27 | 3,060 | 3,060 | Accepted | Accepted | 20.59 | N = int(eval(input()))
def divisor(n):
cd = []
i = 1
while i*i <= n:
if n%i==0:
cd.append(i)
if i != n//i:
cd.append(n//i)
i+=1
return cd
cd = divisor(N)
ans = len(str(cd[-1]))
print(ans)
| def solve():
N = int(eval(input()))
n = int(N**0.5)+1
for i in range(n,0,-1):
if N%i==0:
ans = len(str(N//i))
break
return ans
print((solve()))
| 18 | 9 | 275 | 192 | N = int(eval(input()))
def divisor(n):
cd = []
i = 1
while i * i <= n:
if n % i == 0:
cd.append(i)
if i != n // i:
cd.append(n // i)
i += 1
return cd
cd = divisor(N)
ans = len(str(cd[-1]))
print(ans)
| def solve():
N = int(eval(input()))
n = int(N**0.5) + 1
for i in range(n, 0, -1):
if N % i == 0:
ans = len(str(N // i))
break
return ans
print((solve()))
| false | 50 | [
"-N = int(eval(input()))",
"+def solve():",
"+ N = int(eval(input()))",
"+ n = int(N**0.5) + 1",
"+ for i in range(n, 0, -1):",
"+ if N % i == 0:",
"+ ans = len(str(N // i))",
"+ break",
"+ return ans",
"-def divisor(n):",
"- cd = []",
"- i = 1",
"- while i * i <= n:",
"- if n % i == 0:",
"- cd.append(i)",
"- if i != n // i:",
"- cd.append(n // i)",
"- i += 1",
"- return cd",
"-",
"-",
"-cd = divisor(N)",
"-ans = len(str(cd[-1]))",
"-print(ans)",
"+print((solve()))"
]
| false | 0.044121 | 0.036254 | 1.216991 | [
"s463990376",
"s745026007"
]
|
u600402037 | p03038 | python | s053594989 | s878747399 | 424 | 372 | 24,760 | 36,324 | Accepted | Accepted | 12.26 | from bisect import bisect_left
from operator import itemgetter
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
BC = []
X = []
for _ in range(M):
b, c = list(map(int, input().split()))
X.append((b, c))
X = sorted(X, key=itemgetter(1), reverse=True)
for b, c in X:
BC.extend([c] * b)
if len(BC) >= N:
break
Y = A + BC
Y.sort(reverse=True)
answer = sum(Y[:N])
print(answer) | # coding: utf-8
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, M = lr()
A = lr()
BC = [lr() for _ in range(M)]
BC.sort(key=lambda x: x[1], reverse=True)
D = []
count = 0
for b, c in BC:
x = [c] * b
D.extend(x)
count += b
if count >= N:
break
E = A + D
E.sort(reverse=True)
answer = sum(E[:N])
print(answer)
| 22 | 24 | 434 | 432 | from bisect import bisect_left
from operator import itemgetter
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
BC = []
X = []
for _ in range(M):
b, c = list(map(int, input().split()))
X.append((b, c))
X = sorted(X, key=itemgetter(1), reverse=True)
for b, c in X:
BC.extend([c] * b)
if len(BC) >= N:
break
Y = A + BC
Y.sort(reverse=True)
answer = sum(Y[:N])
print(answer)
| # coding: utf-8
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, M = lr()
A = lr()
BC = [lr() for _ in range(M)]
BC.sort(key=lambda x: x[1], reverse=True)
D = []
count = 0
for b, c in BC:
x = [c] * b
D.extend(x)
count += b
if count >= N:
break
E = A + D
E.sort(reverse=True)
answer = sum(E[:N])
print(answer)
| false | 8.333333 | [
"-from bisect import bisect_left",
"-from operator import itemgetter",
"+# coding: utf-8",
"+import sys",
"-N, M = list(map(int, input().split()))",
"-A = list(map(int, input().split()))",
"-BC = []",
"-X = []",
"-for _ in range(M):",
"- b, c = list(map(int, input().split()))",
"- X.append((b, c))",
"-X = sorted(X, key=itemgetter(1), reverse=True)",
"-for b, c in X:",
"- BC.extend([c] * b)",
"- if len(BC) >= N:",
"+sr = lambda: sys.stdin.readline().rstrip()",
"+ir = lambda: int(sr())",
"+lr = lambda: list(map(int, sr().split()))",
"+N, M = lr()",
"+A = lr()",
"+BC = [lr() for _ in range(M)]",
"+BC.sort(key=lambda x: x[1], reverse=True)",
"+D = []",
"+count = 0",
"+for b, c in BC:",
"+ x = [c] * b",
"+ D.extend(x)",
"+ count += b",
"+ if count >= N:",
"-Y = A + BC",
"-Y.sort(reverse=True)",
"-answer = sum(Y[:N])",
"+E = A + D",
"+E.sort(reverse=True)",
"+answer = sum(E[:N])"
]
| false | 0.040943 | 0.04567 | 0.896489 | [
"s053594989",
"s878747399"
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.