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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u083960235 | p02844 | python | s990996040 | s576527918 | 499 | 258 | 80,764 | 78,848 | Accepted | Accepted | 48.3 | import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right
def input(): return sys.stdin.readline().strip()
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def S_MAP(): return list(map(str, input().split()))
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
N = INT()
L = eval(input())
S = list(map(int, list(L)))
# print(S)
cnt = 0
# 000-999 1000
for i in range(0, 10):
for j in range(0, 10):
for k in range(0, 10):
num = 0
flag = False
exist = [False] * 3
while num != N and flag != True:
# print(num)
if exist[0] == False:
# print(S[num])
if S[num] != i:
num += 1
elif S[num] == i:
num += 1
exist[0] = True
else:
if exist[1] == False:
if S[num] != j:
num += 1
elif S[num] == j:
num += 1
exist[1] = True
else:
if exist[2] == False:
if S[num] != k:
num += 1
elif S[num] == k:
num += 1
exist[2] == True
flag = True
if flag == True:
cnt += 1
print(cnt)
| import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right
def input(): return sys.stdin.readline().strip()
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def S_MAP(): return list(map(str, input().split()))
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
N = INT()
S = eval(input())
ans = 0
for i in range(1000):
tmp = str(i).zfill(3)
cnt = 0
for j in range(N):
if S[j] == tmp[cnt]:
cnt += 1
if cnt == 3:
ans += 1
break
print(ans) | 63 | 35 | 2,110 | 1,038 | import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right
def input():
return sys.stdin.readline().strip()
def INT():
return int(eval(input()))
def MAP():
return list(map(int, input().split()))
def S_MAP():
return list(map(str, input().split()))
def LIST():
return list(map(int, input().split()))
def S_LIST():
return list(map(str, input().split()))
sys.setrecursionlimit(10**9)
INF = float("inf")
mod = 10**9 + 7
N = INT()
L = eval(input())
S = list(map(int, list(L)))
# print(S)
cnt = 0
# 000-999 1000
for i in range(0, 10):
for j in range(0, 10):
for k in range(0, 10):
num = 0
flag = False
exist = [False] * 3
while num != N and flag != True:
# print(num)
if exist[0] == False:
# print(S[num])
if S[num] != i:
num += 1
elif S[num] == i:
num += 1
exist[0] = True
else:
if exist[1] == False:
if S[num] != j:
num += 1
elif S[num] == j:
num += 1
exist[1] = True
else:
if exist[2] == False:
if S[num] != k:
num += 1
elif S[num] == k:
num += 1
exist[2] == True
flag = True
if flag == True:
cnt += 1
print(cnt)
| import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right
def input():
return sys.stdin.readline().strip()
def INT():
return int(eval(input()))
def MAP():
return list(map(int, input().split()))
def S_MAP():
return list(map(str, input().split()))
def LIST():
return list(map(int, input().split()))
def S_LIST():
return list(map(str, input().split()))
sys.setrecursionlimit(10**9)
INF = float("inf")
mod = 10**9 + 7
N = INT()
S = eval(input())
ans = 0
for i in range(1000):
tmp = str(i).zfill(3)
cnt = 0
for j in range(N):
if S[j] == tmp[cnt]:
cnt += 1
if cnt == 3:
ans += 1
break
print(ans)
| false | 44.444444 | [
"-L = eval(input())",
"-S = list(map(int, list(L)))",
"-# print(S)",
"-cnt = 0",
"-# 000-999 1000",
"-for i in range(0, 10):",
"- for j in range(0, 10):",
"- for k in range(0, 10):",
"- num = 0",
"- flag = False",
"- exist = [False] * 3",
"- while num != N and flag != True:",
"- # print(num)",
"- if exist[0] == False:",
"- # print(S[num])",
"- if S[num] != i:",
"- num += 1",
"- elif S[num] == i:",
"- num += 1",
"- exist[0] = True",
"- else:",
"- if exist[1] == False:",
"- if S[num] != j:",
"- num += 1",
"- elif S[num] == j:",
"- num += 1",
"- exist[1] = True",
"- else:",
"- if exist[2] == False:",
"- if S[num] != k:",
"- num += 1",
"- elif S[num] == k:",
"- num += 1",
"- exist[2] == True",
"- flag = True",
"- if flag == True:",
"- cnt += 1",
"-print(cnt)",
"+S = eval(input())",
"+ans = 0",
"+for i in range(1000):",
"+ tmp = str(i).zfill(3)",
"+ cnt = 0",
"+ for j in range(N):",
"+ if S[j] == tmp[cnt]:",
"+ cnt += 1",
"+ if cnt == 3:",
"+ ans += 1",
"+ break",
"+print(ans)"
] | false | 0.047674 | 0.045468 | 1.048514 | [
"s990996040",
"s576527918"
] |
u346812984 | p03311 | python | s049187866 | s356351967 | 244 | 205 | 26,180 | 25,196 | Accepted | Accepted | 15.98 | N = int(eval(input()))
A = list(map(int, input().split()))
A_i = [A[i] - i - 1 for i in range(N)]
A_i.sort()
if N % 2 == 1:
b = A_i[N // 2]
ans = 0
for a in A_i:
ans += abs(a - b)
print(ans)
else:
b1 = A_i[N // 2]
b2 = A_i[N // 2 - 1]
ans1 = 0
ans2 = 0
for a in A_i:
ans1 += abs(a - b1)
ans2 += abs(a - b2)
print((min(ans1, ans2)))
| N = int(eval(input()))
A = list(map(int, input().split()))
A_i = [A[i] - i - 1 for i in range(N)]
A_i.sort()
b = A_i[N // 2]
ans = 0
for a in A_i:
ans += abs(a - b)
print(ans)
| 21 | 11 | 410 | 186 | N = int(eval(input()))
A = list(map(int, input().split()))
A_i = [A[i] - i - 1 for i in range(N)]
A_i.sort()
if N % 2 == 1:
b = A_i[N // 2]
ans = 0
for a in A_i:
ans += abs(a - b)
print(ans)
else:
b1 = A_i[N // 2]
b2 = A_i[N // 2 - 1]
ans1 = 0
ans2 = 0
for a in A_i:
ans1 += abs(a - b1)
ans2 += abs(a - b2)
print((min(ans1, ans2)))
| N = int(eval(input()))
A = list(map(int, input().split()))
A_i = [A[i] - i - 1 for i in range(N)]
A_i.sort()
b = A_i[N // 2]
ans = 0
for a in A_i:
ans += abs(a - b)
print(ans)
| false | 47.619048 | [
"-if N % 2 == 1:",
"- b = A_i[N // 2]",
"- ans = 0",
"- for a in A_i:",
"- ans += abs(a - b)",
"- print(ans)",
"-else:",
"- b1 = A_i[N // 2]",
"- b2 = A_i[N // 2 - 1]",
"- ans1 = 0",
"- ans2 = 0",
"- for a in A_i:",
"- ans1 += abs(a - b1)",
"- ans2 += abs(a - b2)",
"- print((min(ans1, ans2)))",
"+b = A_i[N // 2]",
"+ans = 0",
"+for a in A_i:",
"+ ans += abs(a - b)",
"+print(ans)"
] | false | 0.128892 | 0.047981 | 2.686297 | [
"s049187866",
"s356351967"
] |
u275934251 | p03095 | python | s898929330 | s299051630 | 302 | 185 | 49,136 | 45,296 | Accepted | Accepted | 38.74 | n=int(eval(input()))
s=list(eval(input()))
a=set(s)
ans=1
for i in a:
ans=ans*(s.count(i)+1)%(10**9+7)
print((ans-1)) | eval(input());s=eval(input());a=set(s)
ans=1
for i in a:ans=ans*(s.count(i)+1)%(10**9+7)
print((ans-1)) | 7 | 4 | 113 | 92 | n = int(eval(input()))
s = list(eval(input()))
a = set(s)
ans = 1
for i in a:
ans = ans * (s.count(i) + 1) % (10**9 + 7)
print((ans - 1))
| eval(input())
s = eval(input())
a = set(s)
ans = 1
for i in a:
ans = ans * (s.count(i) + 1) % (10**9 + 7)
print((ans - 1))
| false | 42.857143 | [
"-n = int(eval(input()))",
"-s = list(eval(input()))",
"+eval(input())",
"+s = eval(input())"
] | false | 0.081615 | 0.006856 | 11.903542 | [
"s898929330",
"s299051630"
] |
u214617707 | p03262 | python | s046593561 | s757619023 | 163 | 106 | 16,784 | 14,252 | Accepted | Accepted | 34.97 | n, X = list(map(int, input().split()))
x = list(map(int, input().split()))
rec = set()
for i in range(n):
rec.add(abs(x[i] - X))
rec = sorted(list(rec))
def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a % b)
num = rec[0]
for k in range(1, len(rec)):
num = gcd(num, rec[k])
print(num)
| N, x = list(map(int, input().split()))
X = list([abs(int(p) - x) for p in input().split()])
def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a % b)
q = X[0]
for i in range(1, N):
q = gcd(q, X[i])
print(q) | 22 | 16 | 345 | 257 | n, X = list(map(int, input().split()))
x = list(map(int, input().split()))
rec = set()
for i in range(n):
rec.add(abs(x[i] - X))
rec = sorted(list(rec))
def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a % b)
num = rec[0]
for k in range(1, len(rec)):
num = gcd(num, rec[k])
print(num)
| N, x = list(map(int, input().split()))
X = list([abs(int(p) - x) for p in input().split()])
def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a % b)
q = X[0]
for i in range(1, N):
q = gcd(q, X[i])
print(q)
| false | 27.272727 | [
"-n, X = list(map(int, input().split()))",
"-x = list(map(int, input().split()))",
"-rec = set()",
"-for i in range(n):",
"- rec.add(abs(x[i] - X))",
"-rec = sorted(list(rec))",
"+N, x = list(map(int, input().split()))",
"+X = list([abs(int(p) - x) for p in input().split()])",
"-num = rec[0]",
"-for k in range(1, len(rec)):",
"- num = gcd(num, rec[k])",
"-print(num)",
"+q = X[0]",
"+for i in range(1, N):",
"+ q = gcd(q, X[i])",
"+print(q)"
] | false | 0.042814 | 0.041695 | 1.026829 | [
"s046593561",
"s757619023"
] |
u785066634 | p02860 | python | s548920598 | s049075451 | 19 | 17 | 3,060 | 2,940 | Accepted | Accepted | 10.53 | n=int(eval(input()))
s=eval(input())
if n %2 !=0:
print('No')
elif s[:n//2]==s[n//2:]:
print('Yes')
else:
print('No')
| n=int(eval(input()))
s=list(str(eval(input())))
if n%2!=0:
print('No')
elif len(set(s[:n//2]))!=len(set(s[n//2:])):
print('No')
elif s[:n//2]!=s[n//2:]:
print('No')
else:
print('Yes')
| 9 | 14 | 163 | 297 | n = int(eval(input()))
s = eval(input())
if n % 2 != 0:
print("No")
elif s[: n // 2] == s[n // 2 :]:
print("Yes")
else:
print("No")
| n = int(eval(input()))
s = list(str(eval(input())))
if n % 2 != 0:
print("No")
elif len(set(s[: n // 2])) != len(set(s[n // 2 :])):
print("No")
elif s[: n // 2] != s[n // 2 :]:
print("No")
else:
print("Yes")
| false | 35.714286 | [
"-s = eval(input())",
"+s = list(str(eval(input())))",
"-elif s[: n // 2] == s[n // 2 :]:",
"+elif len(set(s[: n // 2])) != len(set(s[n // 2 :])):",
"+ print(\"No\")",
"+elif s[: n // 2] != s[n // 2 :]:",
"+ print(\"No\")",
"+else:",
"-else:",
"- print(\"No\")"
] | false | 0.041582 | 0.042535 | 0.977583 | [
"s548920598",
"s049075451"
] |
u729133443 | p02943 | python | s753545404 | s371851022 | 301 | 79 | 160,392 | 133,236 | Accepted | Accepted | 73.75 | n,k=list(map(int,input().split()))
s=eval(input())
r=list(range(n))
u=min((s+s[::-1])[i:]for i in r)
i=min(i for i in r if u[i]!=u[0])
print(((u[0]*min(i<<k-1,n)+u[i:])[:n])) | n,k=map(int,input().split())
s=input()
r=range(n)
u=min((s+s[::-1])[i:]for i in r)
for i in r:u[i]==u[0]or exit(print((u[0]*min(i<<k-1,n)+u[i:])[:n]))
| 6 | 5 | 159 | 154 | n, k = list(map(int, input().split()))
s = eval(input())
r = list(range(n))
u = min((s + s[::-1])[i:] for i in r)
i = min(i for i in r if u[i] != u[0])
print(((u[0] * min(i << k - 1, n) + u[i:])[:n]))
| n, k = map(int, input().split())
s = input()
r = range(n)
u = min((s + s[::-1])[i:] for i in r)
for i in r:
u[i] == u[0] or exit(print((u[0] * min(i << k - 1, n) + u[i:])[:n]))
| false | 16.666667 | [
"-n, k = list(map(int, input().split()))",
"-s = eval(input())",
"-r = list(range(n))",
"+n, k = map(int, input().split())",
"+s = input()",
"+r = range(n)",
"-i = min(i for i in r if u[i] != u[0])",
"-print(((u[0] * min(i << k - 1, n) + u[i:])[:n]))",
"+for i in r:",
"+ u[i] == u[0] or exit(print((u[0] * min(i << k - 1, n) + u[i:])[:n]))"
] | false | 0.078944 | 0.060383 | 1.307385 | [
"s753545404",
"s371851022"
] |
u807772568 | p02913 | python | s257005253 | s386398519 | 1,175 | 1,064 | 9,976 | 9,876 | Accepted | Accepted | 9.45 | import sys,collections as cl,bisect as bs,heapq as hq
input = sys.stdin.readline
def l(): #intのlist
return list(map(int,input().split()))
def m(): #複数文字
return list(map(int,input().split()))
def onem(): #Nとかの取得
return int(eval(input()))
def jo(x): #listをスペースごとに分ける
return " ".join(map(str,x))
def In(x,a): #aがリスト(sorted)
k = bs.bisect_left(a,x)
if k != len(a) and a[k] == x:
return True
else:
return False
def search(a,n):
se = dict()
data = []
for i in range(0,len(a)-n+1):
kkk = a[i:i+n]
kkk = "".join(kkk)
if In(kkk,data):
if se[kkk] <= i-n:
return True
else:
bs.insort(data,kkk)
se[kkk] = i
return False
def solver():
n = onem()
s = list(eval(input()))
l = 0
r = n//2
for i in range(n):
mid = -(-(l+r)//2)
ans = search(s,mid)
if l == mid:
break
if ans:
l = mid
else:
r = mid-1
print(l)
if __name__ == '__main__':
solver()
| import sys,collections as cl,bisect as bs , heapq as hq
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
return list(map(int,input().split()))
def m(): #複数文字
return list(map(int,input().split()))
def onem(): #Nとかの取得
return int(eval(input()))
def s(x): #圧縮
a = []
aa = x[0]
su = 1
for i in range(len(x)-1):
if aa != x[i+1]:
a.append([aa,su])
aa = x[i+1]
su = 1
else:
su += 1
a.append([aa,su])
return a
def jo(x): #listをスペースごとに分ける
return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
return max(list(map(max,x)))
def In(x,a): #aがリスト(sorted)
k = bs.bisect_left(a,x)
if k != len(a) and a[k][0] == x:
return True
else:
return False
def search(a,n):
se = dict()
for i in range(0,len(a)-n+1):
kkk = a[i:i+n]
kkk = "".join(kkk)
if kkk in se:
if se[kkk] <= i-n:
return True
else:
se[kkk] = i
return False
n = onem()
s = list(eval(input()))
l = 0
r = n//2
while True:
mid = -(-(l+r)//2)
ans = search(s,mid)
if l == mid:
break
if ans:
l = mid
else:
r = mid-1
print(l)
| 54 | 62 | 1,122 | 1,303 | import sys, collections as cl, bisect as bs, heapq as hq
input = sys.stdin.readline
def l(): # intのlist
return list(map(int, input().split()))
def m(): # 複数文字
return list(map(int, input().split()))
def onem(): # Nとかの取得
return int(eval(input()))
def jo(x): # listをスペースごとに分ける
return " ".join(map(str, x))
def In(x, a): # aがリスト(sorted)
k = bs.bisect_left(a, x)
if k != len(a) and a[k] == x:
return True
else:
return False
def search(a, n):
se = dict()
data = []
for i in range(0, len(a) - n + 1):
kkk = a[i : i + n]
kkk = "".join(kkk)
if In(kkk, data):
if se[kkk] <= i - n:
return True
else:
bs.insort(data, kkk)
se[kkk] = i
return False
def solver():
n = onem()
s = list(eval(input()))
l = 0
r = n // 2
for i in range(n):
mid = -(-(l + r) // 2)
ans = search(s, mid)
if l == mid:
break
if ans:
l = mid
else:
r = mid - 1
print(l)
if __name__ == "__main__":
solver()
| import sys, collections as cl, bisect as bs, heapq as hq
sys.setrecursionlimit(100000)
mod = 10**9 + 7
Max = sys.maxsize
def l(): # intのlist
return list(map(int, input().split()))
def m(): # 複数文字
return list(map(int, input().split()))
def onem(): # Nとかの取得
return int(eval(input()))
def s(x): # 圧縮
a = []
aa = x[0]
su = 1
for i in range(len(x) - 1):
if aa != x[i + 1]:
a.append([aa, su])
aa = x[i + 1]
su = 1
else:
su += 1
a.append([aa, su])
return a
def jo(x): # listをスペースごとに分ける
return " ".join(map(str, x))
def max2(x): # 他のときもどうように作成可能
return max(list(map(max, x)))
def In(x, a): # aがリスト(sorted)
k = bs.bisect_left(a, x)
if k != len(a) and a[k][0] == x:
return True
else:
return False
def search(a, n):
se = dict()
for i in range(0, len(a) - n + 1):
kkk = a[i : i + n]
kkk = "".join(kkk)
if kkk in se:
if se[kkk] <= i - n:
return True
else:
se[kkk] = i
return False
n = onem()
s = list(eval(input()))
l = 0
r = n // 2
while True:
mid = -(-(l + r) // 2)
ans = search(s, mid)
if l == mid:
break
if ans:
l = mid
else:
r = mid - 1
print(l)
| false | 12.903226 | [
"-input = sys.stdin.readline",
"+sys.setrecursionlimit(100000)",
"+mod = 10**9 + 7",
"+Max = sys.maxsize",
"+def s(x): # 圧縮",
"+ a = []",
"+ aa = x[0]",
"+ su = 1",
"+ for i in range(len(x) - 1):",
"+ if aa != x[i + 1]:",
"+ a.append([aa, su])",
"+ aa = x[i + 1]",
"+ su = 1",
"+ else:",
"+ su += 1",
"+ a.append([aa, su])",
"+ return a",
"+",
"+",
"+def max2(x): # 他のときもどうように作成可能",
"+ return max(list(map(max, x)))",
"+",
"+",
"- if k != len(a) and a[k] == x:",
"+ if k != len(a) and a[k][0] == x:",
"- data = []",
"- if In(kkk, data):",
"+ if kkk in se:",
"- bs.insort(data, kkk)",
"-def solver():",
"- n = onem()",
"- s = list(eval(input()))",
"- l = 0",
"- r = n // 2",
"- for i in range(n):",
"- mid = -(-(l + r) // 2)",
"- ans = search(s, mid)",
"- if l == mid:",
"- break",
"- if ans:",
"- l = mid",
"- else:",
"- r = mid - 1",
"- print(l)",
"-",
"-",
"-if __name__ == \"__main__\":",
"- solver()",
"+n = onem()",
"+s = list(eval(input()))",
"+l = 0",
"+r = n // 2",
"+while True:",
"+ mid = -(-(l + r) // 2)",
"+ ans = search(s, mid)",
"+ if l == mid:",
"+ break",
"+ if ans:",
"+ l = mid",
"+ else:",
"+ r = mid - 1",
"+print(l)"
] | false | 0.042391 | 0.043224 | 0.980739 | [
"s257005253",
"s386398519"
] |
u340781749 | p02794 | python | s352208651 | s081388689 | 2,185 | 656 | 43,832 | 42,344 | Accepted | Accepted | 69.98 | def dfs(s, t, links):
visited = set()
q = [(s, 0)]
while q:
v, used = q.pop()
if v == t:
return used
visited.add(v)
for lb, u in links[v]:
if u in visited:
continue
q.append((u, used | lb))
n = int(eval(input()))
links = [set() for _ in range(n)]
for i in range(n - 1):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
lb = 1 << i
links[a].add((lb, b))
links[b].add((lb, a))
conditions = []
m = int(eval(input()))
for i in range(m):
u, v = list(map(int, input().split()))
u -= 1
v -= 1
conditions.append(dfs(u, v, links))
ans = 0
for i in range(1 << m):
cnd_cnt = bin(i).count('1')
bit = 0
k = i
while k:
b = k & -k
j = b.bit_length() - 1
bit |= conditions[j]
k ^= b
free_link_cnt = n - 1 - bin(bit).count('1')
val = 2 ** free_link_cnt
if cnd_cnt % 2:
ans -= val
else:
ans += val
print(ans)
| def dfs(s, t, links):
visited = set()
q = [(s, 0)]
while q:
v, used = q.pop()
if v == t:
return used
visited.add(v)
for lb, u in links[v]:
if u in visited:
continue
q.append((u, used | lb))
def bitcount32(n):
n = ((n >> 1) & 0x5555555555555555) + (n & 0x5555555555555555)
n = ((n >> 2) & 0x3333333333333333) + (n & 0x3333333333333333)
n = ((n >> 4) & 0x0f0f0f0f0f0f0f0f) + (n & 0x0f0f0f0f0f0f0f0f)
n = ((n >> 8) & 0x00ff00ff00ff00ff) + (n & 0x00ff00ff00ff00ff)
n = ((n >> 16) & 0x0000ffff0000ffff) + (n & 0x0000ffff0000ffff)
n = ((n >> 32) & 0x00000000ffffffff) + (n & 0x00000000ffffffff)
return n
n = int(eval(input()))
links = [set() for _ in range(n)]
for i in range(n - 1):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
lb = 1 << i
links[a].add((lb, b))
links[b].add((lb, a))
conditions = []
m = int(eval(input()))
for i in range(m):
u, v = list(map(int, input().split()))
u -= 1
v -= 1
conditions.append(dfs(u, v, links))
ans = 0
for i in range(1 << m):
cnd_cnt = bitcount32(i)
bit = 0
k = i
while k:
b = k & -k
j = b.bit_length() - 1
bit |= conditions[j]
k ^= b
free_link_cnt = n - 1 - bitcount32(bit)
val = 2 ** free_link_cnt
if cnd_cnt % 2:
ans -= val
else:
ans += val
print(ans)
| 48 | 58 | 1,037 | 1,477 | def dfs(s, t, links):
visited = set()
q = [(s, 0)]
while q:
v, used = q.pop()
if v == t:
return used
visited.add(v)
for lb, u in links[v]:
if u in visited:
continue
q.append((u, used | lb))
n = int(eval(input()))
links = [set() for _ in range(n)]
for i in range(n - 1):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
lb = 1 << i
links[a].add((lb, b))
links[b].add((lb, a))
conditions = []
m = int(eval(input()))
for i in range(m):
u, v = list(map(int, input().split()))
u -= 1
v -= 1
conditions.append(dfs(u, v, links))
ans = 0
for i in range(1 << m):
cnd_cnt = bin(i).count("1")
bit = 0
k = i
while k:
b = k & -k
j = b.bit_length() - 1
bit |= conditions[j]
k ^= b
free_link_cnt = n - 1 - bin(bit).count("1")
val = 2**free_link_cnt
if cnd_cnt % 2:
ans -= val
else:
ans += val
print(ans)
| def dfs(s, t, links):
visited = set()
q = [(s, 0)]
while q:
v, used = q.pop()
if v == t:
return used
visited.add(v)
for lb, u in links[v]:
if u in visited:
continue
q.append((u, used | lb))
def bitcount32(n):
n = ((n >> 1) & 0x5555555555555555) + (n & 0x5555555555555555)
n = ((n >> 2) & 0x3333333333333333) + (n & 0x3333333333333333)
n = ((n >> 4) & 0x0F0F0F0F0F0F0F0F) + (n & 0x0F0F0F0F0F0F0F0F)
n = ((n >> 8) & 0x00FF00FF00FF00FF) + (n & 0x00FF00FF00FF00FF)
n = ((n >> 16) & 0x0000FFFF0000FFFF) + (n & 0x0000FFFF0000FFFF)
n = ((n >> 32) & 0x00000000FFFFFFFF) + (n & 0x00000000FFFFFFFF)
return n
n = int(eval(input()))
links = [set() for _ in range(n)]
for i in range(n - 1):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
lb = 1 << i
links[a].add((lb, b))
links[b].add((lb, a))
conditions = []
m = int(eval(input()))
for i in range(m):
u, v = list(map(int, input().split()))
u -= 1
v -= 1
conditions.append(dfs(u, v, links))
ans = 0
for i in range(1 << m):
cnd_cnt = bitcount32(i)
bit = 0
k = i
while k:
b = k & -k
j = b.bit_length() - 1
bit |= conditions[j]
k ^= b
free_link_cnt = n - 1 - bitcount32(bit)
val = 2**free_link_cnt
if cnd_cnt % 2:
ans -= val
else:
ans += val
print(ans)
| false | 17.241379 | [
"+",
"+",
"+def bitcount32(n):",
"+ n = ((n >> 1) & 0x5555555555555555) + (n & 0x5555555555555555)",
"+ n = ((n >> 2) & 0x3333333333333333) + (n & 0x3333333333333333)",
"+ n = ((n >> 4) & 0x0F0F0F0F0F0F0F0F) + (n & 0x0F0F0F0F0F0F0F0F)",
"+ n = ((n >> 8) & 0x00FF00FF00FF00FF) + (n & 0x00FF00FF00FF00FF)",
"+ n = ((n >> 16) & 0x0000FFFF0000FFFF) + (n & 0x0000FFFF0000FFFF)",
"+ n = ((n >> 32) & 0x00000000FFFFFFFF) + (n & 0x00000000FFFFFFFF)",
"+ return n",
"- cnd_cnt = bin(i).count(\"1\")",
"+ cnd_cnt = bitcount32(i)",
"- free_link_cnt = n - 1 - bin(bit).count(\"1\")",
"+ free_link_cnt = n - 1 - bitcount32(bit)"
] | false | 0.055729 | 0.081225 | 0.686111 | [
"s352208651",
"s081388689"
] |
u261103969 | p02695 | python | s871599169 | s331935500 | 1,099 | 642 | 9,200 | 9,420 | Accepted | Accepted | 41.58 | from itertools import combinations_with_replacement
n, m, q = list(map(int, input().split()))
req = [list(map(int, input().split())) for _ in range(q)]
ans = 0
for seq in combinations_with_replacement(list(range(1, m + 1)), n):
score = 0
for a, b, c, d in req:
if seq[b - 1] - seq[a - 1] == c:
score += d
ans = max(ans, score)
print(ans)
| from collections import deque
def calc(nums):
ret = 0
for a, b, c, d in req:
if nums[b - 1] - nums[a - 1] == c:
ret += d
return ret
n, m, q = list(map(int, input().split()))
req = [list(map(int, input().split())) for _ in range(q)]
ans = 0
que = deque()
# [1]~[m]までキューに追加します。実は[1]だけでもいいです。考えてみてください。
for i in range(1, m + 1):
que.append([i])
while que:
seq = que.pop()
if len(seq) == n:
score = calc(seq)
ans = max(ans, score)
else:
for i in range(seq[-1], m + 1):
seq_next = seq + [i]
que.append(seq_next)
print(ans)
| 14 | 35 | 380 | 659 | from itertools import combinations_with_replacement
n, m, q = list(map(int, input().split()))
req = [list(map(int, input().split())) for _ in range(q)]
ans = 0
for seq in combinations_with_replacement(list(range(1, m + 1)), n):
score = 0
for a, b, c, d in req:
if seq[b - 1] - seq[a - 1] == c:
score += d
ans = max(ans, score)
print(ans)
| from collections import deque
def calc(nums):
ret = 0
for a, b, c, d in req:
if nums[b - 1] - nums[a - 1] == c:
ret += d
return ret
n, m, q = list(map(int, input().split()))
req = [list(map(int, input().split())) for _ in range(q)]
ans = 0
que = deque()
# [1]~[m]までキューに追加します。実は[1]だけでもいいです。考えてみてください。
for i in range(1, m + 1):
que.append([i])
while que:
seq = que.pop()
if len(seq) == n:
score = calc(seq)
ans = max(ans, score)
else:
for i in range(seq[-1], m + 1):
seq_next = seq + [i]
que.append(seq_next)
print(ans)
| false | 60 | [
"-from itertools import combinations_with_replacement",
"+from collections import deque",
"+",
"+",
"+def calc(nums):",
"+ ret = 0",
"+ for a, b, c, d in req:",
"+ if nums[b - 1] - nums[a - 1] == c:",
"+ ret += d",
"+ return ret",
"+",
"-for seq in combinations_with_replacement(list(range(1, m + 1)), n):",
"- score = 0",
"- for a, b, c, d in req:",
"- if seq[b - 1] - seq[a - 1] == c:",
"- score += d",
"- ans = max(ans, score)",
"+que = deque()",
"+# [1]~[m]までキューに追加します。実は[1]だけでもいいです。考えてみてください。",
"+for i in range(1, m + 1):",
"+ que.append([i])",
"+while que:",
"+ seq = que.pop()",
"+ if len(seq) == n:",
"+ score = calc(seq)",
"+ ans = max(ans, score)",
"+ else:",
"+ for i in range(seq[-1], m + 1):",
"+ seq_next = seq + [i]",
"+ que.append(seq_next)"
] | false | 0.135317 | 0.084401 | 1.603268 | [
"s871599169",
"s331935500"
] |
u693391925 | p02924 | python | s737157289 | s816419452 | 182 | 167 | 38,256 | 38,384 | Accepted | Accepted | 8.24 | n = int(eval(input()))
print((n * (n-1) // 2)) | n = int(eval(input()))
print(((n * (n-1)) // 2)) | 2 | 2 | 39 | 41 | n = int(eval(input()))
print((n * (n - 1) // 2))
| n = int(eval(input()))
print(((n * (n - 1)) // 2))
| false | 0 | [
"-print((n * (n - 1) // 2))",
"+print(((n * (n - 1)) // 2))"
] | false | 0.035088 | 0.035583 | 0.986083 | [
"s737157289",
"s816419452"
] |
u128456980 | p02775 | python | s596637826 | s417629625 | 413 | 298 | 138,044 | 53,136 | Accepted | Accepted | 27.85 | s = eval(input()); n = len(s)
dp = [ [0,1<<32] for i in range(n+1) ]
for i in range(n):
d = ord(s[i])-ord('0')
dp[i+1][0] = min(dp[i][0], dp[i][1])+d
dp[i+1][1] = min(dp[i][0], dp[i][1]-2)+11-d
print((min(dp[n][0],dp[n][1]))) | s = eval(input()); n = len(s)
dp = [ [0,1<<32] for i in range(2) ]
for i in range(n):
d = ord(s[i])-ord('0')
dp[(i+1)%2][0] = min(dp[i%2][0], dp[i%2][1])+d
dp[(i+1)%2][1] = min(dp[i%2][0], dp[i%2][1]-2)+11-d
print((min(dp[n%2][0],dp[n%2][1]))) | 7 | 7 | 229 | 247 | s = eval(input())
n = len(s)
dp = [[0, 1 << 32] for i in range(n + 1)]
for i in range(n):
d = ord(s[i]) - ord("0")
dp[i + 1][0] = min(dp[i][0], dp[i][1]) + d
dp[i + 1][1] = min(dp[i][0], dp[i][1] - 2) + 11 - d
print((min(dp[n][0], dp[n][1])))
| s = eval(input())
n = len(s)
dp = [[0, 1 << 32] for i in range(2)]
for i in range(n):
d = ord(s[i]) - ord("0")
dp[(i + 1) % 2][0] = min(dp[i % 2][0], dp[i % 2][1]) + d
dp[(i + 1) % 2][1] = min(dp[i % 2][0], dp[i % 2][1] - 2) + 11 - d
print((min(dp[n % 2][0], dp[n % 2][1])))
| false | 0 | [
"-dp = [[0, 1 << 32] for i in range(n + 1)]",
"+dp = [[0, 1 << 32] for i in range(2)]",
"- dp[i + 1][0] = min(dp[i][0], dp[i][1]) + d",
"- dp[i + 1][1] = min(dp[i][0], dp[i][1] - 2) + 11 - d",
"-print((min(dp[n][0], dp[n][1])))",
"+ dp[(i + 1) % 2][0] = min(dp[i % 2][0], dp[i % 2][1]) + d",
"+ dp[(i + 1) % 2][1] = min(dp[i % 2][0], dp[i % 2][1] - 2) + 11 - d",
"+print((min(dp[n % 2][0], dp[n % 2][1])))"
] | false | 0.046815 | 0.048403 | 0.967194 | [
"s596637826",
"s417629625"
] |
u721316601 | p02947 | python | s774952249 | s120854113 | 481 | 233 | 18,236 | 17,808 | Accepted | Accepted | 51.56 | from collections import Counter
count = Counter()
for i in range(int(eval(input()))):
s = sorted(eval(input()))
count[''.join(s)] += 1
ans = 0
for n in list(count.values()):
if n >= 2:
ans += (n**2 - n) // 2
print(ans) | import sys
input = sys.stdin.readline
def main():
x = {}
N = int(eval(input()))
for i in range(N):
s = sorted(eval(input()))
s = ''.join(s)
if s in x: x[s] += 1
else: x[s] = 1
ans = 0
for n in list(x.values()):
ans += (n*(n-1)//2)
print(ans)
if __name__ == '__main__':
main() | 14 | 23 | 226 | 374 | from collections import Counter
count = Counter()
for i in range(int(eval(input()))):
s = sorted(eval(input()))
count["".join(s)] += 1
ans = 0
for n in list(count.values()):
if n >= 2:
ans += (n**2 - n) // 2
print(ans)
| import sys
input = sys.stdin.readline
def main():
x = {}
N = int(eval(input()))
for i in range(N):
s = sorted(eval(input()))
s = "".join(s)
if s in x:
x[s] += 1
else:
x[s] = 1
ans = 0
for n in list(x.values()):
ans += n * (n - 1) // 2
print(ans)
if __name__ == "__main__":
main()
| false | 39.130435 | [
"-from collections import Counter",
"+import sys",
"-count = Counter()",
"-for i in range(int(eval(input()))):",
"- s = sorted(eval(input()))",
"- count[\"\".join(s)] += 1",
"-ans = 0",
"-for n in list(count.values()):",
"- if n >= 2:",
"- ans += (n**2 - n) // 2",
"-print(ans)",
"+input = sys.stdin.readline",
"+",
"+",
"+def main():",
"+ x = {}",
"+ N = int(eval(input()))",
"+ for i in range(N):",
"+ s = sorted(eval(input()))",
"+ s = \"\".join(s)",
"+ if s in x:",
"+ x[s] += 1",
"+ else:",
"+ x[s] = 1",
"+ ans = 0",
"+ for n in list(x.values()):",
"+ ans += n * (n - 1) // 2",
"+ print(ans)",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.11705 | 0.04702 | 2.489381 | [
"s774952249",
"s120854113"
] |
u250583425 | p02732 | python | s783761936 | s986186820 | 1,551 | 178 | 32,940 | 32,952 | Accepted | Accepted | 88.52 | import sys
from math import factorial
from collections import Counter
def input(): return sys.stdin.readline().rstrip()
def main():
N = int(eval(input()))
A = tuple(map(int, input().split()))
c = Counter(A)
data = [0] * (N+1)
sum_count = 0
for i, v in list(c.items()):
if v < 2:
continue
value = factorial(v) // 2 // factorial(v - 2)
data[i] = value - value * (v - 2) // v
sum_count += value
print(('\n'.join([str(sum_count - data[a]) for a in A])))
if __name__ == '__main__':
main() | import sys
from collections import Counter
def input(): return sys.stdin.readline().rstrip()
def main():
N = int(eval(input()))
A = tuple(map(int, input().split()))
c = Counter(A)
data = [0] * (N+1)
sum_count = 0
for i, v in list(c.items()):
if v < 2:
continue
value = v * (v - 1) // 2
data[i] = value - value * (v - 2) // v
sum_count += value
print(('\n'.join([str(sum_count - data[a]) for a in A])))
if __name__ == '__main__':
main()
| 23 | 22 | 571 | 523 | import sys
from math import factorial
from collections import Counter
def input():
return sys.stdin.readline().rstrip()
def main():
N = int(eval(input()))
A = tuple(map(int, input().split()))
c = Counter(A)
data = [0] * (N + 1)
sum_count = 0
for i, v in list(c.items()):
if v < 2:
continue
value = factorial(v) // 2 // factorial(v - 2)
data[i] = value - value * (v - 2) // v
sum_count += value
print(("\n".join([str(sum_count - data[a]) for a in A])))
if __name__ == "__main__":
main()
| import sys
from collections import Counter
def input():
return sys.stdin.readline().rstrip()
def main():
N = int(eval(input()))
A = tuple(map(int, input().split()))
c = Counter(A)
data = [0] * (N + 1)
sum_count = 0
for i, v in list(c.items()):
if v < 2:
continue
value = v * (v - 1) // 2
data[i] = value - value * (v - 2) // v
sum_count += value
print(("\n".join([str(sum_count - data[a]) for a in A])))
if __name__ == "__main__":
main()
| false | 4.347826 | [
"-from math import factorial",
"- value = factorial(v) // 2 // factorial(v - 2)",
"+ value = v * (v - 1) // 2"
] | false | 0.057888 | 0.036595 | 1.581874 | [
"s783761936",
"s986186820"
] |
u557168336 | p03262 | python | s017518003 | s735074156 | 361 | 254 | 89,236 | 64,024 | Accepted | Accepted | 29.64 | # from fractions import gcd
gcd = __import__("fractions").gcd
N, X = list(map(int, input().split()))
V = list(map(int, input().split()))
V.append(X)
V.sort()
vD = [V[i+1]-V[i] for i in range(len(V)-1)]
vD.sort()
res = vD[0]
for d in vD:
res = gcd(res, d)
print(res) | # from fractions import gcd
# gcd = __import__("fractions").gcd
def gcd(a, b):
if b == 0:
return a
return gcd(b, a%b)
N, X = list(map(int, input().split()))
V = list(map(int, input().split()))
V.append(X)
V.sort()
vD = [V[i+1]-V[i] for i in range(len(V)-1)]
vD.sort()
res = vD[0]
for d in vD:
res = gcd(res, d)
if res <= 1:
break
print(res) | 14 | 21 | 278 | 389 | # from fractions import gcd
gcd = __import__("fractions").gcd
N, X = list(map(int, input().split()))
V = list(map(int, input().split()))
V.append(X)
V.sort()
vD = [V[i + 1] - V[i] for i in range(len(V) - 1)]
vD.sort()
res = vD[0]
for d in vD:
res = gcd(res, d)
print(res)
| # from fractions import gcd
# gcd = __import__("fractions").gcd
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
N, X = list(map(int, input().split()))
V = list(map(int, input().split()))
V.append(X)
V.sort()
vD = [V[i + 1] - V[i] for i in range(len(V) - 1)]
vD.sort()
res = vD[0]
for d in vD:
res = gcd(res, d)
if res <= 1:
break
print(res)
| false | 33.333333 | [
"-gcd = __import__(\"fractions\").gcd",
"+# gcd = __import__(\"fractions\").gcd",
"+def gcd(a, b):",
"+ if b == 0:",
"+ return a",
"+ return gcd(b, a % b)",
"+",
"+",
"+ if res <= 1:",
"+ break"
] | false | 0.093567 | 0.061129 | 1.530641 | [
"s017518003",
"s735074156"
] |
u847923740 | p03163 | python | s890944458 | s059762403 | 782 | 159 | 171,656 | 69,456 | Accepted | Accepted | 79.67 | N,W=list(map(int,input().split()))
wv=[[0,0]]+[list(map(int,input().split())) for _ in range(N)]
dp=[[0 for i in range(W+1)] for j in range(N+1)]
for i in range(1,N+1):
for j in range(W+1):
dp[i][j]=dp[i-1][j]
if j - wv[i][0] >= 0:
dp[i][j]=max(dp[i][j],dp[i-1][j-wv[i][0]]+wv[i][1])
print((max(dp[N])))
| N, W = list(map(int, input().split()))
w = []
v = []
for i in range(N):
wi, vi = list(map(int, input().split()))
w.append(wi)
v.append(vi)
dp = [0] * (W + 1)
dp[w[0]] = v[0]
for i in range(1, N):
for j in range(W, -1, -1):
if j - w[i] >= 0 and dp[j - w[i]] + v[i] > dp[j]:
dp[j] = max(dp[j], dp[j - w[i]] + v[i])
print((max(dp))) | 13 | 16 | 356 | 341 | N, W = list(map(int, input().split()))
wv = [[0, 0]] + [list(map(int, input().split())) for _ in range(N)]
dp = [[0 for i in range(W + 1)] for j in range(N + 1)]
for i in range(1, N + 1):
for j in range(W + 1):
dp[i][j] = dp[i - 1][j]
if j - wv[i][0] >= 0:
dp[i][j] = max(dp[i][j], dp[i - 1][j - wv[i][0]] + wv[i][1])
print((max(dp[N])))
| N, W = list(map(int, input().split()))
w = []
v = []
for i in range(N):
wi, vi = list(map(int, input().split()))
w.append(wi)
v.append(vi)
dp = [0] * (W + 1)
dp[w[0]] = v[0]
for i in range(1, N):
for j in range(W, -1, -1):
if j - w[i] >= 0 and dp[j - w[i]] + v[i] > dp[j]:
dp[j] = max(dp[j], dp[j - w[i]] + v[i])
print((max(dp)))
| false | 18.75 | [
"-wv = [[0, 0]] + [list(map(int, input().split())) for _ in range(N)]",
"-dp = [[0 for i in range(W + 1)] for j in range(N + 1)]",
"-for i in range(1, N + 1):",
"- for j in range(W + 1):",
"- dp[i][j] = dp[i - 1][j]",
"- if j - wv[i][0] >= 0:",
"- dp[i][j] = max(dp[i][j], dp[i - 1][j - wv[i][0]] + wv[i][1])",
"-print((max(dp[N])))",
"+w = []",
"+v = []",
"+for i in range(N):",
"+ wi, vi = list(map(int, input().split()))",
"+ w.append(wi)",
"+ v.append(vi)",
"+dp = [0] * (W + 1)",
"+dp[w[0]] = v[0]",
"+for i in range(1, N):",
"+ for j in range(W, -1, -1):",
"+ if j - w[i] >= 0 and dp[j - w[i]] + v[i] > dp[j]:",
"+ dp[j] = max(dp[j], dp[j - w[i]] + v[i])",
"+print((max(dp)))"
] | false | 0.071024 | 0.074061 | 0.958995 | [
"s890944458",
"s059762403"
] |
u013629972 | p03089 | python | s565547400 | s168627676 | 291 | 174 | 65,388 | 38,640 | Accepted | Accepted | 40.21 | import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in input().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 I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)
N = I()
b = LI()
result = []
while True:
# print(b)
for i in range(1, len(b)+1):
# print(i)
if b[-i] == len(b)-i+1:
# print('break')
result.append(b[-i])
b.pop(-i)
break
else:
if not b:
break
print(-1)
exit()
for i in result[::-1]:
print(i)
| N = int(input())
B = [int(x) - 1 for x in input().split()]
# print('b', B)
ans = []
while B:
popped = -1
for i in reversed(range(len(B))):
if B[i] == i:
ans.append(i + 1)
popped = B.pop(i)
break
if popped == -1:
print(-1)
quit()
print(*ans[::-1], sep="\n")
| 38 | 15 | 1,069 | 344 | import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI():
return [int(x) for x in input().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 I():
return int(sys.stdin.readline())
def F():
return float(sys.stdin.readline())
def pf(s):
return print(s, flush=True)
N = I()
b = LI()
result = []
while True:
# print(b)
for i in range(1, len(b) + 1):
# print(i)
if b[-i] == len(b) - i + 1:
# print('break')
result.append(b[-i])
b.pop(-i)
break
else:
if not b:
break
print(-1)
exit()
for i in result[::-1]:
print(i)
| N = int(input())
B = [int(x) - 1 for x in input().split()]
# print('b', B)
ans = []
while B:
popped = -1
for i in reversed(range(len(B))):
if B[i] == i:
ans.append(i + 1)
popped = B.pop(i)
break
if popped == -1:
print(-1)
quit()
print(*ans[::-1], sep="\n")
| false | 60.526316 | [
"-import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools",
"-",
"-sys.setrecursionlimit(10**7)",
"-inf = 10**20",
"-eps = 1.0 / 10**10",
"-mod = 10**9 + 7",
"-dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]",
"-ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]",
"-",
"-",
"-def LI():",
"- return [int(x) for x in input().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 I():",
"- return int(sys.stdin.readline())",
"-",
"-",
"-def F():",
"- return float(sys.stdin.readline())",
"-",
"-",
"-def pf(s):",
"- return print(s, flush=True)",
"-",
"-",
"-N = I()",
"-b = LI()",
"-result = []",
"-while True:",
"- # print(b)",
"- for i in range(1, len(b) + 1):",
"- # print(i)",
"- if b[-i] == len(b) - i + 1:",
"- # print('break')",
"- result.append(b[-i])",
"- b.pop(-i)",
"+N = int(input())",
"+B = [int(x) - 1 for x in input().split()]",
"+# print('b', B)",
"+ans = []",
"+while B:",
"+ popped = -1",
"+ for i in reversed(range(len(B))):",
"+ if B[i] == i:",
"+ ans.append(i + 1)",
"+ popped = B.pop(i)",
"- else:",
"- if not b:",
"- break",
"+ if popped == -1:",
"- exit()",
"-for i in result[::-1]:",
"- print(i)",
"+ quit()",
"+print(*ans[::-1], sep=\"\\n\")"
] | false | 0.115274 | 0.034011 | 3.389349 | [
"s565547400",
"s168627676"
] |
u143492911 | p03487 | python | s289015428 | s026159962 | 105 | 88 | 23,800 | 18,132 | Accepted | Accepted | 16.19 | n=int(eval(input()))
a=list(map(int,input().split()))
set_a=set(a)
import collections
count=0
data=collections.Counter(a)
for i,j in list(data.items()):
if i<j:
count+=j-i
elif j<i:
count+=j
print(count) | n=int(eval(input()))
a=list(map(int,input().split()))
from collections import Counter
data=Counter(a)
ans=0
for i,j in list(data.items()):
if i<j:
ans+=j-i
elif j<i:
ans+=j
print(ans)
| 12 | 11 | 226 | 206 | n = int(eval(input()))
a = list(map(int, input().split()))
set_a = set(a)
import collections
count = 0
data = collections.Counter(a)
for i, j in list(data.items()):
if i < j:
count += j - i
elif j < i:
count += j
print(count)
| n = int(eval(input()))
a = list(map(int, input().split()))
from collections import Counter
data = Counter(a)
ans = 0
for i, j in list(data.items()):
if i < j:
ans += j - i
elif j < i:
ans += j
print(ans)
| false | 8.333333 | [
"-set_a = set(a)",
"-import collections",
"+from collections import Counter",
"-count = 0",
"-data = collections.Counter(a)",
"+data = Counter(a)",
"+ans = 0",
"- count += j - i",
"+ ans += j - i",
"- count += j",
"-print(count)",
"+ ans += j",
"+print(ans)"
] | false | 0.038678 | 0.039966 | 0.967779 | [
"s289015428",
"s026159962"
] |
u334712262 | p03488 | python | s654468951 | s849019724 | 520 | 316 | 84,952 | 92,252 | Accepted | Accepted | 39.23 | # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul
sys.setrecursionlimit(10000)
def read_int():
return int(input())
def read_int_n():
return list(map(int, input().split()))
def read_float():
return float(input())
def read_float_n():
return list(map(float, input().split()))
def read_str():
return input()
def read_str_n():
return list(map(str, input().split()))
def error_print(*args):
print(*args, file=sys.stderr)
def mt(f):
import time
def wrap(*args, **kwargs):
s = time.time()
ret = f(*args, **kwargs)
e = time.time()
error_print(e - s, 'sec')
return ret
return wrap
move = None
tx = None
ty = None
@mt
def slv(S, x, y):
tx = x
ty = y
move = list(map(lambda x: len(x), S.split('T')))
xm = [move[0]]
for i in range(2, len(move), 2):
xm_ = []
for x in xm:
xm_.append(x + move[i])
xm_.append(x - move[i])
xm = set(xm_)
ym = [0]
for i in range(1, len(move), 2):
ym_ = []
for y in ym:
ym_.append(y + move[i])
ym_.append(y - move[i])
ym = set(ym_)
return 'Yes' if tx in xm and ty in ym else 'No'
def main():
S = read_str().strip()
x, y = read_int_n()
print(slv(S, x, y))
if __name__ == '__main__':
main()
| # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
from operator import add, mul, sub, itemgetter, attrgetter
import sys
# sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline
INF = 2**62-1
def read_int():
return int(readline())
def read_int_n():
return list(map(int, readline().split()))
def read_float():
return float(readline())
def read_float_n():
return list(map(float, readline().split()))
def read_str():
return readline().strip()
def read_str_n():
return readline().strip().split()
def error_print(*args):
print(*args, file=sys.stderr)
def mt(f):
import time
def wrap(*args, **kwargs):
s = time.perf_counter()
ret = f(*args, **kwargs)
e = time.perf_counter()
error_print(e - s, 'sec')
return ret
return wrap
@mt
def slv(S, X, Y):
n = 0
m = []
for c in S:
if c == 'T':
m.append(n)
n = 0
else:
n += 1
else:
m.append(n)
X -= m.pop(0)
ym = m[::2]
xm = m[1::2]
memo = {0}
for dx in xm:
nm = set()
for x in memo:
nm.add(x+dx)
nm.add(x-dx)
memo = nm
if X not in memo:
return 'No'
memo = {0}
for dy in ym:
nm = set()
for y in memo:
nm.add(y+dy)
nm.add(y-dy)
memo = nm
if Y not in memo:
return 'No'
return 'Yes'
def main():
S = read_str()
X, Y = read_int_n()
print(slv(S, X, Y))
if __name__ == '__main__':
main()
| 94 | 113 | 1,750 | 2,035 | # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul
sys.setrecursionlimit(10000)
def read_int():
return int(input())
def read_int_n():
return list(map(int, input().split()))
def read_float():
return float(input())
def read_float_n():
return list(map(float, input().split()))
def read_str():
return input()
def read_str_n():
return list(map(str, input().split()))
def error_print(*args):
print(*args, file=sys.stderr)
def mt(f):
import time
def wrap(*args, **kwargs):
s = time.time()
ret = f(*args, **kwargs)
e = time.time()
error_print(e - s, "sec")
return ret
return wrap
move = None
tx = None
ty = None
@mt
def slv(S, x, y):
tx = x
ty = y
move = list(map(lambda x: len(x), S.split("T")))
xm = [move[0]]
for i in range(2, len(move), 2):
xm_ = []
for x in xm:
xm_.append(x + move[i])
xm_.append(x - move[i])
xm = set(xm_)
ym = [0]
for i in range(1, len(move), 2):
ym_ = []
for y in ym:
ym_.append(y + move[i])
ym_.append(y - move[i])
ym = set(ym_)
return "Yes" if tx in xm and ty in ym else "No"
def main():
S = read_str().strip()
x, y = read_int_n()
print(slv(S, x, y))
if __name__ == "__main__":
main()
| # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import (
combinations,
combinations_with_replacement,
product,
permutations,
accumulate,
)
from operator import add, mul, sub, itemgetter, attrgetter
import sys
# sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline
INF = 2**62 - 1
def read_int():
return int(readline())
def read_int_n():
return list(map(int, readline().split()))
def read_float():
return float(readline())
def read_float_n():
return list(map(float, readline().split()))
def read_str():
return readline().strip()
def read_str_n():
return readline().strip().split()
def error_print(*args):
print(*args, file=sys.stderr)
def mt(f):
import time
def wrap(*args, **kwargs):
s = time.perf_counter()
ret = f(*args, **kwargs)
e = time.perf_counter()
error_print(e - s, "sec")
return ret
return wrap
@mt
def slv(S, X, Y):
n = 0
m = []
for c in S:
if c == "T":
m.append(n)
n = 0
else:
n += 1
else:
m.append(n)
X -= m.pop(0)
ym = m[::2]
xm = m[1::2]
memo = {0}
for dx in xm:
nm = set()
for x in memo:
nm.add(x + dx)
nm.add(x - dx)
memo = nm
if X not in memo:
return "No"
memo = {0}
for dy in ym:
nm = set()
for y in memo:
nm.add(y + dy)
nm.add(y - dy)
memo = nm
if Y not in memo:
return "No"
return "Yes"
def main():
S = read_str()
X, Y = read_int_n()
print(slv(S, X, Y))
if __name__ == "__main__":
main()
| false | 16.814159 | [
"+from collections import Counter, defaultdict, deque",
"+from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal",
"+from fractions import Fraction",
"+from functools import lru_cache, reduce",
"+from itertools import (",
"+ combinations,",
"+ combinations_with_replacement,",
"+ product,",
"+ permutations,",
"+ accumulate,",
"+)",
"+from operator import add, mul, sub, itemgetter, attrgetter",
"-from collections import Counter, defaultdict",
"-from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal",
"-from functools import lru_cache, reduce",
"-from itertools import combinations, combinations_with_replacement, product, permutations",
"-from operator import add, mul",
"-sys.setrecursionlimit(10000)",
"+# sys.setrecursionlimit(10**6)",
"+# readline = sys.stdin.buffer.readline",
"+readline = sys.stdin.readline",
"+INF = 2**62 - 1",
"- return int(input())",
"+ return int(readline())",
"- return list(map(int, input().split()))",
"+ return list(map(int, readline().split()))",
"- return float(input())",
"+ return float(readline())",
"- return list(map(float, input().split()))",
"+ return list(map(float, readline().split()))",
"- return input()",
"+ return readline().strip()",
"- return list(map(str, input().split()))",
"+ return readline().strip().split()",
"- s = time.time()",
"+ s = time.perf_counter()",
"- e = time.time()",
"+ e = time.perf_counter()",
"-move = None",
"-tx = None",
"-ty = None",
"-",
"-",
"-def slv(S, x, y):",
"- tx = x",
"- ty = y",
"- move = list(map(lambda x: len(x), S.split(\"T\")))",
"- xm = [move[0]]",
"- for i in range(2, len(move), 2):",
"- xm_ = []",
"- for x in xm:",
"- xm_.append(x + move[i])",
"- xm_.append(x - move[i])",
"- xm = set(xm_)",
"- ym = [0]",
"- for i in range(1, len(move), 2):",
"- ym_ = []",
"- for y in ym:",
"- ym_.append(y + move[i])",
"- ym_.append(y - move[i])",
"- ym = set(ym_)",
"- return \"Yes\" if tx in xm and ty in ym else \"No\"",
"+def slv(S, X, Y):",
"+ n = 0",
"+ m = []",
"+ for c in S:",
"+ if c == \"T\":",
"+ m.append(n)",
"+ n = 0",
"+ else:",
"+ n += 1",
"+ else:",
"+ m.append(n)",
"+ X -= m.pop(0)",
"+ ym = m[::2]",
"+ xm = m[1::2]",
"+ memo = {0}",
"+ for dx in xm:",
"+ nm = set()",
"+ for x in memo:",
"+ nm.add(x + dx)",
"+ nm.add(x - dx)",
"+ memo = nm",
"+ if X not in memo:",
"+ return \"No\"",
"+ memo = {0}",
"+ for dy in ym:",
"+ nm = set()",
"+ for y in memo:",
"+ nm.add(y + dy)",
"+ nm.add(y - dy)",
"+ memo = nm",
"+ if Y not in memo:",
"+ return \"No\"",
"+ return \"Yes\"",
"- S = read_str().strip()",
"- x, y = read_int_n()",
"- print(slv(S, x, y))",
"+ S = read_str()",
"+ X, Y = read_int_n()",
"+ print(slv(S, X, Y))"
] | false | 0.040416 | 0.037963 | 1.064625 | [
"s654468951",
"s849019724"
] |
u345966487 | p04005 | python | s874420163 | s318719003 | 28 | 25 | 9,108 | 9,160 | Accepted | Accepted | 10.71 | import sys
sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))
a, b, c = inl()
def solve():
ans = min(
[
abs((a // 2) - (a - a // 2)) * b * c,
abs((b // 2) - (b - b // 2)) * a * c,
abs((c // 2) - (c - c // 2)) * b * a,
]
)
return ans
print(solve())
| import sys
sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))
def solve():
A, B, C = inl()
if A % 2 == 0 or B % 2 == 0 or C % 2 == 0:
return 0
x = sorted([A, B, C])
return x[0] * x[1]
print(solve())
| 25 | 19 | 575 | 461 | import sys
sys.setrecursionlimit(10**8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))
a, b, c = inl()
def solve():
ans = min(
[
abs((a // 2) - (a - a // 2)) * b * c,
abs((b // 2) - (b - b // 2)) * a * c,
abs((c // 2) - (c - c // 2)) * b * a,
]
)
return ans
print(solve())
| import sys
sys.setrecursionlimit(10**8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))
def solve():
A, B, C = inl()
if A % 2 == 0 or B % 2 == 0 or C % 2 == 0:
return 0
x = sorted([A, B, C])
return x[0] * x[1]
print(solve())
| false | 24 | [
"-inm = lambda: map(int, sys.stdin.readline().split())",
"-inl = lambda: list(inm())",
"+inl = lambda: [int(x) for x in sys.stdin.readline().split()]",
"-a, b, c = inl()",
"- ans = min(",
"- [",
"- abs((a // 2) - (a - a // 2)) * b * c,",
"- abs((b // 2) - (b - b // 2)) * a * c,",
"- abs((c // 2) - (c - c // 2)) * b * a,",
"- ]",
"- )",
"- return ans",
"+ A, B, C = inl()",
"+ if A % 2 == 0 or B % 2 == 0 or C % 2 == 0:",
"+ return 0",
"+ x = sorted([A, B, C])",
"+ return x[0] * x[1]"
] | false | 0.071774 | 0.037329 | 1.922722 | [
"s874420163",
"s318719003"
] |
u512212329 | p02579 | python | s599166305 | s469822619 | 1,503 | 1,249 | 312,864 | 247,836 | Accepted | Accepted | 16.9 | # 参考: White_Pie_46
# https://atcoder.jp/contests/abc176/submissions/16168825
from collections import deque
def main():
height, width = [int(x) for x in input().split()]
init_h, init_w = [int(x) - 1 for x in input().split()]
dest_h, dest_w = [int(x) - 1 for x in input().split()]
grid = [list(eval(input())) for _ in range(height)]
adjacents = (
(1, 0),
(0, 1),
(-1, 0),
(0, -1)
)
def gen_warp_can_reach():
for h in range(-2, 3):
for w in range(-2, 3):
if h == 0 == w:
continue
if (h, w) in adjacents:
continue
yield (h, w)
warp_can_reach = tuple(gen_warp_can_reach())
qu = deque()
qu.append((init_h, init_w, 0)) # 座標とワープ回数を保持
reached = set()
while qu:
h, w, warps = qu.popleft()
if h == dest_h and w == dest_w:
return warps
if (h, w) in reached:
# 同じマスを複数回キューに追加しているかもしれない。
# 短距離で調査済みなら再調査は不要。
continue
reached.add((h, w))
for h_delta, w_delta in adjacents:
new_h, new_w = h + h_delta, w + w_delta
if 0 <= new_h < height and 0 <= new_w < width:
if grid[new_h][new_w] == '.':
qu.appendleft((new_h, new_w, warps))
for h_delta, w_delta in warp_can_reach:
new_h, new_w = h + h_delta, w + w_delta
if 0 <= new_h < height and 0 <= new_w < width:
if grid[new_h][new_w] == '.':
qu.append((new_h, new_w, warps + 1))
return -1
if __name__ == '__main__':
print((main()))
| # 参考: White_Pie_46
# https://atcoder.jp/contests/abc176/submissions/16168825
from collections import deque
def main():
height, width = [int(x) for x in input().split()]
init_h, init_w = [int(x) - 1 for x in input().split()]
dest_h, dest_w = [int(x) - 1 for x in input().split()]
grid = [list(eval(input())) for _ in range(height)]
adjacents = (
(1, 0),
(0, 1),
(-1, 0),
(0, -1)
)
def gen_warp_can_reach():
for h in range(-2, 3):
for w in range(-2, 3):
if h == 0 == w:
continue
if (h, w) in adjacents:
continue
yield (h, w)
warp_can_reach = tuple(gen_warp_can_reach())
qu = deque()
qu.append((init_h, init_w, 0)) # 座標とワープ回数を保持
reached = set()
while qu:
h, w, warps = qu.popleft()
if h == dest_h and w == dest_w:
return warps
if (h, w) in reached:
# 同じマスを複数回キューに追加しているかもしれない。
# 短距離で調査済みなら再調査は不要。
continue
reached.add((h, w))
for h_delta, w_delta in adjacents:
new_h, new_w = h + h_delta, w + w_delta
if 0 <= new_h < height and 0 <= new_w < width:
if grid[new_h][new_w] == '.':
if (new_h, new_w) not in reached:
qu.appendleft((new_h, new_w, warps))
for h_delta, w_delta in warp_can_reach:
new_h, new_w = h + h_delta, w + w_delta
if 0 <= new_h < height and 0 <= new_w < width:
if grid[new_h][new_w] == '.':
if (new_h, new_w) not in reached:
qu.append((new_h, new_w, warps + 1))
return -1
if __name__ == '__main__':
print((main()))
| 57 | 59 | 1,729 | 1,847 | # 参考: White_Pie_46
# https://atcoder.jp/contests/abc176/submissions/16168825
from collections import deque
def main():
height, width = [int(x) for x in input().split()]
init_h, init_w = [int(x) - 1 for x in input().split()]
dest_h, dest_w = [int(x) - 1 for x in input().split()]
grid = [list(eval(input())) for _ in range(height)]
adjacents = ((1, 0), (0, 1), (-1, 0), (0, -1))
def gen_warp_can_reach():
for h in range(-2, 3):
for w in range(-2, 3):
if h == 0 == w:
continue
if (h, w) in adjacents:
continue
yield (h, w)
warp_can_reach = tuple(gen_warp_can_reach())
qu = deque()
qu.append((init_h, init_w, 0)) # 座標とワープ回数を保持
reached = set()
while qu:
h, w, warps = qu.popleft()
if h == dest_h and w == dest_w:
return warps
if (h, w) in reached:
# 同じマスを複数回キューに追加しているかもしれない。
# 短距離で調査済みなら再調査は不要。
continue
reached.add((h, w))
for h_delta, w_delta in adjacents:
new_h, new_w = h + h_delta, w + w_delta
if 0 <= new_h < height and 0 <= new_w < width:
if grid[new_h][new_w] == ".":
qu.appendleft((new_h, new_w, warps))
for h_delta, w_delta in warp_can_reach:
new_h, new_w = h + h_delta, w + w_delta
if 0 <= new_h < height and 0 <= new_w < width:
if grid[new_h][new_w] == ".":
qu.append((new_h, new_w, warps + 1))
return -1
if __name__ == "__main__":
print((main()))
| # 参考: White_Pie_46
# https://atcoder.jp/contests/abc176/submissions/16168825
from collections import deque
def main():
height, width = [int(x) for x in input().split()]
init_h, init_w = [int(x) - 1 for x in input().split()]
dest_h, dest_w = [int(x) - 1 for x in input().split()]
grid = [list(eval(input())) for _ in range(height)]
adjacents = ((1, 0), (0, 1), (-1, 0), (0, -1))
def gen_warp_can_reach():
for h in range(-2, 3):
for w in range(-2, 3):
if h == 0 == w:
continue
if (h, w) in adjacents:
continue
yield (h, w)
warp_can_reach = tuple(gen_warp_can_reach())
qu = deque()
qu.append((init_h, init_w, 0)) # 座標とワープ回数を保持
reached = set()
while qu:
h, w, warps = qu.popleft()
if h == dest_h and w == dest_w:
return warps
if (h, w) in reached:
# 同じマスを複数回キューに追加しているかもしれない。
# 短距離で調査済みなら再調査は不要。
continue
reached.add((h, w))
for h_delta, w_delta in adjacents:
new_h, new_w = h + h_delta, w + w_delta
if 0 <= new_h < height and 0 <= new_w < width:
if grid[new_h][new_w] == ".":
if (new_h, new_w) not in reached:
qu.appendleft((new_h, new_w, warps))
for h_delta, w_delta in warp_can_reach:
new_h, new_w = h + h_delta, w + w_delta
if 0 <= new_h < height and 0 <= new_w < width:
if grid[new_h][new_w] == ".":
if (new_h, new_w) not in reached:
qu.append((new_h, new_w, warps + 1))
return -1
if __name__ == "__main__":
print((main()))
| false | 3.389831 | [
"- qu.appendleft((new_h, new_w, warps))",
"+ if (new_h, new_w) not in reached:",
"+ qu.appendleft((new_h, new_w, warps))",
"- qu.append((new_h, new_w, warps + 1))",
"+ if (new_h, new_w) not in reached:",
"+ qu.append((new_h, new_w, warps + 1))"
] | false | 0.037758 | 0.036705 | 1.028684 | [
"s599166305",
"s469822619"
] |
u018679195 | p03160 | python | s704395640 | s092494083 | 365 | 129 | 87,076 | 20,696 | Accepted | Accepted | 64.66 | def main():
n, height = getInputs()
cost = [0] * n
cost[1] = abs(height[0] - height[1])
for i in range(2, n):
cost[i] = min(
cost[i - 1] + abs(height[i] - height[i - 1]),
cost[i - 2] + abs(height[i] - height[i - 2])
)
print((cost[-1]))
def getInputs():
return int(eval(input())), tuple([int(x) for x in input().split()])
main()
| n = int(eval(input()))
pedras = list(map(int,input().split()))
dp = [0] * n
dp[0] = 0
dp[1] = abs(pedras[0] - pedras[1])
for i in range(2,n):
custo1 = dp[i-1] + abs(pedras[i-1] - pedras[i])
custo2 = dp[i-2] + abs(pedras[i-2] - pedras[i])
dp[i] = min(custo1,custo2)
print((dp[n-1]))
| 18 | 16 | 411 | 307 | def main():
n, height = getInputs()
cost = [0] * n
cost[1] = abs(height[0] - height[1])
for i in range(2, n):
cost[i] = min(
cost[i - 1] + abs(height[i] - height[i - 1]),
cost[i - 2] + abs(height[i] - height[i - 2]),
)
print((cost[-1]))
def getInputs():
return int(eval(input())), tuple([int(x) for x in input().split()])
main()
| n = int(eval(input()))
pedras = list(map(int, input().split()))
dp = [0] * n
dp[0] = 0
dp[1] = abs(pedras[0] - pedras[1])
for i in range(2, n):
custo1 = dp[i - 1] + abs(pedras[i - 1] - pedras[i])
custo2 = dp[i - 2] + abs(pedras[i - 2] - pedras[i])
dp[i] = min(custo1, custo2)
print((dp[n - 1]))
| false | 11.111111 | [
"-def main():",
"- n, height = getInputs()",
"- cost = [0] * n",
"- cost[1] = abs(height[0] - height[1])",
"- for i in range(2, n):",
"- cost[i] = min(",
"- cost[i - 1] + abs(height[i] - height[i - 1]),",
"- cost[i - 2] + abs(height[i] - height[i - 2]),",
"- )",
"- print((cost[-1]))",
"-",
"-",
"-def getInputs():",
"- return int(eval(input())), tuple([int(x) for x in input().split()])",
"-",
"-",
"-main()",
"+n = int(eval(input()))",
"+pedras = list(map(int, input().split()))",
"+dp = [0] * n",
"+dp[0] = 0",
"+dp[1] = abs(pedras[0] - pedras[1])",
"+for i in range(2, n):",
"+ custo1 = dp[i - 1] + abs(pedras[i - 1] - pedras[i])",
"+ custo2 = dp[i - 2] + abs(pedras[i - 2] - pedras[i])",
"+ dp[i] = min(custo1, custo2)",
"+print((dp[n - 1]))"
] | false | 0.035794 | 0.051557 | 0.694251 | [
"s704395640",
"s092494083"
] |
u333945892 | p03260 | python | s842378830 | s794745130 | 130 | 17 | 4,848 | 2,940 | Accepted | Accepted | 86.92 | from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
A,B = inpl()
if (A*B)%2 == 0:
print('No')
else:
print('Yes')
| A,B = list(map(int,input().split()))
if (A*B)%2 == 0:
print('No')
else:
print('Yes') | 15 | 5 | 350 | 86 | from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, datetime
sys.setrecursionlimit(10**8)
INF = float("inf")
mod = 10**9 + 7
eps = 10**-7
def inpl():
return list(map(int, input().split()))
def inpls():
return list(input().split())
A, B = inpl()
if (A * B) % 2 == 0:
print("No")
else:
print("Yes")
| A, B = list(map(int, input().split()))
if (A * B) % 2 == 0:
print("No")
else:
print("Yes")
| false | 66.666667 | [
"-from collections import defaultdict, deque",
"-import sys, heapq, bisect, math, itertools, string, queue, datetime",
"-",
"-sys.setrecursionlimit(10**8)",
"-INF = float(\"inf\")",
"-mod = 10**9 + 7",
"-eps = 10**-7",
"-",
"-",
"-def inpl():",
"- return list(map(int, input().split()))",
"-",
"-",
"-def inpls():",
"- return list(input().split())",
"-",
"-",
"-A, B = inpl()",
"+A, B = list(map(int, input().split()))"
] | false | 0.059577 | 0.055791 | 1.067865 | [
"s842378830",
"s794745130"
] |
u130900604 | p02707 | python | s335884551 | s314296581 | 170 | 145 | 36,364 | 31,648 | Accepted | Accepted | 14.71 | from collections import*
n,*a=list(map(int,open(0).read().split()));c=Counter(a)
for i in range(n):print((c[i+1])) | n,*a=list(map(int,open(0).read().split()));c=[0]*n
for q in a:c[q-1]+=1
for d in c:print(d) | 3 | 3 | 108 | 87 | from collections import *
n, *a = list(map(int, open(0).read().split()))
c = Counter(a)
for i in range(n):
print((c[i + 1]))
| n, *a = list(map(int, open(0).read().split()))
c = [0] * n
for q in a:
c[q - 1] += 1
for d in c:
print(d)
| false | 0 | [
"-from collections import *",
"-",
"-c = Counter(a)",
"-for i in range(n):",
"- print((c[i + 1]))",
"+c = [0] * n",
"+for q in a:",
"+ c[q - 1] += 1",
"+for d in c:",
"+ print(d)"
] | false | 0.041793 | 0.109988 | 0.379978 | [
"s335884551",
"s314296581"
] |
u307516601 | p02683 | python | s425272498 | s786746347 | 303 | 199 | 27,828 | 27,176 | Accepted | Accepted | 34.32 | n,m,x = list(map(int, input().split()))
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
ca = [[int(i) for i in readline().split()] for _ in range(n)]
from itertools import combinations
import numpy as np
lc = [i for i in range(n)]
ans = 1001001001
for nc in range(1,n+1):
lc_sub = list(combinations(lc,nc))
for lc_sub2 in lc_sub:
tmp_price = 0
tmp_und = np.array([0]*m)
for c in lc_sub2:
tmp_price += ca[c][0]
tmp_und += np.array(ca[c][1:])
if all([und >= x for und in tmp_und]):
ans = min(ans, tmp_price)
if ans == 1001001001:
print((-1))
else:
print(ans) | n, m, x = list(map(int, input().split()))
ca = [list(map(int, input().split())) for _ in range(n)]
from itertools import product
import numpy as np
INF = 1001001001
ans = INF
for i in product(list(range(2)), repeat=n): # product(range(2),n)でn桁のbit全探索が可能
tmp_price = 0
tmp_und = np.zeros((m, ))
for j in range(n):
if i[j]:
c, *a = ca[j]
# Pythonでは、タプルやリストの要素を展開して複数の変数に代入できる。アンパック代入などと呼ばれる
# 変数の数が要素の数よりも少ない場合、変数名にアスタリスク*をつけると、要素がリストとしてまとめて代入される
tmp_price += c
tmp_und += np.array(a, dtype=np.int64)
tmp_und = tmp_und.tolist()
if all(tmp_und_ele >= x for tmp_und_ele in tmp_und):
ans = min(ans, tmp_price)
print((ans if ans != INF else -1)) | 29 | 24 | 694 | 748 | n, m, x = list(map(int, input().split()))
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
ca = [[int(i) for i in readline().split()] for _ in range(n)]
from itertools import combinations
import numpy as np
lc = [i for i in range(n)]
ans = 1001001001
for nc in range(1, n + 1):
lc_sub = list(combinations(lc, nc))
for lc_sub2 in lc_sub:
tmp_price = 0
tmp_und = np.array([0] * m)
for c in lc_sub2:
tmp_price += ca[c][0]
tmp_und += np.array(ca[c][1:])
if all([und >= x for und in tmp_und]):
ans = min(ans, tmp_price)
if ans == 1001001001:
print((-1))
else:
print(ans)
| n, m, x = list(map(int, input().split()))
ca = [list(map(int, input().split())) for _ in range(n)]
from itertools import product
import numpy as np
INF = 1001001001
ans = INF
for i in product(list(range(2)), repeat=n): # product(range(2),n)でn桁のbit全探索が可能
tmp_price = 0
tmp_und = np.zeros((m,))
for j in range(n):
if i[j]:
c, *a = ca[j]
# Pythonでは、タプルやリストの要素を展開して複数の変数に代入できる。アンパック代入などと呼ばれる
# 変数の数が要素の数よりも少ない場合、変数名にアスタリスク*をつけると、要素がリストとしてまとめて代入される
tmp_price += c
tmp_und += np.array(a, dtype=np.int64)
tmp_und = tmp_und.tolist()
if all(tmp_und_ele >= x for tmp_und_ele in tmp_und):
ans = min(ans, tmp_price)
print((ans if ans != INF else -1))
| false | 17.241379 | [
"-import sys",
"-",
"-sys.setrecursionlimit(10**6)",
"-readline = sys.stdin.readline",
"-ca = [[int(i) for i in readline().split()] for _ in range(n)]",
"-from itertools import combinations",
"+ca = [list(map(int, input().split())) for _ in range(n)]",
"+from itertools import product",
"-lc = [i for i in range(n)]",
"-ans = 1001001001",
"-for nc in range(1, n + 1):",
"- lc_sub = list(combinations(lc, nc))",
"- for lc_sub2 in lc_sub:",
"- tmp_price = 0",
"- tmp_und = np.array([0] * m)",
"- for c in lc_sub2:",
"- tmp_price += ca[c][0]",
"- tmp_und += np.array(ca[c][1:])",
"- if all([und >= x for und in tmp_und]):",
"- ans = min(ans, tmp_price)",
"-if ans == 1001001001:",
"- print((-1))",
"-else:",
"- print(ans)",
"+INF = 1001001001",
"+ans = INF",
"+for i in product(list(range(2)), repeat=n): # product(range(2),n)でn桁のbit全探索が可能",
"+ tmp_price = 0",
"+ tmp_und = np.zeros((m,))",
"+ for j in range(n):",
"+ if i[j]:",
"+ c, *a = ca[j]",
"+ # Pythonでは、タプルやリストの要素を展開して複数の変数に代入できる。アンパック代入などと呼ばれる",
"+ # 変数の数が要素の数よりも少ない場合、変数名にアスタリスク*をつけると、要素がリストとしてまとめて代入される",
"+ tmp_price += c",
"+ tmp_und += np.array(a, dtype=np.int64)",
"+ tmp_und = tmp_und.tolist()",
"+ if all(tmp_und_ele >= x for tmp_und_ele in tmp_und):",
"+ ans = min(ans, tmp_price)",
"+print((ans if ans != INF else -1))"
] | false | 0.725072 | 0.261619 | 2.771478 | [
"s425272498",
"s786746347"
] |
u028973125 | p02823 | python | s312765056 | s006103205 | 175 | 26 | 38,256 | 9,148 | Accepted | Accepted | 85.14 | import sys
from pprint import pprint
def solve(n, a, b):
ans = 0
if (b - a) % 2 == 0:
ans = (b - a) // 2
else:
# 両端で試合するパターン
simple = min(b - 1, n - a)
# 両端に一回残留してから端以外で試合するパターン
mix_a = a + (b - a) // 2
mix_b = n - b + 1 + (b - a - 1) // 2
ans = min(simple, mix_a, mix_b)
print(ans)
if __name__ == '__main__':
n, a, b = list(map(int, sys.stdin.readline().strip().split(" ")))
solve(n, a, b) | import sys
N, A, B = list(map(int, sys.stdin.readline().split()))
if (B - A) % 2 == 0:
print(((B - A) // 2))
else:
print((min(A + (B - A - 1) // 2, N - B + 1 + (B - A - 1) // 2))) | 21 | 7 | 488 | 184 | import sys
from pprint import pprint
def solve(n, a, b):
ans = 0
if (b - a) % 2 == 0:
ans = (b - a) // 2
else:
# 両端で試合するパターン
simple = min(b - 1, n - a)
# 両端に一回残留してから端以外で試合するパターン
mix_a = a + (b - a) // 2
mix_b = n - b + 1 + (b - a - 1) // 2
ans = min(simple, mix_a, mix_b)
print(ans)
if __name__ == "__main__":
n, a, b = list(map(int, sys.stdin.readline().strip().split(" ")))
solve(n, a, b)
| import sys
N, A, B = list(map(int, sys.stdin.readline().split()))
if (B - A) % 2 == 0:
print(((B - A) // 2))
else:
print((min(A + (B - A - 1) // 2, N - B + 1 + (B - A - 1) // 2)))
| false | 66.666667 | [
"-from pprint import pprint",
"-",
"-def solve(n, a, b):",
"- ans = 0",
"- if (b - a) % 2 == 0:",
"- ans = (b - a) // 2",
"- else:",
"- # 両端で試合するパターン",
"- simple = min(b - 1, n - a)",
"- # 両端に一回残留してから端以外で試合するパターン",
"- mix_a = a + (b - a) // 2",
"- mix_b = n - b + 1 + (b - a - 1) // 2",
"- ans = min(simple, mix_a, mix_b)",
"- print(ans)",
"-",
"-",
"-if __name__ == \"__main__\":",
"- n, a, b = list(map(int, sys.stdin.readline().strip().split(\" \")))",
"- solve(n, a, b)",
"+N, A, B = list(map(int, sys.stdin.readline().split()))",
"+if (B - A) % 2 == 0:",
"+ print(((B - A) // 2))",
"+else:",
"+ print((min(A + (B - A - 1) // 2, N - B + 1 + (B - A - 1) // 2)))"
] | false | 0.057474 | 0.04047 | 1.420181 | [
"s312765056",
"s006103205"
] |
u624613992 | p02761 | python | s990318578 | s554979467 | 30 | 27 | 9,224 | 9,220 | Accepted | Accepted | 10 | n,m = list(map(int,input().split()))
done = [0]*n
ans = [0]*n
for i in range(m):
s,c = list(map(int,input().split()))
if done[s-1] != 0 and ans[s-1] != c:
print((-1))
exit()
elif n != 1 and s == 1 and c == 0:
print((-1))
exit()
else:
done[s-1] = 1
ans[s-1] = c
ans_f = str()
for j in ans:
ans_f += str(j)
if n>1 and ans_f[0] == "0":
print(("1"+ans_f[1::]))
else:
print(ans_f) | n,m = list(map(int,input().split()))
ans = [0]*n
for i in range(m):
s,c = list(map(int,input().split()))
if ans[s-1] != 0 and ans[s-1] != c:
print((-1))
exit()
elif n != 1 and s == 1 and c == 0:
print((-1))
exit()
else:
ans[s-1] = c
ans_f = "".join((list(map(str,ans))))
if n>1 and ans_f[0] == "0":
print(("1"+ans_f[1::]))
else:
print(ans_f) | 21 | 17 | 415 | 365 | n, m = list(map(int, input().split()))
done = [0] * n
ans = [0] * n
for i in range(m):
s, c = list(map(int, input().split()))
if done[s - 1] != 0 and ans[s - 1] != c:
print((-1))
exit()
elif n != 1 and s == 1 and c == 0:
print((-1))
exit()
else:
done[s - 1] = 1
ans[s - 1] = c
ans_f = str()
for j in ans:
ans_f += str(j)
if n > 1 and ans_f[0] == "0":
print(("1" + ans_f[1::]))
else:
print(ans_f)
| n, m = list(map(int, input().split()))
ans = [0] * n
for i in range(m):
s, c = list(map(int, input().split()))
if ans[s - 1] != 0 and ans[s - 1] != c:
print((-1))
exit()
elif n != 1 and s == 1 and c == 0:
print((-1))
exit()
else:
ans[s - 1] = c
ans_f = "".join((list(map(str, ans))))
if n > 1 and ans_f[0] == "0":
print(("1" + ans_f[1::]))
else:
print(ans_f)
| false | 19.047619 | [
"-done = [0] * n",
"- if done[s - 1] != 0 and ans[s - 1] != c:",
"+ if ans[s - 1] != 0 and ans[s - 1] != c:",
"- done[s - 1] = 1",
"-ans_f = str()",
"-for j in ans:",
"- ans_f += str(j)",
"+ans_f = \"\".join((list(map(str, ans))))"
] | false | 0.163649 | 0.252859 | 0.647195 | [
"s990318578",
"s554979467"
] |
u814663076 | p03141 | python | s844182337 | s656295518 | 541 | 407 | 45,140 | 45,140 | Accepted | Accepted | 24.77 | import numpy as np
N = int(eval(input()))
arr = np.array([input().split() + [0] for _ in range(N)], dtype='int64')
for i in range(N):
arr[i, 2] = arr[i, 0] + arr[i, 1]
arr = arr[np.argsort(arr[:, 2])][::-1]
print((np.sum(arr[::2, 0]) - np.sum(arr[1::2, 1]))) | import numpy as np
import sys
input = sys.stdin.readline
N = int(eval(input()))
arr = np.array([input().split() + [0] for _ in range(N)], dtype='int64')
for i in range(N):
arr[i, 2] = arr[i, 0] + arr[i, 1]
arr = arr[np.argsort(arr[:, 2])][::-1]
print((np.sum(arr[::2, 0]) - np.sum(arr[1::2, 1]))) | 11 | 13 | 268 | 308 | import numpy as np
N = int(eval(input()))
arr = np.array([input().split() + [0] for _ in range(N)], dtype="int64")
for i in range(N):
arr[i, 2] = arr[i, 0] + arr[i, 1]
arr = arr[np.argsort(arr[:, 2])][::-1]
print((np.sum(arr[::2, 0]) - np.sum(arr[1::2, 1])))
| import numpy as np
import sys
input = sys.stdin.readline
N = int(eval(input()))
arr = np.array([input().split() + [0] for _ in range(N)], dtype="int64")
for i in range(N):
arr[i, 2] = arr[i, 0] + arr[i, 1]
arr = arr[np.argsort(arr[:, 2])][::-1]
print((np.sum(arr[::2, 0]) - np.sum(arr[1::2, 1])))
| false | 15.384615 | [
"+import sys",
"+input = sys.stdin.readline"
] | false | 0.008214 | 0.226881 | 0.036203 | [
"s844182337",
"s656295518"
] |
u342869120 | p03946 | python | s651680067 | s753580577 | 269 | 223 | 66,668 | 62,704 | Accepted | Accepted | 17.1 | from collections import defaultdict
N, T = list(map(int, input().split()))
*a, = list(map(int, input().split()))
t = defaultdict(int)
m = a[0]
p = 0
ans = 0
for i in range(1, N):
c = a[i] - m
if t[m] < c:
t[m] = c
if a[i] < m:
m = a[i]
if c > p:
p = c
ans = 1
elif c == p:
ans += 1
print(ans)
| N, T = list(map(int, input().split()))
*a, = list(map(int, input().split()))
m = a[0]
p = 0
ans = 0
for i in range(1, N):
c = a[i] - m
if a[i] < m:
m = a[i]
if c > p:
p = c
ans = 1
elif c == p:
ans += 1
print(ans)
| 21 | 16 | 363 | 266 | from collections import defaultdict
N, T = list(map(int, input().split()))
(*a,) = list(map(int, input().split()))
t = defaultdict(int)
m = a[0]
p = 0
ans = 0
for i in range(1, N):
c = a[i] - m
if t[m] < c:
t[m] = c
if a[i] < m:
m = a[i]
if c > p:
p = c
ans = 1
elif c == p:
ans += 1
print(ans)
| N, T = list(map(int, input().split()))
(*a,) = list(map(int, input().split()))
m = a[0]
p = 0
ans = 0
for i in range(1, N):
c = a[i] - m
if a[i] < m:
m = a[i]
if c > p:
p = c
ans = 1
elif c == p:
ans += 1
print(ans)
| false | 23.809524 | [
"-from collections import defaultdict",
"-",
"-t = defaultdict(int)",
"- if t[m] < c:",
"- t[m] = c"
] | false | 0.105542 | 0.042261 | 2.497404 | [
"s651680067",
"s753580577"
] |
u276115223 | p03243 | python | s863639098 | s070021319 | 21 | 17 | 3,316 | 2,940 | Accepted | Accepted | 19.05 | # ABC 111: B – AtCoder Beginner Contest 111
n = int(eval(input()))
i = n // 111
if n % 111 != 0:
i += 1
print((i * 111)) | # ABC 111: B – AtCoder Beginner Contest 111
n = eval(input())
n = '10' if len(n) == 1 else n
while len(set(n)) != 1:
n = str(int(n) + 1)
print(n) | 8 | 9 | 125 | 154 | # ABC 111: B – AtCoder Beginner Contest 111
n = int(eval(input()))
i = n // 111
if n % 111 != 0:
i += 1
print((i * 111))
| # ABC 111: B – AtCoder Beginner Contest 111
n = eval(input())
n = "10" if len(n) == 1 else n
while len(set(n)) != 1:
n = str(int(n) + 1)
print(n)
| false | 11.111111 | [
"-n = int(eval(input()))",
"-i = n // 111",
"-if n % 111 != 0:",
"- i += 1",
"-print((i * 111))",
"+n = eval(input())",
"+n = \"10\" if len(n) == 1 else n",
"+while len(set(n)) != 1:",
"+ n = str(int(n) + 1)",
"+print(n)"
] | false | 0.04683 | 0.045358 | 1.032459 | [
"s863639098",
"s070021319"
] |
u593567568 | p03733 | python | s441807446 | s186085676 | 279 | 130 | 54,976 | 30,824 | Accepted | Accepted | 53.41 | N,T = list(map(int,input().split()))
A = list(map(int,input().split()))
LST = []
for a in A:
LST.append((a,1))
LST.append((a+T,-1))
LST.sort()
prev = -1
s = 0
ans = 0
for x,y in LST:
if y == 1:
s += 1
if s == 1:
prev = x
elif y == -1:
s -= 1
if s == 0:
ans += (x - prev)
print(ans)
| N,T = list(map(int,input().split()))
A = list(map(int,input().split()))
ans = 0
for i in range(N-1):
ans += min(T,A[i+1] - A[i])
print((ans+T))
| 25 | 9 | 345 | 151 | N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
LST = []
for a in A:
LST.append((a, 1))
LST.append((a + T, -1))
LST.sort()
prev = -1
s = 0
ans = 0
for x, y in LST:
if y == 1:
s += 1
if s == 1:
prev = x
elif y == -1:
s -= 1
if s == 0:
ans += x - prev
print(ans)
| N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
ans = 0
for i in range(N - 1):
ans += min(T, A[i + 1] - A[i])
print((ans + T))
| false | 64 | [
"-LST = []",
"-for a in A:",
"- LST.append((a, 1))",
"- LST.append((a + T, -1))",
"-LST.sort()",
"-prev = -1",
"-s = 0",
"-for x, y in LST:",
"- if y == 1:",
"- s += 1",
"- if s == 1:",
"- prev = x",
"- elif y == -1:",
"- s -= 1",
"- if s == 0:",
"- ans += x - prev",
"-print(ans)",
"+for i in range(N - 1):",
"+ ans += min(T, A[i + 1] - A[i])",
"+print((ans + T))"
] | false | 0.040242 | 0.035422 | 1.136072 | [
"s441807446",
"s186085676"
] |
u945345165 | p00481 | python | s089974692 | s367532767 | 36,410 | 17,440 | 35,316 | 34,744 | Accepted | Accepted | 52.1 | import copy
import queue
def bfs(count, x, y, cheese):
q = queue.Queue()
q.put((count,x,y))
tempVisited = copy.deepcopy(visited)
tempVisited[x][y] = True
while q.qsize()>0:
tempc,tempx,tempy = q.get()
if geo[tempx][tempy] == cheese:
return tempc,tempx,tempy
for i in range(4):
neox = tempx+dx[i]
neoy = tempy+dy[i]
if canGoTo(neox,neoy, tempVisited):
#if (tempc+1,neox,neoy) not in q:
q.put((tempc+1,neox,neoy))
tempVisited[neox][neoy]=True
return (-1,-1,-1)
def canGoTo(x,y,tempVisited):
if 0<=x<H and 0<=y<W:
return not tempVisited[x][y]
return False
dx = [0,1,0,-1]
dy = [-1,0,1,0]
data = input().split(' ')
H,W,N = list(map(int, data))
#maps
geo = [[None for i in range(W)] for j in range(H)]
visited = [[False for i in range(W)] for j in range(H)]
x,y=-1,-1
for i in range(H):
line = eval(input())
for j in range(W):
p = line[j:j+1]
geo[i][j] = p
if p == 'X':
visited[i][j] = True
elif p == 'S':
x,y, = i,j
count = 0
for n in range(1,N+1):
count,x,y = bfs(count,x,y,str(n))
print(count) | import copy
from collections import deque
def bfs(count, x, y, cheese):
q = deque()
q.append((count,x,y))
tempVisited = copy.deepcopy(visited)
tempVisited[x][y] = True
while len(q)>0:
tempc,tempx,tempy = q.popleft()
if geo[tempx][tempy] == cheese:
return tempc,tempx,tempy
for i in range(4):
neox = tempx+dx[i]
neoy = tempy+dy[i]
if canGoTo(neox,neoy, tempVisited):
if (tempc+1,neox,neoy) not in q:
q.append((tempc+1,neox,neoy))
tempVisited[neox][neoy]=True
return (-1,-1,-1)
def canGoTo(x,y,tempVisited):
if 0<=x<H and 0<=y<W:
return not tempVisited[x][y]
return False
dx = [0,1,0,-1]
dy = [-1,0,1,0]
data = input().split(' ')
H,W,N = list(map(int, data))
#maps
geo = [[None for i in range(W)] for j in range(H)]
visited = [[False for i in range(W)] for j in range(H)]
x,y=-1,-1
for i in range(H):
line = eval(input())
for j in range(W):
p = line[j:j+1]
geo[i][j] = p
if p == 'X':
visited[i][j] = True
elif p == 'S':
x,y, = i,j
count = 0
for n in range(1,N+1):
count,x,y = bfs(count,x,y,str(n))
print(count) | 51 | 51 | 1,280 | 1,305 | import copy
import queue
def bfs(count, x, y, cheese):
q = queue.Queue()
q.put((count, x, y))
tempVisited = copy.deepcopy(visited)
tempVisited[x][y] = True
while q.qsize() > 0:
tempc, tempx, tempy = q.get()
if geo[tempx][tempy] == cheese:
return tempc, tempx, tempy
for i in range(4):
neox = tempx + dx[i]
neoy = tempy + dy[i]
if canGoTo(neox, neoy, tempVisited):
# if (tempc+1,neox,neoy) not in q:
q.put((tempc + 1, neox, neoy))
tempVisited[neox][neoy] = True
return (-1, -1, -1)
def canGoTo(x, y, tempVisited):
if 0 <= x < H and 0 <= y < W:
return not tempVisited[x][y]
return False
dx = [0, 1, 0, -1]
dy = [-1, 0, 1, 0]
data = input().split(" ")
H, W, N = list(map(int, data))
# maps
geo = [[None for i in range(W)] for j in range(H)]
visited = [[False for i in range(W)] for j in range(H)]
x, y = -1, -1
for i in range(H):
line = eval(input())
for j in range(W):
p = line[j : j + 1]
geo[i][j] = p
if p == "X":
visited[i][j] = True
elif p == "S":
x, y, = (
i,
j,
)
count = 0
for n in range(1, N + 1):
count, x, y = bfs(count, x, y, str(n))
print(count)
| import copy
from collections import deque
def bfs(count, x, y, cheese):
q = deque()
q.append((count, x, y))
tempVisited = copy.deepcopy(visited)
tempVisited[x][y] = True
while len(q) > 0:
tempc, tempx, tempy = q.popleft()
if geo[tempx][tempy] == cheese:
return tempc, tempx, tempy
for i in range(4):
neox = tempx + dx[i]
neoy = tempy + dy[i]
if canGoTo(neox, neoy, tempVisited):
if (tempc + 1, neox, neoy) not in q:
q.append((tempc + 1, neox, neoy))
tempVisited[neox][neoy] = True
return (-1, -1, -1)
def canGoTo(x, y, tempVisited):
if 0 <= x < H and 0 <= y < W:
return not tempVisited[x][y]
return False
dx = [0, 1, 0, -1]
dy = [-1, 0, 1, 0]
data = input().split(" ")
H, W, N = list(map(int, data))
# maps
geo = [[None for i in range(W)] for j in range(H)]
visited = [[False for i in range(W)] for j in range(H)]
x, y = -1, -1
for i in range(H):
line = eval(input())
for j in range(W):
p = line[j : j + 1]
geo[i][j] = p
if p == "X":
visited[i][j] = True
elif p == "S":
x, y, = (
i,
j,
)
count = 0
for n in range(1, N + 1):
count, x, y = bfs(count, x, y, str(n))
print(count)
| false | 0 | [
"-import queue",
"+from collections import deque",
"- q = queue.Queue()",
"- q.put((count, x, y))",
"+ q = deque()",
"+ q.append((count, x, y))",
"- while q.qsize() > 0:",
"- tempc, tempx, tempy = q.get()",
"+ while len(q) > 0:",
"+ tempc, tempx, tempy = q.popleft()",
"- # if (tempc+1,neox,neoy) not in q:",
"- q.put((tempc + 1, neox, neoy))",
"- tempVisited[neox][neoy] = True",
"+ if (tempc + 1, neox, neoy) not in q:",
"+ q.append((tempc + 1, neox, neoy))",
"+ tempVisited[neox][neoy] = True"
] | false | 0.047332 | 0.081683 | 0.579465 | [
"s089974692",
"s367532767"
] |
u780698286 | p03035 | python | s602809505 | s834741380 | 29 | 24 | 8,948 | 9,136 | Accepted | Accepted | 17.24 | a, b = list(map(int, input().split()))
if a >= 13:
print(b)
elif a <= 5:
print((0))
else:
print((b//2)) | a, b = list(map(int, input().split()))
if a <= 5:
print((0))
elif a <= 12:
print((b//2))
else:
print(b)
| 7 | 7 | 105 | 112 | a, b = list(map(int, input().split()))
if a >= 13:
print(b)
elif a <= 5:
print((0))
else:
print((b // 2))
| a, b = list(map(int, input().split()))
if a <= 5:
print((0))
elif a <= 12:
print((b // 2))
else:
print(b)
| false | 0 | [
"-if a >= 13:",
"+if a <= 5:",
"+ print((0))",
"+elif a <= 12:",
"+ print((b // 2))",
"+else:",
"-elif a <= 5:",
"- print((0))",
"-else:",
"- print((b // 2))"
] | false | 0.088684 | 0.087971 | 1.008096 | [
"s602809505",
"s834741380"
] |
u225388820 | p02558 | python | s883735596 | s658824296 | 467 | 302 | 83,344 | 76,592 | Accepted | Accepted | 35.33 | from typing import List
class DSU:
def __init__(self, n: int) -> None:
self._n = n
self.parent_or_size = [-1] * n
def merge(self, a: int, b: int) -> int:
assert 0 <= a <= self._n
assert 0 <= b <= self._n
x, y = self.leader(a), self.leader(b)
if x == y:
return x
if -self.parent_or_size[x] < -self.parent_or_size[y]:
x, y = y, x
self.parent_or_size[x] += self.parent_or_size[y]
self.parent_or_size[y] = x
return x
def same(self, a: int, b: int) -> bool:
assert 0 <= a <= self._n
assert 0 <= b <= self._n
return self.leader(a) == self.leader(b)
def leader(self, a: int) -> int:
assert 0 <= a < self._n
if self.parent_or_size[a] < 0:
return a
result = self.leader(self.parent_or_size[a])
self.parent_or_size[a] = result
return result
def size(self, a: int) -> int:
assert 0 <= a <= self._n
return -self.parent_or_size[self.leader(a)]
def groups(self) -> List[List[int]]:
leader_buf = [self.leader(i) for i in range(self._n)]
group_size = [0] * self._n
for i in leader_buf:
group_size[i] += 1
result = [[] for _ in range(self._n)]
for i in range(self._n):
result[leader_buf[i]].append(i)
result = [i for i in result if i]
return result
import sys
input = sys.stdin.readline
n, q = list(map(int, input().split()))
uf = DSU(n)
for i in range(q):
t, u, v = list(map(int, input().split()))
if t:
print((int(uf.same(u, v))))
else:
uf.merge(u, v)
| from typing import List
class DSU:
def __init__(self, n: int) -> None:
self._n = n
self.parent_or_size = [-1] * n
def merge(self, a: int, b: int) -> int:
assert 0 <= a <= self._n
assert 0 <= b <= self._n
x, y = self.leader(a), self.leader(b)
if x == y:
return x
if -self.parent_or_size[x] < -self.parent_or_size[y]:
x, y = y, x
self.parent_or_size[x] += self.parent_or_size[y]
self.parent_or_size[y] = x
return x
def same(self, a: int, b: int) -> bool:
assert 0 <= a <= self._n
assert 0 <= b <= self._n
return self.leader(a) == self.leader(b)
def leader(self, a: int) -> int:
assert 0 <= a < self._n
if self.parent_or_size[a] < 0:
return a
while self.parent_or_size[a] >= 0:
a = self.parent_or_size[a]
return a
def size(self, a: int) -> int:
assert 0 <= a <= self._n
return -self.parent_or_size[self.leader(a)]
def groups(self) -> List[List[int]]:
leader_buf = [self.leader(i) for i in range(self._n)]
group_size = [0] * self._n
for i in leader_buf:
group_size[i] += 1
result = [[] for _ in range(self._n)]
for i in range(self._n):
result[leader_buf[i]].append(i)
result = [i for i in result if i]
return result
import sys
input = sys.stdin.readline
n, q = list(map(int, input().split()))
uf = DSU(n)
for i in range(q):
t, u, v = list(map(int, input().split()))
if t:
print((int(uf.same(u, v))))
else:
uf.merge(u, v)
| 59 | 59 | 1,718 | 1,702 | from typing import List
class DSU:
def __init__(self, n: int) -> None:
self._n = n
self.parent_or_size = [-1] * n
def merge(self, a: int, b: int) -> int:
assert 0 <= a <= self._n
assert 0 <= b <= self._n
x, y = self.leader(a), self.leader(b)
if x == y:
return x
if -self.parent_or_size[x] < -self.parent_or_size[y]:
x, y = y, x
self.parent_or_size[x] += self.parent_or_size[y]
self.parent_or_size[y] = x
return x
def same(self, a: int, b: int) -> bool:
assert 0 <= a <= self._n
assert 0 <= b <= self._n
return self.leader(a) == self.leader(b)
def leader(self, a: int) -> int:
assert 0 <= a < self._n
if self.parent_or_size[a] < 0:
return a
result = self.leader(self.parent_or_size[a])
self.parent_or_size[a] = result
return result
def size(self, a: int) -> int:
assert 0 <= a <= self._n
return -self.parent_or_size[self.leader(a)]
def groups(self) -> List[List[int]]:
leader_buf = [self.leader(i) for i in range(self._n)]
group_size = [0] * self._n
for i in leader_buf:
group_size[i] += 1
result = [[] for _ in range(self._n)]
for i in range(self._n):
result[leader_buf[i]].append(i)
result = [i for i in result if i]
return result
import sys
input = sys.stdin.readline
n, q = list(map(int, input().split()))
uf = DSU(n)
for i in range(q):
t, u, v = list(map(int, input().split()))
if t:
print((int(uf.same(u, v))))
else:
uf.merge(u, v)
| from typing import List
class DSU:
def __init__(self, n: int) -> None:
self._n = n
self.parent_or_size = [-1] * n
def merge(self, a: int, b: int) -> int:
assert 0 <= a <= self._n
assert 0 <= b <= self._n
x, y = self.leader(a), self.leader(b)
if x == y:
return x
if -self.parent_or_size[x] < -self.parent_or_size[y]:
x, y = y, x
self.parent_or_size[x] += self.parent_or_size[y]
self.parent_or_size[y] = x
return x
def same(self, a: int, b: int) -> bool:
assert 0 <= a <= self._n
assert 0 <= b <= self._n
return self.leader(a) == self.leader(b)
def leader(self, a: int) -> int:
assert 0 <= a < self._n
if self.parent_or_size[a] < 0:
return a
while self.parent_or_size[a] >= 0:
a = self.parent_or_size[a]
return a
def size(self, a: int) -> int:
assert 0 <= a <= self._n
return -self.parent_or_size[self.leader(a)]
def groups(self) -> List[List[int]]:
leader_buf = [self.leader(i) for i in range(self._n)]
group_size = [0] * self._n
for i in leader_buf:
group_size[i] += 1
result = [[] for _ in range(self._n)]
for i in range(self._n):
result[leader_buf[i]].append(i)
result = [i for i in result if i]
return result
import sys
input = sys.stdin.readline
n, q = list(map(int, input().split()))
uf = DSU(n)
for i in range(q):
t, u, v = list(map(int, input().split()))
if t:
print((int(uf.same(u, v))))
else:
uf.merge(u, v)
| false | 0 | [
"- result = self.leader(self.parent_or_size[a])",
"- self.parent_or_size[a] = result",
"- return result",
"+ while self.parent_or_size[a] >= 0:",
"+ a = self.parent_or_size[a]",
"+ return a"
] | false | 0.044151 | 0.044936 | 0.982524 | [
"s883735596",
"s658824296"
] |
u596276291 | p03964 | python | s526397461 | s836489121 | 112 | 62 | 5,204 | 5,984 | Accepted | Accepted | 44.64 | import math
from decimal import Decimal
def main():
N = int(eval(input()))
t, a = 1, 1
for _ in range(N):
_t, _a = list(map(int, input().split()))
n = Decimal(max(math.ceil(t / _t), math.ceil(a / _a)))
t, a = _t * n, _a * n
print((t + a))
if __name__ == '__main__':
main()
| from math import ceil
from fractions import Fraction
def main():
N = int(eval(input()))
t, a = 1, 1
for _ in range(N):
_t, _a = list(map(int, input().split()))
n = ceil(max(Fraction(t, _t), Fraction(a, _a)))
t, a = _t * n, _a * n
print((t + a))
if __name__ == '__main__':
main()
| 16 | 15 | 322 | 326 | import math
from decimal import Decimal
def main():
N = int(eval(input()))
t, a = 1, 1
for _ in range(N):
_t, _a = list(map(int, input().split()))
n = Decimal(max(math.ceil(t / _t), math.ceil(a / _a)))
t, a = _t * n, _a * n
print((t + a))
if __name__ == "__main__":
main()
| from math import ceil
from fractions import Fraction
def main():
N = int(eval(input()))
t, a = 1, 1
for _ in range(N):
_t, _a = list(map(int, input().split()))
n = ceil(max(Fraction(t, _t), Fraction(a, _a)))
t, a = _t * n, _a * n
print((t + a))
if __name__ == "__main__":
main()
| false | 6.25 | [
"-import math",
"-from decimal import Decimal",
"+from math import ceil",
"+from fractions import Fraction",
"- n = Decimal(max(math.ceil(t / _t), math.ceil(a / _a)))",
"+ n = ceil(max(Fraction(t, _t), Fraction(a, _a)))"
] | false | 0.050344 | 0.05425 | 0.927995 | [
"s526397461",
"s836489121"
] |
u024807881 | p03062 | python | s096986795 | s772222657 | 92 | 54 | 14,116 | 14,116 | Accepted | Accepted | 41.3 | from sys import stdin
readline = stdin.readline
_, *aa = list(map(int, open(0).read().split()))
r = 0
mi = 1000000000
m = 0
for a in aa:
if a < 0:
m += 1
b = abs(a)
r += b
mi = min(b, mi)
print((r - mi * 2 * (m % 2)))
| from sys import stdin
readline = stdin.readline
def main():
_, *A = list(map(int, open(0).read().split()))
B = tuple(map(abs, A))
C = tuple(a for a in A if a < 0)
print((sum(B) - min(B)*2*(len(C)%2)))
if __name__ == "__main__":
main() | 15 | 14 | 250 | 269 | from sys import stdin
readline = stdin.readline
_, *aa = list(map(int, open(0).read().split()))
r = 0
mi = 1000000000
m = 0
for a in aa:
if a < 0:
m += 1
b = abs(a)
r += b
mi = min(b, mi)
print((r - mi * 2 * (m % 2)))
| from sys import stdin
readline = stdin.readline
def main():
_, *A = list(map(int, open(0).read().split()))
B = tuple(map(abs, A))
C = tuple(a for a in A if a < 0)
print((sum(B) - min(B) * 2 * (len(C) % 2)))
if __name__ == "__main__":
main()
| false | 6.666667 | [
"-_, *aa = list(map(int, open(0).read().split()))",
"-r = 0",
"-mi = 1000000000",
"-m = 0",
"-for a in aa:",
"- if a < 0:",
"- m += 1",
"- b = abs(a)",
"- r += b",
"- mi = min(b, mi)",
"-print((r - mi * 2 * (m % 2)))",
"+",
"+",
"+def main():",
"+ _, *A = list(map(int, open(0).read().split()))",
"+ B = tuple(map(abs, A))",
"+ C = tuple(a for a in A if a < 0)",
"+ print((sum(B) - min(B) * 2 * (len(C) % 2)))",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.035783 | 0.065392 | 0.547205 | [
"s096986795",
"s772222657"
] |
u221886916 | p03163 | python | s160483148 | s094244860 | 772 | 404 | 171,892 | 118,512 | Accepted | Accepted | 47.67 | from collections import Counter
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce
def input():
return sys.stdin.readline().strip()
def iinput():
return int(eval(input()))
def tinput():
return input().split()
def rinput():
return list(map(int, tinput()))
def rlinput():
return list(rinput())
mod = int(1e9)+7
def factors(n):
return set(reduce(list.__add__,
([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))
# ----------------------------------------------------
if __name__ == "__main__":
n, w = rinput()
w_v = []
for i in range(n):
w_v.append(rlinput())
dp = [[0 for i in range(w+1)]for j in range(n+1)]
# print(w_v)
for item in range(1, n+1):
for weight in range(1, w+1):
if weight >= w_v[item-1][0]:
dp[item][weight] = max(dp[item-1][weight-w_v[item-1][0]]+w_v[item-1][1],dp[item-1][weight])
else:
dp[item][weight] =dp[item-1][weight]
print((dp[n][w]))
|
def main():
N,W = list(map(int, input().split()))
dp = [[0]*(W+1) for i in range(N+1)]
weight = [0]
value = [0]
for i in range(N):
w,v=list(map(int, input().split()))
weight.append(w)
value.append(v)
# dp[i][w] is the maximum value got with first i items stored in w weight of knapsack
for i in range(1,N+1):
for w in range(1,W+1):
if w>=weight[i]:
dp[i][w] = max(dp[i-1][w],dp[i-1][w-weight[i]]+value[i])
else:
dp[i][w] = dp[i-1][w]
print((dp[N][W]))
if __name__ == "__main__":
main() | 54 | 29 | 1,163 | 633 | from collections import Counter
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce
def input():
return sys.stdin.readline().strip()
def iinput():
return int(eval(input()))
def tinput():
return input().split()
def rinput():
return list(map(int, tinput()))
def rlinput():
return list(rinput())
mod = int(1e9) + 7
def factors(n):
return set(
reduce(
list.__add__,
([i, n // i] for i in range(1, int(n**0.5) + 1) if n % i == 0),
)
)
# ----------------------------------------------------
if __name__ == "__main__":
n, w = rinput()
w_v = []
for i in range(n):
w_v.append(rlinput())
dp = [[0 for i in range(w + 1)] for j in range(n + 1)]
# print(w_v)
for item in range(1, n + 1):
for weight in range(1, w + 1):
if weight >= w_v[item - 1][0]:
dp[item][weight] = max(
dp[item - 1][weight - w_v[item - 1][0]] + w_v[item - 1][1],
dp[item - 1][weight],
)
else:
dp[item][weight] = dp[item - 1][weight]
print((dp[n][w]))
| def main():
N, W = list(map(int, input().split()))
dp = [[0] * (W + 1) for i in range(N + 1)]
weight = [0]
value = [0]
for i in range(N):
w, v = list(map(int, input().split()))
weight.append(w)
value.append(v)
# dp[i][w] is the maximum value got with first i items stored in w weight of knapsack
for i in range(1, N + 1):
for w in range(1, W + 1):
if w >= weight[i]:
dp[i][w] = max(dp[i - 1][w], dp[i - 1][w - weight[i]] + value[i])
else:
dp[i][w] = dp[i - 1][w]
print((dp[N][W]))
if __name__ == "__main__":
main()
| false | 46.296296 | [
"-from collections import Counter",
"-from collections import defaultdict",
"-import math",
"-import random",
"-import heapq as hq",
"-from math import sqrt",
"-import sys",
"-from functools import reduce",
"+def main():",
"+ N, W = list(map(int, input().split()))",
"+ dp = [[0] * (W + 1) for i in range(N + 1)]",
"+ weight = [0]",
"+ value = [0]",
"+ for i in range(N):",
"+ w, v = list(map(int, input().split()))",
"+ weight.append(w)",
"+ value.append(v)",
"+ # dp[i][w] is the maximum value got with first i items stored in w weight of knapsack",
"+ for i in range(1, N + 1):",
"+ for w in range(1, W + 1):",
"+ if w >= weight[i]:",
"+ dp[i][w] = max(dp[i - 1][w], dp[i - 1][w - weight[i]] + value[i])",
"+ else:",
"+ dp[i][w] = dp[i - 1][w]",
"+ print((dp[N][W]))",
"-def input():",
"- return sys.stdin.readline().strip()",
"-",
"-",
"-def iinput():",
"- return int(eval(input()))",
"-",
"-",
"-def tinput():",
"- return input().split()",
"-",
"-",
"-def rinput():",
"- return list(map(int, tinput()))",
"-",
"-",
"-def rlinput():",
"- return list(rinput())",
"-",
"-",
"-mod = int(1e9) + 7",
"-",
"-",
"-def factors(n):",
"- return set(",
"- reduce(",
"- list.__add__,",
"- ([i, n // i] for i in range(1, int(n**0.5) + 1) if n % i == 0),",
"- )",
"- )",
"-",
"-",
"- n, w = rinput()",
"- w_v = []",
"- for i in range(n):",
"- w_v.append(rlinput())",
"- dp = [[0 for i in range(w + 1)] for j in range(n + 1)]",
"- # print(w_v)",
"- for item in range(1, n + 1):",
"- for weight in range(1, w + 1):",
"- if weight >= w_v[item - 1][0]:",
"- dp[item][weight] = max(",
"- dp[item - 1][weight - w_v[item - 1][0]] + w_v[item - 1][1],",
"- dp[item - 1][weight],",
"- )",
"- else:",
"- dp[item][weight] = dp[item - 1][weight]",
"- print((dp[n][w]))",
"+ main()"
] | false | 0.08512 | 0.040106 | 2.122362 | [
"s160483148",
"s094244860"
] |
u271176141 | p04029 | python | s943262952 | s164790954 | 26 | 24 | 8,896 | 9,088 | Accepted | Accepted | 7.69 | child_num = eval(input())
child_num = int(child_num)
candy_num = int((child_num**2 + child_num) / 2)
print(candy_num) | #子供の数を入力
child_num = int(eval(input()))
candy_num = int((child_num**2 + child_num) / 2)
print(candy_num) | 4 | 5 | 114 | 103 | child_num = eval(input())
child_num = int(child_num)
candy_num = int((child_num**2 + child_num) / 2)
print(candy_num)
| # 子供の数を入力
child_num = int(eval(input()))
candy_num = int((child_num**2 + child_num) / 2)
print(candy_num)
| false | 20 | [
"-child_num = eval(input())",
"-child_num = int(child_num)",
"+# 子供の数を入力",
"+child_num = int(eval(input()))"
] | false | 0.042847 | 0.040828 | 1.049434 | [
"s943262952",
"s164790954"
] |
u188827677 | p02983 | python | s318260479 | s042947993 | 659 | 398 | 9,064 | 9,048 | Accepted | Accepted | 39.61 | l,r = list(map(int, input().split()))
if r - l >= 2019:
print((0))
exit()
ans = 10**9
for i in range(l,r):
for j in range(i+1, r+1):
ans = min(ans, i*j%2019)
print(ans) | l,r = list(map(int, input().split()))
if r-l >= 2019:
print((0))
exit()
ans = float("inf")
for i in range(l,r):
for j in range(i+1,r+1):
if i*j%2019 < ans: ans = i*j%2019
print(ans) | 11 | 11 | 182 | 195 | l, r = list(map(int, input().split()))
if r - l >= 2019:
print((0))
exit()
ans = 10**9
for i in range(l, r):
for j in range(i + 1, r + 1):
ans = min(ans, i * j % 2019)
print(ans)
| l, r = list(map(int, input().split()))
if r - l >= 2019:
print((0))
exit()
ans = float("inf")
for i in range(l, r):
for j in range(i + 1, r + 1):
if i * j % 2019 < ans:
ans = i * j % 2019
print(ans)
| false | 0 | [
"-ans = 10**9",
"+ans = float(\"inf\")",
"- ans = min(ans, i * j % 2019)",
"+ if i * j % 2019 < ans:",
"+ ans = i * j % 2019"
] | false | 0.045367 | 0.041241 | 1.100043 | [
"s318260479",
"s042947993"
] |
u759938562 | p02891 | python | s088835852 | s988229131 | 20 | 17 | 3,064 | 3,064 | Accepted | Accepted | 15 | S = eval(input())
K = eval(input())
if not(1 <= len(S) and len(S) <= 100):
exit()
if not (S.isalpha() and S.islower()):
exit()
if not float(K).is_integer():
exit()
if not (1 <= int(K) and int(K) <= 10 ** 9):
exit()
L = []
tmp = []
pre = ""
for s in S:
if len(tmp) == 0:
pre = s
tmp.append(s)
elif pre == s:
tmp.append(s)
else:
L.append(tmp)
pre = s
tmp = [s]
L.append(tmp)
count = 0
for l in L:
count += int(len(l) / 2)
# print(l)
count *= int(K)
if len(L) == 1:
if len(L[0]) == 1:
count = int(int(K) / 2)
elif len(L[0]) % 2 == 1:
count += int(int(K) / 2)
elif L[0][0] == L[len(L)-1][0]:
if len(L[0]) % 2 == 1 and len(L[len(L)-1]) % 2 == 1:
count = count + int(K) - 1
print(count)
| S = eval(input())
K = eval(input())
L = []
tmp = []
pre = ""
for s in S:
if len(tmp) == 0:
pre = s
tmp.append(s)
elif pre == s:
tmp.append(s)
else:
L.append(tmp)
pre = s
tmp = [s]
L.append(tmp)
count = 0
for l in L:
count += int(len(l) / 2)
# print(l)
count *= int(K)
if len(L) == 1:
if len(L[0]) == 1:
count = int(int(K) / 2)
elif len(L[0]) % 2 == 1:
count += int(int(K) / 2)
elif L[0][0] == L[len(L)-1][0]:
if len(L[0]) % 2 == 1 and len(L[len(L)-1]) % 2 == 1:
count = count + int(K) - 1
print(count)
| 42 | 33 | 838 | 629 | S = eval(input())
K = eval(input())
if not (1 <= len(S) and len(S) <= 100):
exit()
if not (S.isalpha() and S.islower()):
exit()
if not float(K).is_integer():
exit()
if not (1 <= int(K) and int(K) <= 10**9):
exit()
L = []
tmp = []
pre = ""
for s in S:
if len(tmp) == 0:
pre = s
tmp.append(s)
elif pre == s:
tmp.append(s)
else:
L.append(tmp)
pre = s
tmp = [s]
L.append(tmp)
count = 0
for l in L:
count += int(len(l) / 2)
# print(l)
count *= int(K)
if len(L) == 1:
if len(L[0]) == 1:
count = int(int(K) / 2)
elif len(L[0]) % 2 == 1:
count += int(int(K) / 2)
elif L[0][0] == L[len(L) - 1][0]:
if len(L[0]) % 2 == 1 and len(L[len(L) - 1]) % 2 == 1:
count = count + int(K) - 1
print(count)
| S = eval(input())
K = eval(input())
L = []
tmp = []
pre = ""
for s in S:
if len(tmp) == 0:
pre = s
tmp.append(s)
elif pre == s:
tmp.append(s)
else:
L.append(tmp)
pre = s
tmp = [s]
L.append(tmp)
count = 0
for l in L:
count += int(len(l) / 2)
# print(l)
count *= int(K)
if len(L) == 1:
if len(L[0]) == 1:
count = int(int(K) / 2)
elif len(L[0]) % 2 == 1:
count += int(int(K) / 2)
elif L[0][0] == L[len(L) - 1][0]:
if len(L[0]) % 2 == 1 and len(L[len(L) - 1]) % 2 == 1:
count = count + int(K) - 1
print(count)
| false | 21.428571 | [
"-if not (1 <= len(S) and len(S) <= 100):",
"- exit()",
"-if not (S.isalpha() and S.islower()):",
"- exit()",
"-if not float(K).is_integer():",
"- exit()",
"-if not (1 <= int(K) and int(K) <= 10**9):",
"- exit()"
] | false | 0.042059 | 0.042314 | 0.993964 | [
"s088835852",
"s988229131"
] |
u626337957 | p02579 | python | s537508411 | s002616356 | 842 | 718 | 167,872 | 163,396 | Accepted | Accepted | 14.73 | from collections import deque
H, W = list(map(int, input().split()))
cy, cx = list(map(int, input().split()))
sy, sx = list(map(int, input().split()))
tiles = [list(eval(input())) for _ in range(H)]
# initialization
INF = 10**4
arrived = [[INF for _ in range(W)] for __ in range(H)]
paths = deque()
warps = deque()
dx = [1, 0, -1, 0]
dy = [0, -1, 0, 1]
moves = [-2, -1, 0, 1, 2]
arrived[cy-1][cx-1] = 0
paths.append([cx-1, cy-1])
count = 0
# BFS
while(len(paths) > 0):
while(len(paths) > 0):
nx, ny = paths.popleft()
for i in range(4):
if 0 <= nx+dx[i] < W and 0 <= ny+dy[i] < H and arrived[ny+dy[i]][nx+dx[i]] > count and tiles[ny+dy[i]][nx+dx[i]] == '.':
paths.append([nx+dx[i], ny+dy[i]])
arrived[ny+dy[i]][nx+dx[i]] = count
for x in moves:
for y in moves:
if 0 <= nx+x < W and 0 <= ny+y < H and arrived[ny+y][nx+x] == INF and tiles[ny+y][nx+x] == '.':
warps.append([nx+x, ny+y])
count += 1
while(len(warps) > 0):
nx, ny = warps.popleft()
if arrived[ny][nx] == INF:
arrived[ny][nx] = count
paths.append([nx, ny])
if arrived[sy-1][sx-1] != INF:
print((arrived[sy-1][sx-1]))
else:
print((-1)) | from collections import deque
H, W = list(map(int, input().split()))
cy, cx = list(map(int, input().split()))
sy, sx = list(map(int, input().split()))
tiles = [list(eval(input())) for _ in range(H)]
# initialization
INF = 10**4
arrived = [[INF for _ in range(W)] for __ in range(H)]
paths = deque()
warps = deque()
dx = [1, 0, -1, 0]
dy = [0, -1, 0, 1]
moves = [-2, -1, 0, 1, 2]
arrived[cy-1][cx-1] = 0
paths.append([cx-1, cy-1])
count = 0
# BFS
while(len(paths) > 0):
while(len(paths) > 0):
nx, ny = paths.popleft()
if ny == sy-1 and nx == sx-1:
print(count)
exit()
for i in range(4):
if 0 <= nx+dx[i] < W and 0 <= ny+dy[i] < H and arrived[ny+dy[i]][nx+dx[i]] > count and tiles[ny+dy[i]][nx+dx[i]] == '.':
paths.append([nx+dx[i], ny+dy[i]])
arrived[ny+dy[i]][nx+dx[i]] = count
for x in moves:
for y in moves:
if 0 <= nx+x < W and 0 <= ny+y < H and arrived[ny+y][nx+x] == INF and tiles[ny+y][nx+x] == '.':
warps.append([nx+x, ny+y])
count += 1
while(len(warps) > 0):
nx, ny = warps.popleft()
if arrived[ny][nx] == INF:
arrived[ny][nx] = count
paths.append([nx, ny])
print((-1)) | 42 | 41 | 1,198 | 1,194 | from collections import deque
H, W = list(map(int, input().split()))
cy, cx = list(map(int, input().split()))
sy, sx = list(map(int, input().split()))
tiles = [list(eval(input())) for _ in range(H)]
# initialization
INF = 10**4
arrived = [[INF for _ in range(W)] for __ in range(H)]
paths = deque()
warps = deque()
dx = [1, 0, -1, 0]
dy = [0, -1, 0, 1]
moves = [-2, -1, 0, 1, 2]
arrived[cy - 1][cx - 1] = 0
paths.append([cx - 1, cy - 1])
count = 0
# BFS
while len(paths) > 0:
while len(paths) > 0:
nx, ny = paths.popleft()
for i in range(4):
if (
0 <= nx + dx[i] < W
and 0 <= ny + dy[i] < H
and arrived[ny + dy[i]][nx + dx[i]] > count
and tiles[ny + dy[i]][nx + dx[i]] == "."
):
paths.append([nx + dx[i], ny + dy[i]])
arrived[ny + dy[i]][nx + dx[i]] = count
for x in moves:
for y in moves:
if (
0 <= nx + x < W
and 0 <= ny + y < H
and arrived[ny + y][nx + x] == INF
and tiles[ny + y][nx + x] == "."
):
warps.append([nx + x, ny + y])
count += 1
while len(warps) > 0:
nx, ny = warps.popleft()
if arrived[ny][nx] == INF:
arrived[ny][nx] = count
paths.append([nx, ny])
if arrived[sy - 1][sx - 1] != INF:
print((arrived[sy - 1][sx - 1]))
else:
print((-1))
| from collections import deque
H, W = list(map(int, input().split()))
cy, cx = list(map(int, input().split()))
sy, sx = list(map(int, input().split()))
tiles = [list(eval(input())) for _ in range(H)]
# initialization
INF = 10**4
arrived = [[INF for _ in range(W)] for __ in range(H)]
paths = deque()
warps = deque()
dx = [1, 0, -1, 0]
dy = [0, -1, 0, 1]
moves = [-2, -1, 0, 1, 2]
arrived[cy - 1][cx - 1] = 0
paths.append([cx - 1, cy - 1])
count = 0
# BFS
while len(paths) > 0:
while len(paths) > 0:
nx, ny = paths.popleft()
if ny == sy - 1 and nx == sx - 1:
print(count)
exit()
for i in range(4):
if (
0 <= nx + dx[i] < W
and 0 <= ny + dy[i] < H
and arrived[ny + dy[i]][nx + dx[i]] > count
and tiles[ny + dy[i]][nx + dx[i]] == "."
):
paths.append([nx + dx[i], ny + dy[i]])
arrived[ny + dy[i]][nx + dx[i]] = count
for x in moves:
for y in moves:
if (
0 <= nx + x < W
and 0 <= ny + y < H
and arrived[ny + y][nx + x] == INF
and tiles[ny + y][nx + x] == "."
):
warps.append([nx + x, ny + y])
count += 1
while len(warps) > 0:
nx, ny = warps.popleft()
if arrived[ny][nx] == INF:
arrived[ny][nx] = count
paths.append([nx, ny])
print((-1))
| false | 2.380952 | [
"+ if ny == sy - 1 and nx == sx - 1:",
"+ print(count)",
"+ exit()",
"-if arrived[sy - 1][sx - 1] != INF:",
"- print((arrived[sy - 1][sx - 1]))",
"-else:",
"- print((-1))",
"+print((-1))"
] | false | 0.100252 | 0.102255 | 0.980415 | [
"s537508411",
"s002616356"
] |
u075012704 | p04045 | python | s692800942 | s141797748 | 119 | 108 | 2,940 | 2,940 | Accepted | Accepted | 9.24 | N, K = list(map(int, input().split()))
D = set(map(str, input().split()))
for i in range(N, 100000):
a = list(str(i))
a = set(a)
if a & D == set():
print(i)
break
| N, K = list(map(int, input().split()))
D = set(list(input().split()))
while True:
if set(list(str(N))) & D:
N += 1
else:
print(N)
exit()
| 9 | 9 | 194 | 172 | N, K = list(map(int, input().split()))
D = set(map(str, input().split()))
for i in range(N, 100000):
a = list(str(i))
a = set(a)
if a & D == set():
print(i)
break
| N, K = list(map(int, input().split()))
D = set(list(input().split()))
while True:
if set(list(str(N))) & D:
N += 1
else:
print(N)
exit()
| false | 0 | [
"-D = set(map(str, input().split()))",
"-for i in range(N, 100000):",
"- a = list(str(i))",
"- a = set(a)",
"- if a & D == set():",
"- print(i)",
"- break",
"+D = set(list(input().split()))",
"+while True:",
"+ if set(list(str(N))) & D:",
"+ N += 1",
"+ else:",
"+ print(N)",
"+ exit()"
] | false | 0.133037 | 0.092555 | 1.437388 | [
"s692800942",
"s141797748"
] |
u037430802 | p03418 | python | s014481419 | s885494917 | 106 | 85 | 3,064 | 3,060 | Accepted | Accepted | 19.81 | n, k = list(map(int, input().split()))
if k == 0:
print((n**2))
exit()
ans = 0
for b in range(1,n+1):
# 連続部分
if b - k > 0:
ans += (n // b) * (b-k)
# 繰り返し範囲外
if ((n - (n // b)*b) - (k-1)) > 0:
ans += ((n - (n // b)*b) - (k-1))
print(ans) | N,K = list(map(int, input().split()))
if K == 0:
print((N*N))
exit()
ans = 0
for b in range(K+1,N+1):
# N = b * num + rest
num = N // b
rest = N - (b*num)
# b一周期の中に、余りがK以上になる数字が(b-K)個、残りの中でさらに余りがKを超える物があればそれも加算
ans += (b - K) * num + max(0, rest-K+1)
print(ans) | 22 | 17 | 287 | 304 | n, k = list(map(int, input().split()))
if k == 0:
print((n**2))
exit()
ans = 0
for b in range(1, n + 1):
# 連続部分
if b - k > 0:
ans += (n // b) * (b - k)
# 繰り返し範囲外
if ((n - (n // b) * b) - (k - 1)) > 0:
ans += (n - (n // b) * b) - (k - 1)
print(ans)
| N, K = list(map(int, input().split()))
if K == 0:
print((N * N))
exit()
ans = 0
for b in range(K + 1, N + 1):
# N = b * num + rest
num = N // b
rest = N - (b * num)
# b一周期の中に、余りがK以上になる数字が(b-K)個、残りの中でさらに余りがKを超える物があればそれも加算
ans += (b - K) * num + max(0, rest - K + 1)
print(ans)
| false | 22.727273 | [
"-n, k = list(map(int, input().split()))",
"-if k == 0:",
"- print((n**2))",
"+N, K = list(map(int, input().split()))",
"+if K == 0:",
"+ print((N * N))",
"-for b in range(1, n + 1):",
"- # 連続部分",
"- if b - k > 0:",
"- ans += (n // b) * (b - k)",
"- # 繰り返し範囲外",
"- if ((n - (n // b) * b) - (k - 1)) > 0:",
"- ans += (n - (n // b) * b) - (k - 1)",
"+for b in range(K + 1, N + 1):",
"+ # N = b * num + rest",
"+ num = N // b",
"+ rest = N - (b * num)",
"+ # b一周期の中に、余りがK以上になる数字が(b-K)個、残りの中でさらに余りがKを超える物があればそれも加算",
"+ ans += (b - K) * num + max(0, rest - K + 1)"
] | false | 0.038608 | 0.039719 | 0.972024 | [
"s014481419",
"s885494917"
] |
u971091945 | p02571 | python | s170452090 | s950155090 | 79 | 60 | 9,028 | 9,056 | Accepted | Accepted | 24.05 | s = eval(input())
t = eval(input())
l = len(t)
ls = len(s)
ans = 0
for i in range(ls-l+1):
num = 0
for j in range(l):
if s[i+j]==t[j]:
num += 1
ans = max(ans, num)
print((l-ans)) | s = eval(input())
t = eval(input())
lt = len(t)
ls = len(s)
ans = ls
for i in range(ls-lt+1):
num = 0
for j in range(lt):
if s[i+j] != t[j]:
num += 1
ans = min(ans, num)
print(ans) | 14 | 14 | 211 | 215 | s = eval(input())
t = eval(input())
l = len(t)
ls = len(s)
ans = 0
for i in range(ls - l + 1):
num = 0
for j in range(l):
if s[i + j] == t[j]:
num += 1
ans = max(ans, num)
print((l - ans))
| s = eval(input())
t = eval(input())
lt = len(t)
ls = len(s)
ans = ls
for i in range(ls - lt + 1):
num = 0
for j in range(lt):
if s[i + j] != t[j]:
num += 1
ans = min(ans, num)
print(ans)
| false | 0 | [
"-l = len(t)",
"+lt = len(t)",
"-ans = 0",
"-for i in range(ls - l + 1):",
"+ans = ls",
"+for i in range(ls - lt + 1):",
"- for j in range(l):",
"- if s[i + j] == t[j]:",
"+ for j in range(lt):",
"+ if s[i + j] != t[j]:",
"- ans = max(ans, num)",
"-print((l - ans))",
"+ ans = min(ans, num)",
"+print(ans)"
] | false | 0.05654 | 0.137067 | 0.412498 | [
"s170452090",
"s950155090"
] |
u607155447 | p02658 | python | s745335978 | s732282052 | 97 | 55 | 21,648 | 21,672 | Accepted | Accepted | 43.3 | N = int(eval(input()))
Alst = list(map(int, input().split()))
Alst.sort()
ans = 1
rec = True
for i in range(N):
ans = ans * Alst[i]
if ans > 10**18:
rec = False
break
if rec:
print(ans)
else:
print((-1)) | N = int(eval(input()))
Alst = list(map(int, input().split()))
ans = 1
rec = True
if 0 in Alst:
print((0))
else:
for i in range(N):
ans = ans * Alst[i]
if ans > 10**18:
rec = False
break
if rec:
print(ans)
else:
print((-1)) | 15 | 18 | 242 | 303 | N = int(eval(input()))
Alst = list(map(int, input().split()))
Alst.sort()
ans = 1
rec = True
for i in range(N):
ans = ans * Alst[i]
if ans > 10**18:
rec = False
break
if rec:
print(ans)
else:
print((-1))
| N = int(eval(input()))
Alst = list(map(int, input().split()))
ans = 1
rec = True
if 0 in Alst:
print((0))
else:
for i in range(N):
ans = ans * Alst[i]
if ans > 10**18:
rec = False
break
if rec:
print(ans)
else:
print((-1))
| false | 16.666667 | [
"-Alst.sort()",
"-for i in range(N):",
"- ans = ans * Alst[i]",
"- if ans > 10**18:",
"- rec = False",
"- break",
"-if rec:",
"- print(ans)",
"+if 0 in Alst:",
"+ print((0))",
"- print((-1))",
"+ for i in range(N):",
"+ ans = ans * Alst[i]",
"+ if ans > 10**18:",
"+ rec = False",
"+ break",
"+ if rec:",
"+ print(ans)",
"+ else:",
"+ print((-1))"
] | false | 0.108399 | 0.088429 | 1.225836 | [
"s745335978",
"s732282052"
] |
u677523557 | p03044 | python | s145935894 | s379573919 | 592 | 465 | 40,352 | 40,364 | Accepted | Accepted | 21.45 | import sys
input = sys.stdin.readline
N = int(input())
graph = [[] for _ in range(N)]
for _ in range(N-1):
a, b, w = map(int, input().split())
graph[a-1].append((b-1, w))
graph[b-1].append((a-1, w))
def dfs(s):
Ind = [0]*N
stack = [s]
Color = [0]*N
while stack:
p = stack[-1]
if Ind[p] == len(graph[p]):
stack.pop()
elif len(stack) > 1 and stack[-2] == graph[p][Ind[p]][0]:
Ind[p] += 1
else:
ch, w = graph[p][Ind[p]]
Ind[p] += 1
stack.append(ch)
Color[ch] = Color[p]^(w%2)
return Color
Color = dfs(0)
print(*Color, sep="\n")
| import sys
input = sys.stdin.readline
N = int(input())
graph = [[] for _ in range(N)]
for _ in range(N-1):
a, b, w = map(int, input().split())
graph[a-1].append((b-1, w))
graph[b-1].append((a-1, w))
def dfs(s):
stack = [s]
Color = [-1]*N
Color[s] = 0
while stack:
p = stack.pop()
for np, w in graph[p]:
if Color[np] == -1:
Color[np] = Color[p]^(w%2)
stack.append(np)
return Color
if __name__ == "__main__":
Color = dfs(0)
print(*Color, sep="\n")
| 30 | 26 | 694 | 575 | import sys
input = sys.stdin.readline
N = int(input())
graph = [[] for _ in range(N)]
for _ in range(N - 1):
a, b, w = map(int, input().split())
graph[a - 1].append((b - 1, w))
graph[b - 1].append((a - 1, w))
def dfs(s):
Ind = [0] * N
stack = [s]
Color = [0] * N
while stack:
p = stack[-1]
if Ind[p] == len(graph[p]):
stack.pop()
elif len(stack) > 1 and stack[-2] == graph[p][Ind[p]][0]:
Ind[p] += 1
else:
ch, w = graph[p][Ind[p]]
Ind[p] += 1
stack.append(ch)
Color[ch] = Color[p] ^ (w % 2)
return Color
Color = dfs(0)
print(*Color, sep="\n")
| import sys
input = sys.stdin.readline
N = int(input())
graph = [[] for _ in range(N)]
for _ in range(N - 1):
a, b, w = map(int, input().split())
graph[a - 1].append((b - 1, w))
graph[b - 1].append((a - 1, w))
def dfs(s):
stack = [s]
Color = [-1] * N
Color[s] = 0
while stack:
p = stack.pop()
for np, w in graph[p]:
if Color[np] == -1:
Color[np] = Color[p] ^ (w % 2)
stack.append(np)
return Color
if __name__ == "__main__":
Color = dfs(0)
print(*Color, sep="\n")
| false | 13.333333 | [
"- Ind = [0] * N",
"- Color = [0] * N",
"+ Color = [-1] * N",
"+ Color[s] = 0",
"- p = stack[-1]",
"- if Ind[p] == len(graph[p]):",
"- stack.pop()",
"- elif len(stack) > 1 and stack[-2] == graph[p][Ind[p]][0]:",
"- Ind[p] += 1",
"- else:",
"- ch, w = graph[p][Ind[p]]",
"- Ind[p] += 1",
"- stack.append(ch)",
"- Color[ch] = Color[p] ^ (w % 2)",
"+ p = stack.pop()",
"+ for np, w in graph[p]:",
"+ if Color[np] == -1:",
"+ Color[np] = Color[p] ^ (w % 2)",
"+ stack.append(np)",
"-Color = dfs(0)",
"-print(*Color, sep=\"\\n\")",
"+if __name__ == \"__main__\":",
"+ Color = dfs(0)",
"+ print(*Color, sep=\"\\n\")"
] | false | 0.037946 | 0.038032 | 0.997728 | [
"s145935894",
"s379573919"
] |
u822044226 | p02947 | python | s861547568 | s747129978 | 770 | 375 | 19,756 | 19,760 | Accepted | Accepted | 51.3 | import math
from collections import Counter
N = int(eval(input()))
s = []
for _ in range(N):
s.append(''.join(sorted(str(eval(input())))))
c = Counter(s)
def combinations_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
cnt = 0
for i in list(c.values()):
if i >= 2:
cnt += combinations_count(i, 2)
print(cnt) | from collections import Counter
N = int(eval(input()))
s = []
for _ in range(N):
s.append(''.join(sorted(str(eval(input())))))
c = Counter(s)
cnt = 0
for i in list(c.values()):
if i >= 2:
cnt += (i*(i-1))//2
print(cnt) | 20 | 16 | 368 | 233 | import math
from collections import Counter
N = int(eval(input()))
s = []
for _ in range(N):
s.append("".join(sorted(str(eval(input())))))
c = Counter(s)
def combinations_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
cnt = 0
for i in list(c.values()):
if i >= 2:
cnt += combinations_count(i, 2)
print(cnt)
| from collections import Counter
N = int(eval(input()))
s = []
for _ in range(N):
s.append("".join(sorted(str(eval(input())))))
c = Counter(s)
cnt = 0
for i in list(c.values()):
if i >= 2:
cnt += (i * (i - 1)) // 2
print(cnt)
| false | 20 | [
"-import math",
"-",
"-",
"-def combinations_count(n, r):",
"- return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))",
"-",
"-",
"- cnt += combinations_count(i, 2)",
"+ cnt += (i * (i - 1)) // 2"
] | false | 0.046036 | 0.090239 | 0.510151 | [
"s861547568",
"s747129978"
] |
u172873334 | p03796 | python | s996742296 | s540128233 | 56 | 36 | 2,940 | 2,940 | Accepted | Accepted | 35.71 | ans=1
for _ in range(int(eval(input()))):
ans*=_+1
ans%=int(1e9+7)
print(ans)
| mod = 1000000007
n = int(eval(input()))
ans = 1
for i in range(1, n + 1):
ans = ans * i % mod
print(ans) | 5 | 6 | 84 | 107 | ans = 1
for _ in range(int(eval(input()))):
ans *= _ + 1
ans %= int(1e9 + 7)
print(ans)
| mod = 1000000007
n = int(eval(input()))
ans = 1
for i in range(1, n + 1):
ans = ans * i % mod
print(ans)
| false | 16.666667 | [
"+mod = 1000000007",
"+n = int(eval(input()))",
"-for _ in range(int(eval(input()))):",
"- ans *= _ + 1",
"- ans %= int(1e9 + 7)",
"+for i in range(1, n + 1):",
"+ ans = ans * i % mod"
] | false | 0.107311 | 0.111211 | 0.964934 | [
"s996742296",
"s540128233"
] |
u063052907 | p03416 | python | s511344953 | s771959072 | 54 | 19 | 2,940 | 3,060 | Accepted | Accepted | 64.81 | # coding: utf-8
import sys
input = sys.stdin.readline
A, B = list(map(int, input().split()))
ans = 0
for i in range(A, B + 1):
i = str(i)
if i == i[::-1]:
ans += 1
print(ans)
| # coding: utf-8
import sys
input = sys.stdin.readline
A, B = list(map(int, input().split()))
ans = 0
for i in range(1, 10):
for j in range(10):
for k in range(10):
val = 10000*i + 1000*j + 100*k + 10*j + i
if A <= val <= B:
ans+=1
print(ans)
| 11 | 13 | 196 | 301 | # coding: utf-8
import sys
input = sys.stdin.readline
A, B = list(map(int, input().split()))
ans = 0
for i in range(A, B + 1):
i = str(i)
if i == i[::-1]:
ans += 1
print(ans)
| # coding: utf-8
import sys
input = sys.stdin.readline
A, B = list(map(int, input().split()))
ans = 0
for i in range(1, 10):
for j in range(10):
for k in range(10):
val = 10000 * i + 1000 * j + 100 * k + 10 * j + i
if A <= val <= B:
ans += 1
print(ans)
| false | 15.384615 | [
"-for i in range(A, B + 1):",
"- i = str(i)",
"- if i == i[::-1]:",
"- ans += 1",
"+for i in range(1, 10):",
"+ for j in range(10):",
"+ for k in range(10):",
"+ val = 10000 * i + 1000 * j + 100 * k + 10 * j + i",
"+ if A <= val <= B:",
"+ ans += 1"
] | false | 0.054614 | 0.081519 | 0.66996 | [
"s511344953",
"s771959072"
] |
u133936772 | p03103 | python | s789282159 | s039474039 | 574 | 462 | 28,648 | 16,988 | Accepted | Accepted | 19.51 | f = lambda : list(map(int,input().split()))
n,m = f()
ll = sorted([list(f()) for _ in range(n)])
ans = 0
for p, c in ll:
ans += p*min(m,c)
m -= c
if m < 1:
break
print(ans) | f=lambda:list(map(int,input().split()))
n,m=f()
l=[]
for _ in range(n):
l+=[tuple(f())]
l.sort()
c=0
for a,b in l:
if b<m:
m-=b
c+=a*b
else:
c+=a*m
break
print(c) | 10 | 15 | 185 | 192 | f = lambda: list(map(int, input().split()))
n, m = f()
ll = sorted([list(f()) for _ in range(n)])
ans = 0
for p, c in ll:
ans += p * min(m, c)
m -= c
if m < 1:
break
print(ans)
| f = lambda: list(map(int, input().split()))
n, m = f()
l = []
for _ in range(n):
l += [tuple(f())]
l.sort()
c = 0
for a, b in l:
if b < m:
m -= b
c += a * b
else:
c += a * m
break
print(c)
| false | 33.333333 | [
"-ll = sorted([list(f()) for _ in range(n)])",
"-ans = 0",
"-for p, c in ll:",
"- ans += p * min(m, c)",
"- m -= c",
"- if m < 1:",
"+l = []",
"+for _ in range(n):",
"+ l += [tuple(f())]",
"+l.sort()",
"+c = 0",
"+for a, b in l:",
"+ if b < m:",
"+ m -= b",
"+ c += a * b",
"+ else:",
"+ c += a * m",
"-print(ans)",
"+print(c)"
] | false | 0.044798 | 0.105807 | 0.423393 | [
"s789282159",
"s039474039"
] |
u186838327 | p02882 | python | s298597189 | s083083503 | 172 | 64 | 38,384 | 62,204 | Accepted | Accepted | 62.79 | a, b, x = list(map(int, input().split()))
if x == a**2*b:
print((0))
exit()
if x <= a**2*b/2:
t = (2*x)/(a*b**2)
else:
t = (a**3)/(2*(a**2*b-x))
#print(t)
import math
a = math.atan(t)
a = math.degrees(a)
print((90-a))
| a, b, x = list(map(int, input().split()))
if x >= a**2*b/2:
t = 2*(b*a**2-x)/(a**3)
else:
t = (a*b**2)/(2*x)
import math
p = math.atan(t)
p = math.degrees(p)
print(p)
| 16 | 11 | 234 | 181 | a, b, x = list(map(int, input().split()))
if x == a**2 * b:
print((0))
exit()
if x <= a**2 * b / 2:
t = (2 * x) / (a * b**2)
else:
t = (a**3) / (2 * (a**2 * b - x))
# print(t)
import math
a = math.atan(t)
a = math.degrees(a)
print((90 - a))
| a, b, x = list(map(int, input().split()))
if x >= a**2 * b / 2:
t = 2 * (b * a**2 - x) / (a**3)
else:
t = (a * b**2) / (2 * x)
import math
p = math.atan(t)
p = math.degrees(p)
print(p)
| false | 31.25 | [
"-if x == a**2 * b:",
"- print((0))",
"- exit()",
"-if x <= a**2 * b / 2:",
"- t = (2 * x) / (a * b**2)",
"+if x >= a**2 * b / 2:",
"+ t = 2 * (b * a**2 - x) / (a**3)",
"- t = (a**3) / (2 * (a**2 * b - x))",
"-# print(t)",
"+ t = (a * b**2) / (2 * x)",
"-a = math.atan(t)",
"-a = math.degrees(a)",
"-print((90 - a))",
"+p = math.atan(t)",
"+p = math.degrees(p)",
"+print(p)"
] | false | 0.039172 | 0.042745 | 0.916426 | [
"s298597189",
"s083083503"
] |
u968404618 | p02912 | python | s291026031 | s227521368 | 179 | 124 | 14,380 | 20,360 | Accepted | Accepted | 30.73 | from heapq import heappush, heappop
import math
import sys
input = sys.stdin.readline
n, m = list(map(int, input().split()))
A =list(map(int, input().split()))
Hq = []
for a in A:
heappush(Hq, -a)
for _ in range(m):
max = -heappop(Hq)
heappush(Hq, -math.floor(max/2))
print((-sum(Hq))) | from heapq import *
n, m = list(map(int, input().split()))
A = list([int(x)*(-1) for x in input().split()])
heapify(A)
for _ in range(m):
max_a = heappop(A)*(-1)
max_a //= 2
heappush(A, -max_a)
print((-sum(A))) | 15 | 11 | 302 | 231 | from heapq import heappush, heappop
import math
import sys
input = sys.stdin.readline
n, m = list(map(int, input().split()))
A = list(map(int, input().split()))
Hq = []
for a in A:
heappush(Hq, -a)
for _ in range(m):
max = -heappop(Hq)
heappush(Hq, -math.floor(max / 2))
print((-sum(Hq)))
| from heapq import *
n, m = list(map(int, input().split()))
A = list([int(x) * (-1) for x in input().split()])
heapify(A)
for _ in range(m):
max_a = heappop(A) * (-1)
max_a //= 2
heappush(A, -max_a)
print((-sum(A)))
| false | 26.666667 | [
"-from heapq import heappush, heappop",
"-import math",
"-import sys",
"+from heapq import *",
"-input = sys.stdin.readline",
"-A = list(map(int, input().split()))",
"-Hq = []",
"-for a in A:",
"- heappush(Hq, -a)",
"+A = list([int(x) * (-1) for x in input().split()])",
"+heapify(A)",
"- max = -heappop(Hq)",
"- heappush(Hq, -math.floor(max / 2))",
"-print((-sum(Hq)))",
"+ max_a = heappop(A) * (-1)",
"+ max_a //= 2",
"+ heappush(A, -max_a)",
"+print((-sum(A)))"
] | false | 0.170747 | 0.167268 | 1.020799 | [
"s291026031",
"s227521368"
] |
u434630332 | p04029 | python | s779866426 | s076003719 | 27 | 23 | 9,068 | 9,020 | Accepted | Accepted | 14.81 | number = int(eval(input()))
print((int((number + 1) * number / 2))) | n = int(eval(input()))
answer = int((n + 1) * n / 2)
print(answer)
| 3 | 5 | 62 | 67 | number = int(eval(input()))
print((int((number + 1) * number / 2)))
| n = int(eval(input()))
answer = int((n + 1) * n / 2)
print(answer)
| false | 40 | [
"-number = int(eval(input()))",
"-print((int((number + 1) * number / 2)))",
"+n = int(eval(input()))",
"+answer = int((n + 1) * n / 2)",
"+print(answer)"
] | false | 0.049087 | 0.049617 | 0.98931 | [
"s779866426",
"s076003719"
] |
u062147869 | p03634 | python | s985908191 | s009626653 | 1,260 | 844 | 79,748 | 64,404 | Accepted | Accepted | 33.02 | from heapq import heappush,heappop
N = int(eval(input()))
table=[[]for i in range(N)]
for i in range(N-1):
a,b,c=list(map(int,input().split()))
table[a-1].append([b-1,c])
table[b-1].append([a-1,c])
Q,K=list(map(int,input().split()))
Que=[[int(i) for i in input().split()] for i in range(Q)]
inf=10**17
dis=[inf]*N
dis[K-1]=0
kei=[]
heappush(kei,[0,K-1])
while kei:
q,x=heappop(kei)
if dis[x]<q:
continue
for i,d in table[x]:
if dis[x]+d<dis[i]:
dis[i]=dis[x]+d
heappush(kei,[dis[i],i])
ans =[]
for x,y in Que:
ans.append(dis[x-1]+dis[y-1])
print(('\n'.join(map(str,ans)))) | import sys
input = sys.stdin.readline
from heapq import heappop,heappush
N=int(eval(input()))
table=[[] for i in range(N)]
for i in range(N-1):
a,b,c=list(map(int,input().split()))
a,b=a-1,b-1
table[a].append((b,c))
table[b].append((a,c))
Q,K=list(map(int,input().split()))
query=[[int(i)-1 for i in input().split()] for i in range(Q)]
K=K-1
H=[]
visit=[10**18]*(N)
visit[K]=0
heappush(H,(0,K))
while H:
co,pt=heappop(H)
if co>visit[pt]:
continue
for x,c in table[pt]:
if visit[x]>visit[pt]+c:
visit[x]=visit[pt]+c
heappush(H,(visit[x],x))
for a,b in query:
print((visit[a]+visit[b])) | 26 | 27 | 645 | 662 | from heapq import heappush, heappop
N = int(eval(input()))
table = [[] for i in range(N)]
for i in range(N - 1):
a, b, c = list(map(int, input().split()))
table[a - 1].append([b - 1, c])
table[b - 1].append([a - 1, c])
Q, K = list(map(int, input().split()))
Que = [[int(i) for i in input().split()] for i in range(Q)]
inf = 10**17
dis = [inf] * N
dis[K - 1] = 0
kei = []
heappush(kei, [0, K - 1])
while kei:
q, x = heappop(kei)
if dis[x] < q:
continue
for i, d in table[x]:
if dis[x] + d < dis[i]:
dis[i] = dis[x] + d
heappush(kei, [dis[i], i])
ans = []
for x, y in Que:
ans.append(dis[x - 1] + dis[y - 1])
print(("\n".join(map(str, ans))))
| import sys
input = sys.stdin.readline
from heapq import heappop, heappush
N = int(eval(input()))
table = [[] for i in range(N)]
for i in range(N - 1):
a, b, c = list(map(int, input().split()))
a, b = a - 1, b - 1
table[a].append((b, c))
table[b].append((a, c))
Q, K = list(map(int, input().split()))
query = [[int(i) - 1 for i in input().split()] for i in range(Q)]
K = K - 1
H = []
visit = [10**18] * (N)
visit[K] = 0
heappush(H, (0, K))
while H:
co, pt = heappop(H)
if co > visit[pt]:
continue
for x, c in table[pt]:
if visit[x] > visit[pt] + c:
visit[x] = visit[pt] + c
heappush(H, (visit[x], x))
for a, b in query:
print((visit[a] + visit[b]))
| false | 3.703704 | [
"-from heapq import heappush, heappop",
"+import sys",
"+",
"+input = sys.stdin.readline",
"+from heapq import heappop, heappush",
"- table[a - 1].append([b - 1, c])",
"- table[b - 1].append([a - 1, c])",
"+ a, b = a - 1, b - 1",
"+ table[a].append((b, c))",
"+ table[b].append((a, c))",
"-Que = [[int(i) for i in input().split()] for i in range(Q)]",
"-inf = 10**17",
"-dis = [inf] * N",
"-dis[K - 1] = 0",
"-kei = []",
"-heappush(kei, [0, K - 1])",
"-while kei:",
"- q, x = heappop(kei)",
"- if dis[x] < q:",
"+query = [[int(i) - 1 for i in input().split()] for i in range(Q)]",
"+K = K - 1",
"+H = []",
"+visit = [10**18] * (N)",
"+visit[K] = 0",
"+heappush(H, (0, K))",
"+while H:",
"+ co, pt = heappop(H)",
"+ if co > visit[pt]:",
"- for i, d in table[x]:",
"- if dis[x] + d < dis[i]:",
"- dis[i] = dis[x] + d",
"- heappush(kei, [dis[i], i])",
"-ans = []",
"-for x, y in Que:",
"- ans.append(dis[x - 1] + dis[y - 1])",
"-print((\"\\n\".join(map(str, ans))))",
"+ for x, c in table[pt]:",
"+ if visit[x] > visit[pt] + c:",
"+ visit[x] = visit[pt] + c",
"+ heappush(H, (visit[x], x))",
"+for a, b in query:",
"+ print((visit[a] + visit[b]))"
] | false | 0.045693 | 0.042877 | 1.065662 | [
"s985908191",
"s009626653"
] |
u075303794 | p02642 | python | s913861569 | s099191954 | 1,776 | 724 | 104,740 | 123,016 | Accepted | Accepted | 59.23 | import sys
import numpy as np
from numba import njit
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
#@njit
def slove(A):
count = np.zeros(10**6 + 10, np.int32)
for x in A:
if count[x] > 1:
continue
count[::x] += 1
ret = 0
for x in A:
ret += count[x] == 1
return ret
A = np.array(read().split(), np.int32)[1:]
print((slove(A))) | import sys
import numpy as np
from numba import njit
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
@njit
def slove(A):
count = np.zeros(10**6 + 10, np.int32)
for x in A:
if count[x] > 1:
continue
count[::x] += 1
ret = 0
for x in A:
ret += count[x] == 1
return ret
A = np.array(read().split(), np.int32)[1:]
print((slove(A))) | 23 | 23 | 436 | 435 | import sys
import numpy as np
from numba import njit
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# @njit
def slove(A):
count = np.zeros(10**6 + 10, np.int32)
for x in A:
if count[x] > 1:
continue
count[::x] += 1
ret = 0
for x in A:
ret += count[x] == 1
return ret
A = np.array(read().split(), np.int32)[1:]
print((slove(A)))
| import sys
import numpy as np
from numba import njit
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
@njit
def slove(A):
count = np.zeros(10**6 + 10, np.int32)
for x in A:
if count[x] > 1:
continue
count[::x] += 1
ret = 0
for x in A:
ret += count[x] == 1
return ret
A = np.array(read().split(), np.int32)[1:]
print((slove(A)))
| false | 0 | [
"-# @njit",
"+",
"+",
"+@njit"
] | false | 0.839245 | 0.423858 | 1.980012 | [
"s913861569",
"s099191954"
] |
u579699847 | p03329 | python | s214974592 | s294353468 | 973 | 699 | 7,796 | 3,828 | Accepted | Accepted | 28.16 | import itertools,sys
def I(): return int(sys.stdin.readline().rstrip())
N = I()
if N<=5:
print(N)
exit()
dp = [float('INF')]*(N+1)
dp[0] = 0
num6,num9 = 6,9
d6d9 = set()
while num6<=N:
d6d9.add(num6)
num6 *= 6
while num9<=N:
d6d9.add(num9)
num9 *= 9
for i,x in itertools.product(list(range(N+1)),d6d9):
if i+x>=N+1:
continue
dp[i+1] = min(dp[i+1],dp[i]+1)
dp[i+x] = min(dp[i+x],dp[i]+1)
print((dp[-1]))
| import itertools,sys
def I(): return int(sys.stdin.readline().rstrip())
N = I()
dp = [float('INF')]*(N+1)
dp[0] = 0
for i in range(N+1):
if i+1<=N:
dp[i+1] = min(dp[i+1],dp[i]+1)
num6,num9 = 6,9
while i+num6<=N:
dp[i+num6] = min(dp[i+num6],dp[i]+1)
num6 *= 6
while i+num9<=N:
dp[i+num9] = min(dp[i+num9],dp[i]+1)
num9 *=9
print((dp[-1]))
| 22 | 16 | 460 | 407 | import itertools, sys
def I():
return int(sys.stdin.readline().rstrip())
N = I()
if N <= 5:
print(N)
exit()
dp = [float("INF")] * (N + 1)
dp[0] = 0
num6, num9 = 6, 9
d6d9 = set()
while num6 <= N:
d6d9.add(num6)
num6 *= 6
while num9 <= N:
d6d9.add(num9)
num9 *= 9
for i, x in itertools.product(list(range(N + 1)), d6d9):
if i + x >= N + 1:
continue
dp[i + 1] = min(dp[i + 1], dp[i] + 1)
dp[i + x] = min(dp[i + x], dp[i] + 1)
print((dp[-1]))
| import itertools, sys
def I():
return int(sys.stdin.readline().rstrip())
N = I()
dp = [float("INF")] * (N + 1)
dp[0] = 0
for i in range(N + 1):
if i + 1 <= N:
dp[i + 1] = min(dp[i + 1], dp[i] + 1)
num6, num9 = 6, 9
while i + num6 <= N:
dp[i + num6] = min(dp[i + num6], dp[i] + 1)
num6 *= 6
while i + num9 <= N:
dp[i + num9] = min(dp[i + num9], dp[i] + 1)
num9 *= 9
print((dp[-1]))
| false | 27.272727 | [
"-if N <= 5:",
"- print(N)",
"- exit()",
"-num6, num9 = 6, 9",
"-d6d9 = set()",
"-while num6 <= N:",
"- d6d9.add(num6)",
"- num6 *= 6",
"-while num9 <= N:",
"- d6d9.add(num9)",
"- num9 *= 9",
"-for i, x in itertools.product(list(range(N + 1)), d6d9):",
"- if i + x >= N + 1:",
"- continue",
"- dp[i + 1] = min(dp[i + 1], dp[i] + 1)",
"- dp[i + x] = min(dp[i + x], dp[i] + 1)",
"+for i in range(N + 1):",
"+ if i + 1 <= N:",
"+ dp[i + 1] = min(dp[i + 1], dp[i] + 1)",
"+ num6, num9 = 6, 9",
"+ while i + num6 <= N:",
"+ dp[i + num6] = min(dp[i + num6], dp[i] + 1)",
"+ num6 *= 6",
"+ while i + num9 <= N:",
"+ dp[i + num9] = min(dp[i + num9], dp[i] + 1)",
"+ num9 *= 9"
] | false | 0.174601 | 0.217255 | 0.803669 | [
"s214974592",
"s294353468"
] |
u832039789 | p03986 | python | s756547015 | s588640071 | 77 | 61 | 5,096 | 3,500 | Accepted | Accepted | 20.78 | stack = []
for c in eval(input()):
if c=='S' or len(stack)==0:
stack.append(c)
elif stack[-1]=='S':
stack.pop()
else:
stack.append(c)
#print(stack)
print((len(stack)))
| s = eval(input())
SSS = 0
len = 0
for c in s:
if c == 'S':
SSS += 1
len += 1
elif SSS == 0:
len += 1
else:
SSS -= 1
len -= 1
# print(len)
print(len)
| 12 | 14 | 213 | 212 | stack = []
for c in eval(input()):
if c == "S" or len(stack) == 0:
stack.append(c)
elif stack[-1] == "S":
stack.pop()
else:
stack.append(c)
# print(stack)
print((len(stack)))
| s = eval(input())
SSS = 0
len = 0
for c in s:
if c == "S":
SSS += 1
len += 1
elif SSS == 0:
len += 1
else:
SSS -= 1
len -= 1
# print(len)
print(len)
| false | 14.285714 | [
"-stack = []",
"-for c in eval(input()):",
"- if c == \"S\" or len(stack) == 0:",
"- stack.append(c)",
"- elif stack[-1] == \"S\":",
"- stack.pop()",
"+s = eval(input())",
"+SSS = 0",
"+len = 0",
"+for c in s:",
"+ if c == \"S\":",
"+ SSS += 1",
"+ len += 1",
"+ elif SSS == 0:",
"+ len += 1",
"- stack.append(c)",
"- # print(stack)",
"-print((len(stack)))",
"+ SSS -= 1",
"+ len -= 1",
"+ # print(len)",
"+print(len)"
] | false | 0.037101 | 0.03704 | 1.001639 | [
"s756547015",
"s588640071"
] |
u631277801 | p04013 | python | s859525256 | s680765229 | 38 | 34 | 3,572 | 3,572 | Accepted | Accepted | 10.53 | import collections
N,A = list(map(int, input().split()))
X = list(map(int,input().split()))
for i in range(N):
X[i] -= A
sums = collections.Counter([0,X[0]])
for i in X[1:]:
c = collections.Counter()
for p,q in list(sums.items()):
c[i+p] = q
sums += c
print((sums[0]-1))
| from collections import Counter
N, A = list(map(int, input().split()))
X = list(map(int, input().split()))
for i in range(N):
X[i] -= A
sums = Counter([0,X[0]])
for i in range(1,N):
ith_x = X[i]
ith_hash = {}
for key, value in list(sums.items()):
ith_hash[ith_x + key] = value
sums += ith_hash
print((sums[0]-1)) | 17 | 19 | 306 | 366 | import collections
N, A = list(map(int, input().split()))
X = list(map(int, input().split()))
for i in range(N):
X[i] -= A
sums = collections.Counter([0, X[0]])
for i in X[1:]:
c = collections.Counter()
for p, q in list(sums.items()):
c[i + p] = q
sums += c
print((sums[0] - 1))
| from collections import Counter
N, A = list(map(int, input().split()))
X = list(map(int, input().split()))
for i in range(N):
X[i] -= A
sums = Counter([0, X[0]])
for i in range(1, N):
ith_x = X[i]
ith_hash = {}
for key, value in list(sums.items()):
ith_hash[ith_x + key] = value
sums += ith_hash
print((sums[0] - 1))
| false | 10.526316 | [
"-import collections",
"+from collections import Counter",
"-sums = collections.Counter([0, X[0]])",
"-for i in X[1:]:",
"- c = collections.Counter()",
"- for p, q in list(sums.items()):",
"- c[i + p] = q",
"- sums += c",
"+sums = Counter([0, X[0]])",
"+for i in range(1, N):",
"+ ith_x = X[i]",
"+ ith_hash = {}",
"+ for key, value in list(sums.items()):",
"+ ith_hash[ith_x + key] = value",
"+ sums += ith_hash"
] | false | 0.047966 | 0.047973 | 0.999866 | [
"s859525256",
"s680765229"
] |
u077291787 | p02755 | python | s681031683 | s782500615 | 20 | 17 | 3,060 | 3,060 | Accepted | Accepted | 15 | # C - Tax Increase
from math import floor
def calc(a: int, b: int) -> int:
for i in range(1, 10001):
if floor(i * 0.08) == a and floor(i * 0.1) == b:
return i
return -1
def main():
A, B = list(map(int, input().split()))
print((calc(A, B)))
if __name__ == "__main__":
main()
| # C - Tax Increase
from math import floor
def calc(a: int, b: int) -> int:
for i in range(1, 1010):
if floor(i * 0.08) == a and floor(i * 0.1) == b:
return i
return -1
def main():
A, B = list(map(int, input().split()))
print((calc(A, B)))
if __name__ == "__main__":
main()
| 17 | 18 | 327 | 328 | # C - Tax Increase
from math import floor
def calc(a: int, b: int) -> int:
for i in range(1, 10001):
if floor(i * 0.08) == a and floor(i * 0.1) == b:
return i
return -1
def main():
A, B = list(map(int, input().split()))
print((calc(A, B)))
if __name__ == "__main__":
main()
| # C - Tax Increase
from math import floor
def calc(a: int, b: int) -> int:
for i in range(1, 1010):
if floor(i * 0.08) == a and floor(i * 0.1) == b:
return i
return -1
def main():
A, B = list(map(int, input().split()))
print((calc(A, B)))
if __name__ == "__main__":
main()
| false | 5.555556 | [
"- for i in range(1, 10001):",
"+ for i in range(1, 1010):"
] | false | 0.054261 | 0.051408 | 1.055487 | [
"s681031683",
"s782500615"
] |
u827885761 | p03014 | python | s650860271 | s935093989 | 1,726 | 1,018 | 91,352 | 102,232 | Accepted | Accepted | 41.02 | import sys
from bisect import bisect_left
sys.setrecursionlimit(10**7)
def lmi(): return list(map(int, input().split()))
h, w = lmi()
s = [eval(input()) for i in range(h)]
a = [[] for i in range(h)]
#al = [[] for i in range(h)]
b = [[] for i in range(w)]
bl = [[] for i in range(w)]
for i in range(h):
k = 0
for j in range(w):
if s[i][j] == '.':
k += 1
if j == w-1:
a[i].append(k)
#al[i].append(j)
elif j != 0 and s[i][j-1] == '.':
a[i].append(k)
#al[i].append(j-1)
k = 0
for i in range(w):
k = 0
for j in range(h):
if s[j][i] == '.':
k += 1
if j == h-1:
b[i].append(k)
bl[i].append(j)
elif j != 0 and s[j-1][i] == '.':
b[i].append(k)
bl[i].append(j-1)
k = 0
'''
print(a)
print(al)
print(b)
print(bl)
'''
ans = 0
for i in range(h):
k = 0
c = -1
for j in range(w):
if s[i][j] == '.':
c = a[i][k]
d = b[j][bisect_left(bl[j], i)]
#print(c,d)
ans = max(ans, c+d-1)
elif j != 0 and s[i][j-1] == '.' and c != -1:
k += 1
print(ans)
| from bisect import bisect_left
def lmi(): return list(map(int, input().split()))
h, w = lmi()
s = [eval(input()) for i in range(h)]
cnt = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
j = 0
while j < w:
if s[i][j] == '#':
j += 1
continue
l = 0
while j+l < w:
if s[i][j+l] == '#':
break
l += 1
for k in range(l):
cnt[i][j+k] += l
j += l+1
for i in range(w):
j = 0
while j < h:
if s[j][i] == '#':
j += 1
continue
l = 0
while j+l < h:
if s[j+l][i] == '#':
break
l += 1
for k in range(l):
cnt[j+k][i] += l
j += l+1
print((max([max([cnt[i][j] for i in range(h)]) for j in range(w)])-1))
| 57 | 39 | 1,303 | 880 | import sys
from bisect import bisect_left
sys.setrecursionlimit(10**7)
def lmi():
return list(map(int, input().split()))
h, w = lmi()
s = [eval(input()) for i in range(h)]
a = [[] for i in range(h)]
# al = [[] for i in range(h)]
b = [[] for i in range(w)]
bl = [[] for i in range(w)]
for i in range(h):
k = 0
for j in range(w):
if s[i][j] == ".":
k += 1
if j == w - 1:
a[i].append(k)
# al[i].append(j)
elif j != 0 and s[i][j - 1] == ".":
a[i].append(k)
# al[i].append(j-1)
k = 0
for i in range(w):
k = 0
for j in range(h):
if s[j][i] == ".":
k += 1
if j == h - 1:
b[i].append(k)
bl[i].append(j)
elif j != 0 and s[j - 1][i] == ".":
b[i].append(k)
bl[i].append(j - 1)
k = 0
"""
print(a)
print(al)
print(b)
print(bl)
"""
ans = 0
for i in range(h):
k = 0
c = -1
for j in range(w):
if s[i][j] == ".":
c = a[i][k]
d = b[j][bisect_left(bl[j], i)]
# print(c,d)
ans = max(ans, c + d - 1)
elif j != 0 and s[i][j - 1] == "." and c != -1:
k += 1
print(ans)
| from bisect import bisect_left
def lmi():
return list(map(int, input().split()))
h, w = lmi()
s = [eval(input()) for i in range(h)]
cnt = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
j = 0
while j < w:
if s[i][j] == "#":
j += 1
continue
l = 0
while j + l < w:
if s[i][j + l] == "#":
break
l += 1
for k in range(l):
cnt[i][j + k] += l
j += l + 1
for i in range(w):
j = 0
while j < h:
if s[j][i] == "#":
j += 1
continue
l = 0
while j + l < h:
if s[j + l][i] == "#":
break
l += 1
for k in range(l):
cnt[j + k][i] += l
j += l + 1
print((max([max([cnt[i][j] for i in range(h)]) for j in range(w)]) - 1))
| false | 31.578947 | [
"-import sys",
"-",
"-sys.setrecursionlimit(10**7)",
"-a = [[] for i in range(h)]",
"-# al = [[] for i in range(h)]",
"-b = [[] for i in range(w)]",
"-bl = [[] for i in range(w)]",
"+cnt = [[0 for i in range(w)] for j in range(h)]",
"- k = 0",
"- for j in range(w):",
"- if s[i][j] == \".\":",
"- k += 1",
"- if j == w - 1:",
"- a[i].append(k)",
"- # al[i].append(j)",
"- elif j != 0 and s[i][j - 1] == \".\":",
"- a[i].append(k)",
"- # al[i].append(j-1)",
"- k = 0",
"+ j = 0",
"+ while j < w:",
"+ if s[i][j] == \"#\":",
"+ j += 1",
"+ continue",
"+ l = 0",
"+ while j + l < w:",
"+ if s[i][j + l] == \"#\":",
"+ break",
"+ l += 1",
"+ for k in range(l):",
"+ cnt[i][j + k] += l",
"+ j += l + 1",
"- k = 0",
"- for j in range(h):",
"- if s[j][i] == \".\":",
"- k += 1",
"- if j == h - 1:",
"- b[i].append(k)",
"- bl[i].append(j)",
"- elif j != 0 and s[j - 1][i] == \".\":",
"- b[i].append(k)",
"- bl[i].append(j - 1)",
"- k = 0",
"-\"\"\"",
"-print(a)",
"-print(al)",
"-print(b)",
"-print(bl)",
"-\"\"\"",
"-ans = 0",
"-for i in range(h):",
"- k = 0",
"- c = -1",
"- for j in range(w):",
"- if s[i][j] == \".\":",
"- c = a[i][k]",
"- d = b[j][bisect_left(bl[j], i)]",
"- # print(c,d)",
"- ans = max(ans, c + d - 1)",
"- elif j != 0 and s[i][j - 1] == \".\" and c != -1:",
"- k += 1",
"-print(ans)",
"+ j = 0",
"+ while j < h:",
"+ if s[j][i] == \"#\":",
"+ j += 1",
"+ continue",
"+ l = 0",
"+ while j + l < h:",
"+ if s[j + l][i] == \"#\":",
"+ break",
"+ l += 1",
"+ for k in range(l):",
"+ cnt[j + k][i] += l",
"+ j += l + 1",
"+print((max([max([cnt[i][j] for i in range(h)]) for j in range(w)]) - 1))"
] | false | 0.037864 | 0.037811 | 1.001393 | [
"s650860271",
"s935093989"
] |
u588794534 | p03295 | python | s389018046 | s035191710 | 846 | 763 | 59,992 | 62,552 | Accepted | Accepted | 9.81 | n,m=list(map(int,input().split()))
ab=[]
for _ in range(m):
a,b=list(map(int,input().split()))
ab.append([a,b])
ab.sort()
ll=ab[0][0]
rr=ab[0][1]
cnt=1
#print(ab[0],ll,rr,cnt)
for item in ab[1:]:
l=item[0]
r=item[1]
if l>=rr:
cnt+=1
ll=l
rr=r
else:
if r<rr:
rr=r
if ll<l:
ll=l
#print(item,ll,rr,cnt)
print(cnt)
| n,m=list(map(int,input().split()))
ab=[]
for _ in range(m):
a,b=list(map(int,input().split()))
ab.append([a,b])
ab.sort(key=lambda x: x[1])
cnt=0
border=0
for item in ab:
if item[0]>=border:
border=item[1]
cnt+=1
print(cnt)
| 30 | 19 | 426 | 264 | n, m = list(map(int, input().split()))
ab = []
for _ in range(m):
a, b = list(map(int, input().split()))
ab.append([a, b])
ab.sort()
ll = ab[0][0]
rr = ab[0][1]
cnt = 1
# print(ab[0],ll,rr,cnt)
for item in ab[1:]:
l = item[0]
r = item[1]
if l >= rr:
cnt += 1
ll = l
rr = r
else:
if r < rr:
rr = r
if ll < l:
ll = l
# print(item,ll,rr,cnt)
print(cnt)
| n, m = list(map(int, input().split()))
ab = []
for _ in range(m):
a, b = list(map(int, input().split()))
ab.append([a, b])
ab.sort(key=lambda x: x[1])
cnt = 0
border = 0
for item in ab:
if item[0] >= border:
border = item[1]
cnt += 1
print(cnt)
| false | 36.666667 | [
"-ab.sort()",
"-ll = ab[0][0]",
"-rr = ab[0][1]",
"-cnt = 1",
"-# print(ab[0],ll,rr,cnt)",
"-for item in ab[1:]:",
"- l = item[0]",
"- r = item[1]",
"- if l >= rr:",
"+ab.sort(key=lambda x: x[1])",
"+cnt = 0",
"+border = 0",
"+for item in ab:",
"+ if item[0] >= border:",
"+ border = item[1]",
"- ll = l",
"- rr = r",
"- else:",
"- if r < rr:",
"- rr = r",
"- if ll < l:",
"- ll = l",
"- # print(item,ll,rr,cnt)"
] | false | 0.084498 | 0.040917 | 2.065122 | [
"s389018046",
"s035191710"
] |
u736149053 | p02802 | python | s303219300 | s862454476 | 462 | 398 | 37,092 | 14,016 | Accepted | Accepted | 13.85 | import numpy as np
def main():
N, M = list(map(int, input().split()))
PS = {}
for i in range(M):
row = input().split()
row[0] = int(row[0])
if row[0] not in PS:
PS[row[0]] = [row[1]]
else:
PS[row[0]].append(row[1])
n_correct = 0
n_penalty = 0
for p in PS:
if 'AC' in PS[p]:
n_correct += 1
for result in PS[p]:
if result == 'AC':
break
if result == 'WA':
n_penalty += 1
print(('{} {}'.format(n_correct, n_penalty)))
if __name__ == '__main__':
main() | import numpy as np
def main():
# N, M = map(int, input().split())
# PS = {}
# for i in range(M):
# row = input().split()
# row[0] = int(row[0])
# if row[0] not in PS:
# PS[row[0]] = [row[1]]
# else:
# PS[row[0]].append(row[1])
# n_correct = 0
# n_penalty = 0
# for p in PS:
# if 'AC' in PS[p]:
# n_correct += 1
# for result in PS[p]:
# if result == 'AC':
# break
# if result == 'WA':
# n_penalty += 1
# print('{} {}'.format(n_correct, n_penalty))
N, M = list(map(int, input().split()))
accepted = [False] * N
penalties = [0] * N
for _ in range(M):
q, res = input().split()
q = int(q) - 1
if res[0] == 'A':
accepted[q] = True
elif res[0] == 'W' and not accepted[q]:
penalties[q] += 1
s_acc = 0
s_pen = 0
for i in range(N):
if accepted[i]:
s_acc += 1
s_pen += penalties[i]
print(('{} {}'.format(s_acc, s_pen)))
if __name__ == '__main__':
main() | 30 | 49 | 679 | 1,210 | import numpy as np
def main():
N, M = list(map(int, input().split()))
PS = {}
for i in range(M):
row = input().split()
row[0] = int(row[0])
if row[0] not in PS:
PS[row[0]] = [row[1]]
else:
PS[row[0]].append(row[1])
n_correct = 0
n_penalty = 0
for p in PS:
if "AC" in PS[p]:
n_correct += 1
for result in PS[p]:
if result == "AC":
break
if result == "WA":
n_penalty += 1
print(("{} {}".format(n_correct, n_penalty)))
if __name__ == "__main__":
main()
| import numpy as np
def main():
# N, M = map(int, input().split())
# PS = {}
# for i in range(M):
# row = input().split()
# row[0] = int(row[0])
# if row[0] not in PS:
# PS[row[0]] = [row[1]]
# else:
# PS[row[0]].append(row[1])
# n_correct = 0
# n_penalty = 0
# for p in PS:
# if 'AC' in PS[p]:
# n_correct += 1
# for result in PS[p]:
# if result == 'AC':
# break
# if result == 'WA':
# n_penalty += 1
# print('{} {}'.format(n_correct, n_penalty))
N, M = list(map(int, input().split()))
accepted = [False] * N
penalties = [0] * N
for _ in range(M):
q, res = input().split()
q = int(q) - 1
if res[0] == "A":
accepted[q] = True
elif res[0] == "W" and not accepted[q]:
penalties[q] += 1
s_acc = 0
s_pen = 0
for i in range(N):
if accepted[i]:
s_acc += 1
s_pen += penalties[i]
print(("{} {}".format(s_acc, s_pen)))
if __name__ == "__main__":
main()
| false | 38.77551 | [
"+ # N, M = map(int, input().split())",
"+ # PS = {}",
"+ # for i in range(M):",
"+ # row = input().split()",
"+ # row[0] = int(row[0])",
"+ # if row[0] not in PS:",
"+ # PS[row[0]] = [row[1]]",
"+ # else:",
"+ # PS[row[0]].append(row[1])",
"+ # n_correct = 0",
"+ # n_penalty = 0",
"+ # for p in PS:",
"+ # if 'AC' in PS[p]:",
"+ # n_correct += 1",
"+ # for result in PS[p]:",
"+ # if result == 'AC':",
"+ # break",
"+ # if result == 'WA':",
"+ # n_penalty += 1",
"+ # print('{} {}'.format(n_correct, n_penalty))",
"- PS = {}",
"- for i in range(M):",
"- row = input().split()",
"- row[0] = int(row[0])",
"- if row[0] not in PS:",
"- PS[row[0]] = [row[1]]",
"- else:",
"- PS[row[0]].append(row[1])",
"- n_correct = 0",
"- n_penalty = 0",
"- for p in PS:",
"- if \"AC\" in PS[p]:",
"- n_correct += 1",
"- for result in PS[p]:",
"- if result == \"AC\":",
"- break",
"- if result == \"WA\":",
"- n_penalty += 1",
"- print((\"{} {}\".format(n_correct, n_penalty)))",
"+ accepted = [False] * N",
"+ penalties = [0] * N",
"+ for _ in range(M):",
"+ q, res = input().split()",
"+ q = int(q) - 1",
"+ if res[0] == \"A\":",
"+ accepted[q] = True",
"+ elif res[0] == \"W\" and not accepted[q]:",
"+ penalties[q] += 1",
"+ s_acc = 0",
"+ s_pen = 0",
"+ for i in range(N):",
"+ if accepted[i]:",
"+ s_acc += 1",
"+ s_pen += penalties[i]",
"+ print((\"{} {}\".format(s_acc, s_pen)))"
] | false | 0.047639 | 0.048525 | 0.981736 | [
"s303219300",
"s862454476"
] |
u104005543 | p02678 | python | s277211842 | s596271719 | 771 | 675 | 34,748 | 35,096 | Accepted | Accepted | 12.45 | from collections import deque
n, m = list(map(int, input().split()))
way = [[] for i in range(n + 1)]
ans = [-1 for i in range(n + 1)]
reached = [0 for i in range(n + 1)]
for i in range(m):
a, b = list(map(int, input().split()))
way[a].append(b)
way[b].append(a)
D = deque([1])
while D:
go = D.popleft()
for i in way[go]:
if reached[i] == 0:
D.append(i)
reached[i] = 1
ans[i] = go
print('Yes')
for i in range(2, n + 1):
print((ans[i])) | from collections import deque
n, m = list(map(int, input().split()))
route =[[] for i in range(n+1)]
for i in range(m):
a, b = list(map(int, input().split()))
route[a].append(b)
route[b].append(a)
visited = [0 for i in range(n+1)]
visited[1] = 1
ans = [0 for i in range(n+1)]
D = deque()
D.append(1)
while D:
visit = D.popleft()
for i in route[visit]:
if visited[i] == 0:
D.append(i)
visited[i] = 1
ans[i] = visit
print('Yes')
for i in range(2, n+1):
print((ans[i])) | 20 | 22 | 508 | 541 | from collections import deque
n, m = list(map(int, input().split()))
way = [[] for i in range(n + 1)]
ans = [-1 for i in range(n + 1)]
reached = [0 for i in range(n + 1)]
for i in range(m):
a, b = list(map(int, input().split()))
way[a].append(b)
way[b].append(a)
D = deque([1])
while D:
go = D.popleft()
for i in way[go]:
if reached[i] == 0:
D.append(i)
reached[i] = 1
ans[i] = go
print("Yes")
for i in range(2, n + 1):
print((ans[i]))
| from collections import deque
n, m = list(map(int, input().split()))
route = [[] for i in range(n + 1)]
for i in range(m):
a, b = list(map(int, input().split()))
route[a].append(b)
route[b].append(a)
visited = [0 for i in range(n + 1)]
visited[1] = 1
ans = [0 for i in range(n + 1)]
D = deque()
D.append(1)
while D:
visit = D.popleft()
for i in route[visit]:
if visited[i] == 0:
D.append(i)
visited[i] = 1
ans[i] = visit
print("Yes")
for i in range(2, n + 1):
print((ans[i]))
| false | 9.090909 | [
"-way = [[] for i in range(n + 1)]",
"-ans = [-1 for i in range(n + 1)]",
"-reached = [0 for i in range(n + 1)]",
"+route = [[] for i in range(n + 1)]",
"- way[a].append(b)",
"- way[b].append(a)",
"-D = deque([1])",
"+ route[a].append(b)",
"+ route[b].append(a)",
"+visited = [0 for i in range(n + 1)]",
"+visited[1] = 1",
"+ans = [0 for i in range(n + 1)]",
"+D = deque()",
"+D.append(1)",
"- go = D.popleft()",
"- for i in way[go]:",
"- if reached[i] == 0:",
"+ visit = D.popleft()",
"+ for i in route[visit]:",
"+ if visited[i] == 0:",
"- reached[i] = 1",
"- ans[i] = go",
"+ visited[i] = 1",
"+ ans[i] = visit"
] | false | 0.038059 | 0.040167 | 0.947517 | [
"s277211842",
"s596271719"
] |
u392319141 | p03775 | python | s050278819 | s712913301 | 34 | 28 | 3,064 | 3,064 | Accepted | Accepted | 17.65 | N = int(eval(input()))
def factor(n):
factList = []
i = 1
while i * i <= n:
if n % i == 0:
factList.append(i)
factList.append(n // i)
i += 1
factList.sort()
return factList
fact = factor(N)
ans = float('inf')
for i in range(len(fact)):
f = max(len(str(fact[i])), len(str(fact[-1 - i])))
ans = min(ans, f)
print(ans) | N = int(eval(input()))
# 約数の全列挙
def divisors(n):
divisors = []
R = int(n**(0.5)) + 1
for i in range(1, R):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n // i)
# divisors.sort(reverse=True) # ソート
return divisors
ans = len(str(N))
for a in divisors(N):
b = N // a
ans = min(ans, max(len(str(a)), len(str(b))))
print(ans) | 22 | 19 | 403 | 431 | N = int(eval(input()))
def factor(n):
factList = []
i = 1
while i * i <= n:
if n % i == 0:
factList.append(i)
factList.append(n // i)
i += 1
factList.sort()
return factList
fact = factor(N)
ans = float("inf")
for i in range(len(fact)):
f = max(len(str(fact[i])), len(str(fact[-1 - i])))
ans = min(ans, f)
print(ans)
| N = int(eval(input()))
# 約数の全列挙
def divisors(n):
divisors = []
R = int(n ** (0.5)) + 1
for i in range(1, R):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n // i)
# divisors.sort(reverse=True) # ソート
return divisors
ans = len(str(N))
for a in divisors(N):
b = N // a
ans = min(ans, max(len(str(a)), len(str(b))))
print(ans)
| false | 13.636364 | [
"+# 約数の全列挙",
"+def divisors(n):",
"+ divisors = []",
"+ R = int(n ** (0.5)) + 1",
"+ for i in range(1, R):",
"+ if n % i == 0:",
"+ divisors.append(i)",
"+ if i != n // i:",
"+ divisors.append(n // i)",
"+ # divisors.sort(reverse=True) # ソート",
"+ return divisors",
"-def factor(n):",
"- factList = []",
"- i = 1",
"- while i * i <= n:",
"- if n % i == 0:",
"- factList.append(i)",
"- factList.append(n // i)",
"- i += 1",
"- factList.sort()",
"- return factList",
"-",
"-",
"-fact = factor(N)",
"-ans = float(\"inf\")",
"-for i in range(len(fact)):",
"- f = max(len(str(fact[i])), len(str(fact[-1 - i])))",
"- ans = min(ans, f)",
"+ans = len(str(N))",
"+for a in divisors(N):",
"+ b = N // a",
"+ ans = min(ans, max(len(str(a)), len(str(b))))"
] | false | 0.118118 | 0.046433 | 2.543874 | [
"s050278819",
"s712913301"
] |
u334712262 | p03078 | python | s862549377 | s483574392 | 1,379 | 277 | 86,492 | 85,916 | Accepted | Accepted | 79.91 | # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
from operator import add, mul, sub, itemgetter, attrgetter
import sys
# sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline
INF = 2**62-1
def read_int():
return int(readline())
def read_int_n():
return list(map(int, readline().split()))
def read_float():
return float(readline())
def read_float_n():
return list(map(float, readline().split()))
def read_str():
return readline().strip()
def read_str_n():
return readline().strip().split()
def error_print(*args):
print(*args, file=sys.stderr)
def mt(f):
import time
def wrap(*args, **kwargs):
s = time.perf_counter()
ret = f(*args, **kwargs)
e = time.perf_counter()
error_print(e - s, 'sec')
return ret
return wrap
@mt
def slv(X, Y, Z, K, A, B, C):
q = []
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
if len(A) > K:
A = A[:K]
if len(B) > K:
B = B[:K]
if len(C) > K:
C = C[:K]
for a in A:
for b in B:
heapq.heappush(q, a+b)
if len(q) > K:
heapq.heappop(q)
qq = []
for c in C:
for d in q:
heapq.heappush(qq, d+c)
if len(qq) > K:
heapq.heappop(qq)
qq.sort(reverse=True)
return qq
def main():
X, Y, Z, K = read_int_n()
A = read_int_n()
B = read_int_n()
C = read_int_n()
print(*slv(X, Y, Z, K, A, B, C), sep='\n')
if __name__ == '__main__':
main()
| # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
from operator import add, mul, sub, itemgetter, attrgetter
import sys
# sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline
INF = 2**62-1
def read_int():
return int(readline())
def read_int_n():
return list(map(int, readline().split()))
def read_float():
return float(readline())
def read_float_n():
return list(map(float, readline().split()))
def read_str():
return readline().strip()
def read_str_n():
return readline().strip().split()
def error_print(*args):
print(*args, file=sys.stderr)
def mt(f):
import time
def wrap(*args, **kwargs):
s = time.perf_counter()
ret = f(*args, **kwargs)
e = time.perf_counter()
error_print(e - s, 'sec')
return ret
return wrap
@mt
def slv(X, Y, Z, K, A, B, C):
q = []
for a in A:
for b in B:
if len(q) < K:
heapq.heappush(q, a+b)
else:
heapq.heappushpop(q, a+b)
qq = []
for c in C:
for d in q:
if len(qq) < K:
heapq.heappush(qq, d+c)
else:
heapq.heappushpop(qq, d+c)
qq.sort(reverse=True)
return qq
def main():
X, Y, Z, K = read_int_n()
A = read_int_n()
B = read_int_n()
C = read_int_n()
print(*slv(X, Y, Z, K, A, B, C), sep='\n')
if __name__ == '__main__':
main()
| 101 | 95 | 2,016 | 1,887 | # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import (
combinations,
combinations_with_replacement,
product,
permutations,
accumulate,
)
from operator import add, mul, sub, itemgetter, attrgetter
import sys
# sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline
INF = 2**62 - 1
def read_int():
return int(readline())
def read_int_n():
return list(map(int, readline().split()))
def read_float():
return float(readline())
def read_float_n():
return list(map(float, readline().split()))
def read_str():
return readline().strip()
def read_str_n():
return readline().strip().split()
def error_print(*args):
print(*args, file=sys.stderr)
def mt(f):
import time
def wrap(*args, **kwargs):
s = time.perf_counter()
ret = f(*args, **kwargs)
e = time.perf_counter()
error_print(e - s, "sec")
return ret
return wrap
@mt
def slv(X, Y, Z, K, A, B, C):
q = []
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
if len(A) > K:
A = A[:K]
if len(B) > K:
B = B[:K]
if len(C) > K:
C = C[:K]
for a in A:
for b in B:
heapq.heappush(q, a + b)
if len(q) > K:
heapq.heappop(q)
qq = []
for c in C:
for d in q:
heapq.heappush(qq, d + c)
if len(qq) > K:
heapq.heappop(qq)
qq.sort(reverse=True)
return qq
def main():
X, Y, Z, K = read_int_n()
A = read_int_n()
B = read_int_n()
C = read_int_n()
print(*slv(X, Y, Z, K, A, B, C), sep="\n")
if __name__ == "__main__":
main()
| # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import (
combinations,
combinations_with_replacement,
product,
permutations,
accumulate,
)
from operator import add, mul, sub, itemgetter, attrgetter
import sys
# sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline
INF = 2**62 - 1
def read_int():
return int(readline())
def read_int_n():
return list(map(int, readline().split()))
def read_float():
return float(readline())
def read_float_n():
return list(map(float, readline().split()))
def read_str():
return readline().strip()
def read_str_n():
return readline().strip().split()
def error_print(*args):
print(*args, file=sys.stderr)
def mt(f):
import time
def wrap(*args, **kwargs):
s = time.perf_counter()
ret = f(*args, **kwargs)
e = time.perf_counter()
error_print(e - s, "sec")
return ret
return wrap
@mt
def slv(X, Y, Z, K, A, B, C):
q = []
for a in A:
for b in B:
if len(q) < K:
heapq.heappush(q, a + b)
else:
heapq.heappushpop(q, a + b)
qq = []
for c in C:
for d in q:
if len(qq) < K:
heapq.heappush(qq, d + c)
else:
heapq.heappushpop(qq, d + c)
qq.sort(reverse=True)
return qq
def main():
X, Y, Z, K = read_int_n()
A = read_int_n()
B = read_int_n()
C = read_int_n()
print(*slv(X, Y, Z, K, A, B, C), sep="\n")
if __name__ == "__main__":
main()
| false | 5.940594 | [
"- A.sort(reverse=True)",
"- B.sort(reverse=True)",
"- C.sort(reverse=True)",
"- if len(A) > K:",
"- A = A[:K]",
"- if len(B) > K:",
"- B = B[:K]",
"- if len(C) > K:",
"- C = C[:K]",
"- heapq.heappush(q, a + b)",
"- if len(q) > K:",
"- heapq.heappop(q)",
"+ if len(q) < K:",
"+ heapq.heappush(q, a + b)",
"+ else:",
"+ heapq.heappushpop(q, a + b)",
"- heapq.heappush(qq, d + c)",
"- if len(qq) > K:",
"- heapq.heappop(qq)",
"+ if len(qq) < K:",
"+ heapq.heappush(qq, d + c)",
"+ else:",
"+ heapq.heappushpop(qq, d + c)"
] | false | 0.036515 | 0.037573 | 0.971836 | [
"s862549377",
"s483574392"
] |
u777283665 | p02996 | python | s356547969 | s040339933 | 1,182 | 899 | 74,712 | 53,600 | Accepted | Accepted | 23.94 | n = int(eval(input()))
task_list = []
for i in range(n):
a, b = list(map(int, input().split()))
task_list.append((a, b))
task_list = sorted(task_list, key=lambda x: x[1])
current = 0
for task in task_list:
current += task[0]
if current > task[1]:
print("No")
exit()
print("Yes") | n = int(eval(input()))
tasks = [list(map(int, input().split())) for _ in range(n)]
tasks.sort(key=lambda x: x[1])
current_time = 0
for task in tasks:
current_time += task[0]
if current_time > task[1]:
print("No")
exit()
print("Yes") | 19 | 13 | 322 | 265 | n = int(eval(input()))
task_list = []
for i in range(n):
a, b = list(map(int, input().split()))
task_list.append((a, b))
task_list = sorted(task_list, key=lambda x: x[1])
current = 0
for task in task_list:
current += task[0]
if current > task[1]:
print("No")
exit()
print("Yes")
| n = int(eval(input()))
tasks = [list(map(int, input().split())) for _ in range(n)]
tasks.sort(key=lambda x: x[1])
current_time = 0
for task in tasks:
current_time += task[0]
if current_time > task[1]:
print("No")
exit()
print("Yes")
| false | 31.578947 | [
"-task_list = []",
"-for i in range(n):",
"- a, b = list(map(int, input().split()))",
"- task_list.append((a, b))",
"-task_list = sorted(task_list, key=lambda x: x[1])",
"-current = 0",
"-for task in task_list:",
"- current += task[0]",
"- if current > task[1]:",
"+tasks = [list(map(int, input().split())) for _ in range(n)]",
"+tasks.sort(key=lambda x: x[1])",
"+current_time = 0",
"+for task in tasks:",
"+ current_time += task[0]",
"+ if current_time > task[1]:"
] | false | 0.06577 | 0.067997 | 0.967255 | [
"s356547969",
"s040339933"
] |
u647999897 | p02726 | python | s161638224 | s811371249 | 1,677 | 1,218 | 3,956 | 62,812 | Accepted | Accepted | 27.37 | from collections import defaultdict, deque
def solve():
N, X, Y = list(map(int, input().split()))
X -= 1
Y -= 1
cnter = defaultdict(int)
for i in range(N):
for j in range(i,N):
n_step = min(abs(j-i), abs(X-i)+1+abs(Y-j), abs(Y-i)+1+abs(j-X))
cnter[n_step] += 1
for i in range(1,N):
print((cnter[i]))
if __name__ == '__main__':
solve() | from collections import deque
def solve():
N, X, Y = map(int, input().split())
X -= 1
Y -= 1
ans = [0] * N
for start_vertex in range(N):
q = deque()
distance_list = [float('inf')] * N
def push(vertex, distance):
if distance_list[vertex] != float('inf'):
return
q.append(vertex)
distance_list[vertex] = distance
push(start_vertex, 0)
while len(q) > 0:
vertex = q.popleft()
distance = distance_list[vertex]
if vertex - 1 >= 0:
push(vertex-1, distance+1)
if vertex + 1 < N:
push(vertex+1, distance+1)
if vertex == X:
push(Y, distance+1)
if vertex == Y:
push(X, distance+1)
for i in distance_list:
ans[i] += 1
ans = list(map(lambda x: x // 2, ans))
print(*ans[1:], sep='\n')
if __name__ == '__main__':
solve()
| 18 | 40 | 419 | 1,052 | from collections import defaultdict, deque
def solve():
N, X, Y = list(map(int, input().split()))
X -= 1
Y -= 1
cnter = defaultdict(int)
for i in range(N):
for j in range(i, N):
n_step = min(
abs(j - i), abs(X - i) + 1 + abs(Y - j), abs(Y - i) + 1 + abs(j - X)
)
cnter[n_step] += 1
for i in range(1, N):
print((cnter[i]))
if __name__ == "__main__":
solve()
| from collections import deque
def solve():
N, X, Y = map(int, input().split())
X -= 1
Y -= 1
ans = [0] * N
for start_vertex in range(N):
q = deque()
distance_list = [float("inf")] * N
def push(vertex, distance):
if distance_list[vertex] != float("inf"):
return
q.append(vertex)
distance_list[vertex] = distance
push(start_vertex, 0)
while len(q) > 0:
vertex = q.popleft()
distance = distance_list[vertex]
if vertex - 1 >= 0:
push(vertex - 1, distance + 1)
if vertex + 1 < N:
push(vertex + 1, distance + 1)
if vertex == X:
push(Y, distance + 1)
if vertex == Y:
push(X, distance + 1)
for i in distance_list:
ans[i] += 1
ans = list(map(lambda x: x // 2, ans))
print(*ans[1:], sep="\n")
if __name__ == "__main__":
solve()
| false | 55 | [
"-from collections import defaultdict, deque",
"+from collections import deque",
"- N, X, Y = list(map(int, input().split()))",
"+ N, X, Y = map(int, input().split())",
"- cnter = defaultdict(int)",
"- for i in range(N):",
"- for j in range(i, N):",
"- n_step = min(",
"- abs(j - i), abs(X - i) + 1 + abs(Y - j), abs(Y - i) + 1 + abs(j - X)",
"- )",
"- cnter[n_step] += 1",
"- for i in range(1, N):",
"- print((cnter[i]))",
"+ ans = [0] * N",
"+ for start_vertex in range(N):",
"+ q = deque()",
"+ distance_list = [float(\"inf\")] * N",
"+",
"+ def push(vertex, distance):",
"+ if distance_list[vertex] != float(\"inf\"):",
"+ return",
"+ q.append(vertex)",
"+ distance_list[vertex] = distance",
"+",
"+ push(start_vertex, 0)",
"+ while len(q) > 0:",
"+ vertex = q.popleft()",
"+ distance = distance_list[vertex]",
"+ if vertex - 1 >= 0:",
"+ push(vertex - 1, distance + 1)",
"+ if vertex + 1 < N:",
"+ push(vertex + 1, distance + 1)",
"+ if vertex == X:",
"+ push(Y, distance + 1)",
"+ if vertex == Y:",
"+ push(X, distance + 1)",
"+ for i in distance_list:",
"+ ans[i] += 1",
"+ ans = list(map(lambda x: x // 2, ans))",
"+ print(*ans[1:], sep=\"\\n\")"
] | false | 0.071826 | 0.034416 | 2.086984 | [
"s161638224",
"s811371249"
] |
u816872429 | p02775 | python | s895863835 | s130691846 | 148 | 117 | 76,892 | 75,636 | Accepted | Accepted | 20.95 | n = eval(input())
dp = [0, 10000]
for d in reversed('0' + n):
newdp = []
newdp.append(min(int(d) + dp[0], int(d) + 1 + dp[1]))
newdp.append(min(10 - int(d) + dp[0], 10 - int(d) - 1 + dp[1]))
dp = newdp
print((dp[0]))
| n = eval(input())
dp = [0, 10000]
for d in map(int, reversed(n)):
dp = [min(d + dp[0], d + 1 + dp[1]), min(10 - d + dp[0], 9 - d + dp[1])]
print((min(dp[0], 1 + dp[1])))
| 8 | 5 | 232 | 170 | n = eval(input())
dp = [0, 10000]
for d in reversed("0" + n):
newdp = []
newdp.append(min(int(d) + dp[0], int(d) + 1 + dp[1]))
newdp.append(min(10 - int(d) + dp[0], 10 - int(d) - 1 + dp[1]))
dp = newdp
print((dp[0]))
| n = eval(input())
dp = [0, 10000]
for d in map(int, reversed(n)):
dp = [min(d + dp[0], d + 1 + dp[1]), min(10 - d + dp[0], 9 - d + dp[1])]
print((min(dp[0], 1 + dp[1])))
| false | 37.5 | [
"-for d in reversed(\"0\" + n):",
"- newdp = []",
"- newdp.append(min(int(d) + dp[0], int(d) + 1 + dp[1]))",
"- newdp.append(min(10 - int(d) + dp[0], 10 - int(d) - 1 + dp[1]))",
"- dp = newdp",
"-print((dp[0]))",
"+for d in map(int, reversed(n)):",
"+ dp = [min(d + dp[0], d + 1 + dp[1]), min(10 - d + dp[0], 9 - d + dp[1])]",
"+print((min(dp[0], 1 + dp[1])))"
] | false | 0.03785 | 0.036576 | 1.034817 | [
"s895863835",
"s130691846"
] |
u440566786 | p04030 | python | s811549445 | s263567352 | 170 | 64 | 38,384 | 61,464 | Accepted | Accepted | 62.35 | S = eval(input())
ans = []
for s in S:
if s=='B' and ans:
ans.pop(-1)
elif s!='B':
ans.append(s)
print((''.join(ans))) | import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
stack = []
for c in eval(input()):
if c != 'B':
stack.append(c)
else:
if stack:
stack.pop()
print((''.join(stack)))
resolve() | 8 | 15 | 141 | 346 | S = eval(input())
ans = []
for s in S:
if s == "B" and ans:
ans.pop(-1)
elif s != "B":
ans.append(s)
print(("".join(ans)))
| import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda: sys.stdin.readline().rstrip()
def resolve():
stack = []
for c in eval(input()):
if c != "B":
stack.append(c)
else:
if stack:
stack.pop()
print(("".join(stack)))
resolve()
| false | 46.666667 | [
"-S = eval(input())",
"-ans = []",
"-for s in S:",
"- if s == \"B\" and ans:",
"- ans.pop(-1)",
"- elif s != \"B\":",
"- ans.append(s)",
"-print((\"\".join(ans)))",
"+import sys",
"+",
"+INF = 1 << 60",
"+MOD = 10**9 + 7 # 998244353",
"+sys.setrecursionlimit(2147483647)",
"+input = lambda: sys.stdin.readline().rstrip()",
"+",
"+",
"+def resolve():",
"+ stack = []",
"+ for c in eval(input()):",
"+ if c != \"B\":",
"+ stack.append(c)",
"+ else:",
"+ if stack:",
"+ stack.pop()",
"+ print((\"\".join(stack)))",
"+",
"+",
"+resolve()"
] | false | 0.083545 | 0.073713 | 1.133379 | [
"s811549445",
"s263567352"
] |
u644907318 | p03599 | python | s108709253 | s977494396 | 1,829 | 186 | 3,064 | 40,048 | Accepted | Accepted | 89.83 | A,B,C,D,E,F = list(map(int,input().split()))
cmax = 0
x = 100*A
y = 0
for n in range(F//(100*A)+1):
for m in range((F-n*100*A)//(100*B)+1):
for l in range((F-n*100*A-m*100*B)//C+1):
for k in range((F-n*100*A-m*100*B-l*C)//D+1):
# print("n,m,l,k={},{},{},{}".format(n,m,l,k))
if n**2+m**2>0 and l*C+k*D<=E*(n*A+m*B):
# print("d={}".format((l*C+k*D)/(n*100*A+m*100*B+l*C+k*D)))
if cmax<(l*C+k*D)/(n*100*A+m*100*B+l*C+k*D):
cmax = (l*C+k*D)/(n*100*A+m*100*B+l*C+k*D)
x = n*100*A+m*100*B
y = l*C+k*D
print((x+y,y)) | A,B,C,D,E,F = list(map(int,input().split()))
xmax = 100*A
kmax = 0
for n in range(31):
for m in range(31):
x = 100*(n*A+m*B)
ymax = min((n*A+m*B)*E,F-100*(n*A+m*B))
for k in range(ymax,ymax-C-1,-1):
t = 0
flag = 0
while k-t*D>=0:
if (k-t*D)%C==0:
flag = 1
break
t += 1
if flag==1:
if kmax*(x+k)<k*(xmax+kmax):
xmax = x
kmax = k
print((xmax+kmax,kmax)) | 17 | 20 | 707 | 566 | A, B, C, D, E, F = list(map(int, input().split()))
cmax = 0
x = 100 * A
y = 0
for n in range(F // (100 * A) + 1):
for m in range((F - n * 100 * A) // (100 * B) + 1):
for l in range((F - n * 100 * A - m * 100 * B) // C + 1):
for k in range((F - n * 100 * A - m * 100 * B - l * C) // D + 1):
# print("n,m,l,k={},{},{},{}".format(n,m,l,k))
if n**2 + m**2 > 0 and l * C + k * D <= E * (n * A + m * B):
# print("d={}".format((l*C+k*D)/(n*100*A+m*100*B+l*C+k*D)))
if cmax < (l * C + k * D) / (
n * 100 * A + m * 100 * B + l * C + k * D
):
cmax = (l * C + k * D) / (
n * 100 * A + m * 100 * B + l * C + k * D
)
x = n * 100 * A + m * 100 * B
y = l * C + k * D
print((x + y, y))
| A, B, C, D, E, F = list(map(int, input().split()))
xmax = 100 * A
kmax = 0
for n in range(31):
for m in range(31):
x = 100 * (n * A + m * B)
ymax = min((n * A + m * B) * E, F - 100 * (n * A + m * B))
for k in range(ymax, ymax - C - 1, -1):
t = 0
flag = 0
while k - t * D >= 0:
if (k - t * D) % C == 0:
flag = 1
break
t += 1
if flag == 1:
if kmax * (x + k) < k * (xmax + kmax):
xmax = x
kmax = k
print((xmax + kmax, kmax))
| false | 15 | [
"-cmax = 0",
"-x = 100 * A",
"-y = 0",
"-for n in range(F // (100 * A) + 1):",
"- for m in range((F - n * 100 * A) // (100 * B) + 1):",
"- for l in range((F - n * 100 * A - m * 100 * B) // C + 1):",
"- for k in range((F - n * 100 * A - m * 100 * B - l * C) // D + 1):",
"- # print(\"n,m,l,k={},{},{},{}\".format(n,m,l,k))",
"- if n**2 + m**2 > 0 and l * C + k * D <= E * (n * A + m * B):",
"- # print(\"d={}\".format((l*C+k*D)/(n*100*A+m*100*B+l*C+k*D)))",
"- if cmax < (l * C + k * D) / (",
"- n * 100 * A + m * 100 * B + l * C + k * D",
"- ):",
"- cmax = (l * C + k * D) / (",
"- n * 100 * A + m * 100 * B + l * C + k * D",
"- )",
"- x = n * 100 * A + m * 100 * B",
"- y = l * C + k * D",
"-print((x + y, y))",
"+xmax = 100 * A",
"+kmax = 0",
"+for n in range(31):",
"+ for m in range(31):",
"+ x = 100 * (n * A + m * B)",
"+ ymax = min((n * A + m * B) * E, F - 100 * (n * A + m * B))",
"+ for k in range(ymax, ymax - C - 1, -1):",
"+ t = 0",
"+ flag = 0",
"+ while k - t * D >= 0:",
"+ if (k - t * D) % C == 0:",
"+ flag = 1",
"+ break",
"+ t += 1",
"+ if flag == 1:",
"+ if kmax * (x + k) < k * (xmax + kmax):",
"+ xmax = x",
"+ kmax = k",
"+print((xmax + kmax, kmax))"
] | false | 0.545934 | 0.04571 | 11.943433 | [
"s108709253",
"s977494396"
] |
u172147273 | p03415 | python | s118975421 | s112168481 | 68 | 60 | 61,332 | 61,636 | Accepted | Accepted | 11.76 | for i in range(3):
a=input()
print(a[i],end="")
| print(input()[0],end="")
print(input()[1],end="")
print(input()[2],end="")
| 3 | 3 | 57 | 76 | for i in range(3):
a = input()
print(a[i], end="")
| print(input()[0], end="")
print(input()[1], end="")
print(input()[2], end="")
| false | 0 | [
"-for i in range(3):",
"- a = input()",
"- print(a[i], end=\"\")",
"+print(input()[0], end=\"\")",
"+print(input()[1], end=\"\")",
"+print(input()[2], end=\"\")"
] | false | 0.041431 | 0.040392 | 1.025706 | [
"s118975421",
"s112168481"
] |
u230686312 | p02953 | python | s876928429 | s410863866 | 80 | 52 | 14,396 | 14,396 | Accepted | Accepted | 35 | N = int(eval(input()))
Hs = [int(x) for x in input().split()]
# 右端から見て, 単調減少/同じにできればいい.
# 右端から見て, 右側より大きければ1つ減らす.
# その上で比較していく. もし単調減少/同じにできなければ'No'を返す.
prev = 'init'
is_yes = True
for i in range(N):
current = Hs[N-1-i]
if prev == 'init':
prev = current
continue
elif prev >= current:
prev = current
elif prev == current - 1:
prev = current - 1
else:
is_yes = False
if is_yes:
print('Yes')
else:
print('No')
| N = int(eval(input()))
Hs = [int(x) for x in input().split()]
# 右端から見て, 単調減少/同じにできればいい.
# 右端から見て, 右側より大きければ1つ減らす.
# その上で比較していく. もし単調減少/同じにできなければ'No'を返す.
def is_yes(Hs):
max = 0
for H in Hs:
# print("H: " + H)
if H > max:
max = H
# print("max: " + max)
if max - H >= 2:
return False
return True
if is_yes(Hs):
print('Yes')
else:
print('No')
| 25 | 23 | 497 | 436 | N = int(eval(input()))
Hs = [int(x) for x in input().split()]
# 右端から見て, 単調減少/同じにできればいい.
# 右端から見て, 右側より大きければ1つ減らす.
# その上で比較していく. もし単調減少/同じにできなければ'No'を返す.
prev = "init"
is_yes = True
for i in range(N):
current = Hs[N - 1 - i]
if prev == "init":
prev = current
continue
elif prev >= current:
prev = current
elif prev == current - 1:
prev = current - 1
else:
is_yes = False
if is_yes:
print("Yes")
else:
print("No")
| N = int(eval(input()))
Hs = [int(x) for x in input().split()]
# 右端から見て, 単調減少/同じにできればいい.
# 右端から見て, 右側より大きければ1つ減らす.
# その上で比較していく. もし単調減少/同じにできなければ'No'を返す.
def is_yes(Hs):
max = 0
for H in Hs:
# print("H: " + H)
if H > max:
max = H
# print("max: " + max)
if max - H >= 2:
return False
return True
if is_yes(Hs):
print("Yes")
else:
print("No")
| false | 8 | [
"-prev = \"init\"",
"-is_yes = True",
"-for i in range(N):",
"- current = Hs[N - 1 - i]",
"- if prev == \"init\":",
"- prev = current",
"- continue",
"- elif prev >= current:",
"- prev = current",
"- elif prev == current - 1:",
"- prev = current - 1",
"- else:",
"- is_yes = False",
"-if is_yes:",
"+def is_yes(Hs):",
"+ max = 0",
"+ for H in Hs:",
"+ # print(\"H: \" + H)",
"+ if H > max:",
"+ max = H",
"+ # print(\"max: \" + max)",
"+ if max - H >= 2:",
"+ return False",
"+ return True",
"+",
"+",
"+if is_yes(Hs):"
] | false | 0.044897 | 0.044736 | 1.003586 | [
"s876928429",
"s410863866"
] |
u089230684 | p03073 | python | s577051869 | s797689896 | 82 | 67 | 3,956 | 3,188 | Accepted | Accepted | 18.29 | x = list(str(eval(input())))
i = 0
counter =0
while i<len(x)-1 :
if(x[i]==x[i+1]):
if x[i+1]=="0":
x[i+1]="1"
else:
x[i+1]="0"
# x[i+1]=x[i-1]
counter+=1
i+=1
print(counter) | receber = eval(input())
contador = 0
contaor = 0
casoUm=""
casoDois=""
if receber[0] == "1":
for i in range(len(receber)):
if i%2==0:
casoUm+="1"
else:
casoUm+="0"
for k in range(len(receber)):
if receber[k] != casoUm[k]:
contador+=1
else:
for i in range(len(receber)):
if i%2==0:
casoDois+="0"
else:
casoDois+="1"
for k in range(len(receber)):
if receber[k] != casoDois[k]:
contador+=1
print(contador) | 13 | 25 | 242 | 557 | x = list(str(eval(input())))
i = 0
counter = 0
while i < len(x) - 1:
if x[i] == x[i + 1]:
if x[i + 1] == "0":
x[i + 1] = "1"
else:
x[i + 1] = "0"
# x[i+1]=x[i-1]
counter += 1
i += 1
print(counter)
| receber = eval(input())
contador = 0
contaor = 0
casoUm = ""
casoDois = ""
if receber[0] == "1":
for i in range(len(receber)):
if i % 2 == 0:
casoUm += "1"
else:
casoUm += "0"
for k in range(len(receber)):
if receber[k] != casoUm[k]:
contador += 1
else:
for i in range(len(receber)):
if i % 2 == 0:
casoDois += "0"
else:
casoDois += "1"
for k in range(len(receber)):
if receber[k] != casoDois[k]:
contador += 1
print(contador)
| false | 48 | [
"-x = list(str(eval(input())))",
"-i = 0",
"-counter = 0",
"-while i < len(x) - 1:",
"- if x[i] == x[i + 1]:",
"- if x[i + 1] == \"0\":",
"- x[i + 1] = \"1\"",
"+receber = eval(input())",
"+contador = 0",
"+contaor = 0",
"+casoUm = \"\"",
"+casoDois = \"\"",
"+if receber[0] == \"1\":",
"+ for i in range(len(receber)):",
"+ if i % 2 == 0:",
"+ casoUm += \"1\"",
"- x[i + 1] = \"0\"",
"- # x[i+1]=x[i-1]",
"- counter += 1",
"- i += 1",
"-print(counter)",
"+ casoUm += \"0\"",
"+ for k in range(len(receber)):",
"+ if receber[k] != casoUm[k]:",
"+ contador += 1",
"+else:",
"+ for i in range(len(receber)):",
"+ if i % 2 == 0:",
"+ casoDois += \"0\"",
"+ else:",
"+ casoDois += \"1\"",
"+ for k in range(len(receber)):",
"+ if receber[k] != casoDois[k]:",
"+ contador += 1",
"+print(contador)"
] | false | 0.045117 | 0.035139 | 1.283943 | [
"s577051869",
"s797689896"
] |
u506689504 | p03457 | python | s325545107 | s978221350 | 423 | 323 | 27,324 | 3,060 | Accepted | Accepted | 23.64 | n = int(eval(input()))
txy = [list(map(int, input().split())) for i in range(n)]
for i in range(n):
if i == 0:
ti, xi, yi = 0, 0, 0
else:
ti, xi, yi = txy[i-1]
tf,xf,yf = txy[i]
dt = tf - ti
dx = abs(xi-xf)
dy = abs(yi-yf)
if dt < dx + dy or (dt-(dx+dy))%2 != 0:
print("No")
exit()
print("Yes")
| n = int(eval(input()))
for i in range(n):
t, x, y = list(map(int, input().split()))
if x+y > t or (x+y+t) % 2!=0:
print("No")
exit()
print("Yes") | 17 | 7 | 367 | 163 | n = int(eval(input()))
txy = [list(map(int, input().split())) for i in range(n)]
for i in range(n):
if i == 0:
ti, xi, yi = 0, 0, 0
else:
ti, xi, yi = txy[i - 1]
tf, xf, yf = txy[i]
dt = tf - ti
dx = abs(xi - xf)
dy = abs(yi - yf)
if dt < dx + dy or (dt - (dx + dy)) % 2 != 0:
print("No")
exit()
print("Yes")
| n = int(eval(input()))
for i in range(n):
t, x, y = list(map(int, input().split()))
if x + y > t or (x + y + t) % 2 != 0:
print("No")
exit()
print("Yes")
| false | 58.823529 | [
"-txy = [list(map(int, input().split())) for i in range(n)]",
"- if i == 0:",
"- ti, xi, yi = 0, 0, 0",
"- else:",
"- ti, xi, yi = txy[i - 1]",
"- tf, xf, yf = txy[i]",
"- dt = tf - ti",
"- dx = abs(xi - xf)",
"- dy = abs(yi - yf)",
"- if dt < dx + dy or (dt - (dx + dy)) % 2 != 0:",
"+ t, x, y = list(map(int, input().split()))",
"+ if x + y > t or (x + y + t) % 2 != 0:"
] | false | 0.040463 | 0.034915 | 1.158918 | [
"s325545107",
"s978221350"
] |
u363892646 | p02859 | python | s613133522 | s409138000 | 22 | 18 | 2,940 | 2,940 | Accepted | Accepted | 18.18 | r = int(eval(input()))
print((r * r)) | print((int(eval(input()))**2)) | 2 | 1 | 30 | 22 | r = int(eval(input()))
print((r * r))
| print((int(eval(input())) ** 2))
| false | 50 | [
"-r = int(eval(input()))",
"-print((r * r))",
"+print((int(eval(input())) ** 2))"
] | false | 0.034611 | 0.040367 | 0.857407 | [
"s613133522",
"s409138000"
] |
u561231954 | p03290 | python | s462102616 | s407132929 | 36 | 24 | 3,064 | 3,316 | Accepted | Accepted | 33.33 | import sys
input=sys.stdin.readline
INF = 10**9
def main():
d,g=list(map(int,input().split()))
P=[list(map(int,input().split())) for _ in range(d)]
ans=INF
for bit in range(1<<d):
score=0
p=0
cnt=0
for i in range(d):
if (bit>>i)&1:
score += P[i][0]*100*(i+1)+P[i][1]
cnt += P[i][0]
else:
p = i
if score >= g:
ans=min(ans,cnt)
else:
for i in range(P[p][0]-1):
score += 100*(p+1)
cnt +=1
if score >= g:
ans=min(ans,cnt)
break
print(ans)
if __name__=='__main__':
main()
| INF = 10 ** 9
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from heapq import heappop,heapify,heappush
from bisect import bisect_left
def main():
d,g = list(map(int,input().split()))
problems = [list(map(int,input().split())) for _ in range(d)]
ans = INF
for bit in range(1 << d):
ret = 0
tot = 0
left = -1
for i in range(d):
if (bit>>i)&1:
tot += (i + 1) * 100 * problems[i][0] + problems[i][1]
ret += problems[i][0]
else:
left = i
if tot >= g:
ans = min(ans,ret)
continue
if tot + (left + 1) * 100 * (problems[left][0] - 1) >= g:
tmp = (left + 1) * 100
ret += (g - tot + tmp - 1)//tmp
ans = min(ans,ret)
print(ans)
if __name__ == '__main__':
main()
| 34 | 37 | 776 | 942 | import sys
input = sys.stdin.readline
INF = 10**9
def main():
d, g = list(map(int, input().split()))
P = [list(map(int, input().split())) for _ in range(d)]
ans = INF
for bit in range(1 << d):
score = 0
p = 0
cnt = 0
for i in range(d):
if (bit >> i) & 1:
score += P[i][0] * 100 * (i + 1) + P[i][1]
cnt += P[i][0]
else:
p = i
if score >= g:
ans = min(ans, cnt)
else:
for i in range(P[p][0] - 1):
score += 100 * (p + 1)
cnt += 1
if score >= g:
ans = min(ans, cnt)
break
print(ans)
if __name__ == "__main__":
main()
| INF = 10**9
import sys
sys.setrecursionlimit(100000000)
dy = (-1, 0, 1, 0)
dx = (0, 1, 0, -1)
from heapq import heappop, heapify, heappush
from bisect import bisect_left
def main():
d, g = list(map(int, input().split()))
problems = [list(map(int, input().split())) for _ in range(d)]
ans = INF
for bit in range(1 << d):
ret = 0
tot = 0
left = -1
for i in range(d):
if (bit >> i) & 1:
tot += (i + 1) * 100 * problems[i][0] + problems[i][1]
ret += problems[i][0]
else:
left = i
if tot >= g:
ans = min(ans, ret)
continue
if tot + (left + 1) * 100 * (problems[left][0] - 1) >= g:
tmp = (left + 1) * 100
ret += (g - tot + tmp - 1) // tmp
ans = min(ans, ret)
print(ans)
if __name__ == "__main__":
main()
| false | 8.108108 | [
"+INF = 10**9",
"-input = sys.stdin.readline",
"-INF = 10**9",
"+sys.setrecursionlimit(100000000)",
"+dy = (-1, 0, 1, 0)",
"+dx = (0, 1, 0, -1)",
"+from heapq import heappop, heapify, heappush",
"+from bisect import bisect_left",
"- P = [list(map(int, input().split())) for _ in range(d)]",
"+ problems = [list(map(int, input().split())) for _ in range(d)]",
"- score = 0",
"- p = 0",
"- cnt = 0",
"+ ret = 0",
"+ tot = 0",
"+ left = -1",
"- score += P[i][0] * 100 * (i + 1) + P[i][1]",
"- cnt += P[i][0]",
"+ tot += (i + 1) * 100 * problems[i][0] + problems[i][1]",
"+ ret += problems[i][0]",
"- p = i",
"- if score >= g:",
"- ans = min(ans, cnt)",
"- else:",
"- for i in range(P[p][0] - 1):",
"- score += 100 * (p + 1)",
"- cnt += 1",
"- if score >= g:",
"- ans = min(ans, cnt)",
"- break",
"+ left = i",
"+ if tot >= g:",
"+ ans = min(ans, ret)",
"+ continue",
"+ if tot + (left + 1) * 100 * (problems[left][0] - 1) >= g:",
"+ tmp = (left + 1) * 100",
"+ ret += (g - tot + tmp - 1) // tmp",
"+ ans = min(ans, ret)"
] | false | 0.062819 | 0.059025 | 1.06427 | [
"s462102616",
"s407132929"
] |
u762420987 | p03848 | python | s775222192 | s106331059 | 90 | 69 | 15,312 | 14,820 | Accepted | Accepted | 23.33 | from collections import Counter
N = int(eval(input()))
AC = Counter(list(map(int, input().split())))
if N % 2 == 1:
if N == 1:
ans = AC[0] == 1
else:
ans = AC[0] == 1
for k, v in AC.most_common(N//2):
if k > N-1 or k % 2 != 0 or v != 2:
ans = False
break
else:
ans = True
for k, v in AC.most_common():
if k > N or k % 2 == 0 or v != 2:
ans = False
break
if ans:
print((pow(2, N//2, 10**9+7)))
else:
print((0)) | from collections import Counter
N = int(eval(input()))
Alist = list(map(int, input().split()))
Ac = Counter(Alist)
mod = 10**9+7
if N%2==0:
for i in range(1, N, 2):
if Ac[i] != 2:
print((0))
break
else:
print((pow(2, (N//2), mod)))
else:
if Ac[0] != 1:
print((0))
else:
for i in range(2, N, 2):
if Ac[i] != 2:
print((0))
break
else:
print((pow(2, (N//2), mod)))
| 22 | 22 | 544 | 503 | from collections import Counter
N = int(eval(input()))
AC = Counter(list(map(int, input().split())))
if N % 2 == 1:
if N == 1:
ans = AC[0] == 1
else:
ans = AC[0] == 1
for k, v in AC.most_common(N // 2):
if k > N - 1 or k % 2 != 0 or v != 2:
ans = False
break
else:
ans = True
for k, v in AC.most_common():
if k > N or k % 2 == 0 or v != 2:
ans = False
break
if ans:
print((pow(2, N // 2, 10**9 + 7)))
else:
print((0))
| from collections import Counter
N = int(eval(input()))
Alist = list(map(int, input().split()))
Ac = Counter(Alist)
mod = 10**9 + 7
if N % 2 == 0:
for i in range(1, N, 2):
if Ac[i] != 2:
print((0))
break
else:
print((pow(2, (N // 2), mod)))
else:
if Ac[0] != 1:
print((0))
else:
for i in range(2, N, 2):
if Ac[i] != 2:
print((0))
break
else:
print((pow(2, (N // 2), mod)))
| false | 0 | [
"-AC = Counter(list(map(int, input().split())))",
"-if N % 2 == 1:",
"- if N == 1:",
"- ans = AC[0] == 1",
"+Alist = list(map(int, input().split()))",
"+Ac = Counter(Alist)",
"+mod = 10**9 + 7",
"+if N % 2 == 0:",
"+ for i in range(1, N, 2):",
"+ if Ac[i] != 2:",
"+ print((0))",
"+ break",
"- ans = AC[0] == 1",
"- for k, v in AC.most_common(N // 2):",
"- if k > N - 1 or k % 2 != 0 or v != 2:",
"- ans = False",
"+ print((pow(2, (N // 2), mod)))",
"+else:",
"+ if Ac[0] != 1:",
"+ print((0))",
"+ else:",
"+ for i in range(2, N, 2):",
"+ if Ac[i] != 2:",
"+ print((0))",
"-else:",
"- ans = True",
"- for k, v in AC.most_common():",
"- if k > N or k % 2 == 0 or v != 2:",
"- ans = False",
"- break",
"-if ans:",
"- print((pow(2, N // 2, 10**9 + 7)))",
"-else:",
"- print((0))",
"+ else:",
"+ print((pow(2, (N // 2), mod)))"
] | false | 0.039512 | 0.039895 | 0.9904 | [
"s775222192",
"s106331059"
] |
u761529120 | p03295 | python | s550948646 | s404056399 | 844 | 308 | 55,384 | 92,008 | Accepted | Accepted | 63.51 | def main():
N, M = list(map(int, input().split()))
A = []
for _ in range(M):
a, b = list(map(int, input().split()))
A.append((a,b))
sort_A = sorted(A)
left = 0
right = N
cnt = 1
for i in range(M):
left = max(sort_A[i][0],left)
right = min(sort_A[i][1], right)
if left >= right:
cnt += 1
right = sort_A[i][1]
print(cnt)
if __name__ == "__main__":
main() | def main():
N, M = list(map(int, input().split()))
X = []
for _ in range(M):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
X.append([a,b])
X.sort(key=lambda x: x[1])
cnt = 1
now = X[0][1]
for a, b in X:
if now <= a:
cnt += 1
now = b
print(cnt)
if __name__ == "__main__":
main() | 27 | 23 | 482 | 403 | def main():
N, M = list(map(int, input().split()))
A = []
for _ in range(M):
a, b = list(map(int, input().split()))
A.append((a, b))
sort_A = sorted(A)
left = 0
right = N
cnt = 1
for i in range(M):
left = max(sort_A[i][0], left)
right = min(sort_A[i][1], right)
if left >= right:
cnt += 1
right = sort_A[i][1]
print(cnt)
if __name__ == "__main__":
main()
| def main():
N, M = list(map(int, input().split()))
X = []
for _ in range(M):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
X.append([a, b])
X.sort(key=lambda x: x[1])
cnt = 1
now = X[0][1]
for a, b in X:
if now <= a:
cnt += 1
now = b
print(cnt)
if __name__ == "__main__":
main()
| false | 14.814815 | [
"- A = []",
"+ X = []",
"- A.append((a, b))",
"- sort_A = sorted(A)",
"- left = 0",
"- right = N",
"+ a -= 1",
"+ b -= 1",
"+ X.append([a, b])",
"+ X.sort(key=lambda x: x[1])",
"- for i in range(M):",
"- left = max(sort_A[i][0], left)",
"- right = min(sort_A[i][1], right)",
"- if left >= right:",
"+ now = X[0][1]",
"+ for a, b in X:",
"+ if now <= a:",
"- right = sort_A[i][1]",
"+ now = b"
] | false | 0.035949 | 0.035965 | 0.999557 | [
"s550948646",
"s404056399"
] |
u315485238 | p03241 | python | s866856518 | s113401021 | 1,898 | 21 | 3,060 | 3,060 | Accepted | Accepted | 98.89 | N, M = list(map(int, input().split()))
def solution():
if M-N < M//N:
for n in range(N, M+1):
if M%n==0:
return M//n
else:
for m in range(M//N, 0, -1):
if M%m==0:
return m
print((solution()))
| N, M = list(map(int, input().split()))
def solution():
answer = 1
for i in range(1, int(M**0.5)+1):
if M%i ==0:
if M//i>=N:
answer = max(answer , i)
if i>=N:
answer = max(answer, M//i)
return answer
print((solution())) | 14 | 13 | 297 | 306 | N, M = list(map(int, input().split()))
def solution():
if M - N < M // N:
for n in range(N, M + 1):
if M % n == 0:
return M // n
else:
for m in range(M // N, 0, -1):
if M % m == 0:
return m
print((solution()))
| N, M = list(map(int, input().split()))
def solution():
answer = 1
for i in range(1, int(M**0.5) + 1):
if M % i == 0:
if M // i >= N:
answer = max(answer, i)
if i >= N:
answer = max(answer, M // i)
return answer
print((solution()))
| false | 7.142857 | [
"- if M - N < M // N:",
"- for n in range(N, M + 1):",
"- if M % n == 0:",
"- return M // n",
"- else:",
"- for m in range(M // N, 0, -1):",
"- if M % m == 0:",
"- return m",
"+ answer = 1",
"+ for i in range(1, int(M**0.5) + 1):",
"+ if M % i == 0:",
"+ if M // i >= N:",
"+ answer = max(answer, i)",
"+ if i >= N:",
"+ answer = max(answer, M // i)",
"+ return answer"
] | false | 0.108477 | 0.073416 | 1.477569 | [
"s866856518",
"s113401021"
] |
u760802228 | p02659 | python | s702975392 | s920452902 | 24 | 22 | 9,128 | 9,148 | Accepted | Accepted | 8.33 | A, B = input().split()
ans = (int(A) * (int(B[0])*100 + int(B[2])*10 + int(B[3]))) // 100
print((int(ans))) | A, B = input().split()
ans = int(A) * round(float(B) * 100) // 100
print((int(ans))) | 3 | 3 | 107 | 84 | A, B = input().split()
ans = (int(A) * (int(B[0]) * 100 + int(B[2]) * 10 + int(B[3]))) // 100
print((int(ans)))
| A, B = input().split()
ans = int(A) * round(float(B) * 100) // 100
print((int(ans)))
| false | 0 | [
"-ans = (int(A) * (int(B[0]) * 100 + int(B[2]) * 10 + int(B[3]))) // 100",
"+ans = int(A) * round(float(B) * 100) // 100"
] | false | 0.036453 | 0.068575 | 0.53158 | [
"s702975392",
"s920452902"
] |
u657329920 | p02628 | python | s566823509 | s444990744 | 370 | 66 | 80,016 | 62,068 | Accepted | Accepted | 82.16 | N, K = list(map(int, input().split()))
p = list(map(int, input().split()))
print((sum(sorted(p)[:K]))) | N, K = list(map(int, input().split()))
p = [int(num) for num in input().split()]
print((sum(sorted(p)[:K]))) | 3 | 3 | 96 | 102 | N, K = list(map(int, input().split()))
p = list(map(int, input().split()))
print((sum(sorted(p)[:K])))
| N, K = list(map(int, input().split()))
p = [int(num) for num in input().split()]
print((sum(sorted(p)[:K])))
| false | 0 | [
"-p = list(map(int, input().split()))",
"+p = [int(num) for num in input().split()]"
] | false | 0.045158 | 0.08783 | 0.514153 | [
"s566823509",
"s444990744"
] |
u811434779 | p02363 | python | s398159926 | s393564642 | 680 | 490 | 6,856 | 6,880 | Accepted | Accepted | 27.94 | INF = 1<<31
V, E = list(map(int, input().split()))
l = [[INF]*V for i in range(V)]
for i in range(E):
s, t, d = list(map(int, input().split()))
l[s][t] = d
for k in range(V):
for i in range(V):
for j in range(V):
if l[i][k] != INF and l[k][j] != INF:
l[i][j] = min(l[i][j], l[i][k] + l[k][j])
for i in range(V):
if l[i][i] < 0:
print("NEGATIVE CYCLE")
break
l[i][i] = 0
else:
for r in l:
for i in range(V):
if r[i] == INF: r[i] = "INF"
print(" ".join(map(str, r))) | INF = float("inf")
V, E = list(map(int, input().split()))
l = [[INF]*V for i in range(V)]
for i in range(E):
s, t, d = list(map(int, input().split()))
l[s][t] = d
for k in range(V):
for i in range(V):
for j in range(V):
l[i][j] = min(l[i][j], l[i][k] + l[k][j])
for i in range(V):
if l[i][i] < 0:
print("NEGATIVE CYCLE")
break
l[i][i] = 0
else:
for r in l:
for i in range(V):
if r[i] == INF: r[i] = "INF"
print(" ".join(map(str, r))) | 21 | 20 | 583 | 535 | INF = 1 << 31
V, E = list(map(int, input().split()))
l = [[INF] * V for i in range(V)]
for i in range(E):
s, t, d = list(map(int, input().split()))
l[s][t] = d
for k in range(V):
for i in range(V):
for j in range(V):
if l[i][k] != INF and l[k][j] != INF:
l[i][j] = min(l[i][j], l[i][k] + l[k][j])
for i in range(V):
if l[i][i] < 0:
print("NEGATIVE CYCLE")
break
l[i][i] = 0
else:
for r in l:
for i in range(V):
if r[i] == INF:
r[i] = "INF"
print(" ".join(map(str, r)))
| INF = float("inf")
V, E = list(map(int, input().split()))
l = [[INF] * V for i in range(V)]
for i in range(E):
s, t, d = list(map(int, input().split()))
l[s][t] = d
for k in range(V):
for i in range(V):
for j in range(V):
l[i][j] = min(l[i][j], l[i][k] + l[k][j])
for i in range(V):
if l[i][i] < 0:
print("NEGATIVE CYCLE")
break
l[i][i] = 0
else:
for r in l:
for i in range(V):
if r[i] == INF:
r[i] = "INF"
print(" ".join(map(str, r)))
| false | 4.761905 | [
"-INF = 1 << 31",
"+INF = float(\"inf\")",
"- if l[i][k] != INF and l[k][j] != INF:",
"- l[i][j] = min(l[i][j], l[i][k] + l[k][j])",
"+ l[i][j] = min(l[i][j], l[i][k] + l[k][j])"
] | false | 0.039304 | 0.035656 | 1.102322 | [
"s398159926",
"s393564642"
] |
u367701763 | p02861 | python | s238661265 | s056554468 | 300 | 103 | 3,316 | 74,436 | Accepted | Accepted | 65.67 | from itertools import permutations
from itertools import combinations
from math import sqrt
from math import factorial
from collections import defaultdict
N = int(eval(input()))
points = [list(map(int, input().split())) for _ in range(N) ]
length = defaultdict(float)
l_sum = 0
res = 0
for a, b in combinations(list(range(N)),2):
length[(a, b)] = (sqrt( (points[a][0] - points[b][0])**2 + (points[a][1] - points[b][1])**2 ))
for a in permutations(list(range(N))):
for i in range(N-1):
l_sum += length[(min(a[i], a[i+1]), max(a[i], a[i+1]))]
res = l_sum/factorial(N)
print(res) | from itertools import permutations
from math import factorial
N = int(eval(input()))
data = []
for _ in range(N):
x, y = list(map(int, input().split()))
data.append((x,y))
res = 0
for a in permutations(data,N):
x0, y0 = a[0]
for x, y in a[1:]:
res += ((x-x0)**2 + (y-y0)**2)**(0.5)
x0, y0 = x, y
print((res/factorial(N))) | 24 | 15 | 604 | 354 | from itertools import permutations
from itertools import combinations
from math import sqrt
from math import factorial
from collections import defaultdict
N = int(eval(input()))
points = [list(map(int, input().split())) for _ in range(N)]
length = defaultdict(float)
l_sum = 0
res = 0
for a, b in combinations(list(range(N)), 2):
length[(a, b)] = sqrt(
(points[a][0] - points[b][0]) ** 2 + (points[a][1] - points[b][1]) ** 2
)
for a in permutations(list(range(N))):
for i in range(N - 1):
l_sum += length[(min(a[i], a[i + 1]), max(a[i], a[i + 1]))]
res = l_sum / factorial(N)
print(res)
| from itertools import permutations
from math import factorial
N = int(eval(input()))
data = []
for _ in range(N):
x, y = list(map(int, input().split()))
data.append((x, y))
res = 0
for a in permutations(data, N):
x0, y0 = a[0]
for x, y in a[1:]:
res += ((x - x0) ** 2 + (y - y0) ** 2) ** (0.5)
x0, y0 = x, y
print((res / factorial(N)))
| false | 37.5 | [
"-from itertools import combinations",
"-from math import sqrt",
"-from collections import defaultdict",
"-points = [list(map(int, input().split())) for _ in range(N)]",
"-length = defaultdict(float)",
"-l_sum = 0",
"+data = []",
"+for _ in range(N):",
"+ x, y = list(map(int, input().split()))",
"+ data.append((x, y))",
"-for a, b in combinations(list(range(N)), 2):",
"- length[(a, b)] = sqrt(",
"- (points[a][0] - points[b][0]) ** 2 + (points[a][1] - points[b][1]) ** 2",
"- )",
"-for a in permutations(list(range(N))):",
"- for i in range(N - 1):",
"- l_sum += length[(min(a[i], a[i + 1]), max(a[i], a[i + 1]))]",
"-res = l_sum / factorial(N)",
"-print(res)",
"+for a in permutations(data, N):",
"+ x0, y0 = a[0]",
"+ for x, y in a[1:]:",
"+ res += ((x - x0) ** 2 + (y - y0) ** 2) ** (0.5)",
"+ x0, y0 = x, y",
"+print((res / factorial(N)))"
] | false | 0.040822 | 0.036407 | 1.121256 | [
"s238661265",
"s056554468"
] |
u756829954 | p03163 | python | s748382919 | s065515684 | 386 | 349 | 118,256 | 117,232 | Accepted | Accepted | 9.59 | def p_d():
N, W = list(map(int, input().split()))
dp = [[0] * (W + 1) for _ in range(N + 1)]
for i in range(1, N + 1):
w, v = list(map(int, input().split()))
for j in range(1, W + 1):
if j - w >= 0:
dp[i][j] = max(v + dp[i - 1][j - w], dp[i - 1][j])
else:
dp[i][j] = max(dp[i - 1][j], dp[i][j])
print((max(dp[N])))
if __name__ == '__main__':
p_d()
| def p_e():
"""
ナップサック問題(制約厳しい版)
"""
N, W = list(map(int, input().split()))
dp = [0] * (W + 1)
for i in range(1, N + 1):
w, v = list(map(int, input().split()))
NEXT = [0] * (W + 1)
for j in range(1, W + 1):
if j - w >= 0:
NEXT[j] = max(v + dp[j - w], dp[j])
else:
NEXT[j] = dp[j]
dp = NEXT
print((max(NEXT)))
if __name__ == '__main__':
p_e()
| 17 | 21 | 446 | 471 | def p_d():
N, W = list(map(int, input().split()))
dp = [[0] * (W + 1) for _ in range(N + 1)]
for i in range(1, N + 1):
w, v = list(map(int, input().split()))
for j in range(1, W + 1):
if j - w >= 0:
dp[i][j] = max(v + dp[i - 1][j - w], dp[i - 1][j])
else:
dp[i][j] = max(dp[i - 1][j], dp[i][j])
print((max(dp[N])))
if __name__ == "__main__":
p_d()
| def p_e():
"""
ナップサック問題(制約厳しい版)
"""
N, W = list(map(int, input().split()))
dp = [0] * (W + 1)
for i in range(1, N + 1):
w, v = list(map(int, input().split()))
NEXT = [0] * (W + 1)
for j in range(1, W + 1):
if j - w >= 0:
NEXT[j] = max(v + dp[j - w], dp[j])
else:
NEXT[j] = dp[j]
dp = NEXT
print((max(NEXT)))
if __name__ == "__main__":
p_e()
| false | 19.047619 | [
"-def p_d():",
"+def p_e():",
"+ \"\"\"",
"+ ナップサック問題(制約厳しい版)",
"+ \"\"\"",
"- dp = [[0] * (W + 1) for _ in range(N + 1)]",
"+ dp = [0] * (W + 1)",
"+ NEXT = [0] * (W + 1)",
"- dp[i][j] = max(v + dp[i - 1][j - w], dp[i - 1][j])",
"+ NEXT[j] = max(v + dp[j - w], dp[j])",
"- dp[i][j] = max(dp[i - 1][j], dp[i][j])",
"- print((max(dp[N])))",
"+ NEXT[j] = dp[j]",
"+ dp = NEXT",
"+ print((max(NEXT)))",
"- p_d()",
"+ p_e()"
] | false | 0.135443 | 0.046584 | 2.907477 | [
"s748382919",
"s065515684"
] |
u230621983 | p04034 | python | s961389816 | s116393949 | 387 | 246 | 12,652 | 10,652 | Accepted | Accepted | 36.43 | n, m = list(map(int, input().split()))
ball = [1] * n # 各箱のボールの個数。初めは各箱に1つずつ。
red = set([0]) # 赤いボールがある可能性のある箱のインデックス。初めは0番目の箱に赤いボールがある。
for _ in range(m):
x, y = list(map(int, input().split()))
ball[x-1] -= 1 # x-1番目の箱のボールを1つ減らす
ball[y-1] += 1 # y-1番目の箱のボールを1つ増やす
if x-1 in red: # x-1番目の箱に赤いボールがあるなら、y-1番目の箱に移動したとする。
red.add(y-1)
if ball[x-1] == 0: # x-1番目の箱にボールがなくなったら、赤いボールもないはずなので
red.discard(x-1) # 可能性のある箱から削除しとく
print((len(red))) # 可能性のある箱の個数を出力 | n, m = list(map(int, input().split()))
red = [0 for _ in range(n)]
red[0] = 1
balls = [1 for _ in range(n)]
for _ in range(m):
x, y = list(map(int, input().split()))
if balls[x-1]:
balls[x-1] -= 1
balls[y-1] += 1
if red[x-1]:
red[y-1] = 1
if balls[x-1] == 0:
red[x-1] = 0
cnt = 0
for i in range(n):
if red[i] and balls[i]:
cnt += 1
print(cnt) | 12 | 18 | 474 | 431 | n, m = list(map(int, input().split()))
ball = [1] * n # 各箱のボールの個数。初めは各箱に1つずつ。
red = set([0]) # 赤いボールがある可能性のある箱のインデックス。初めは0番目の箱に赤いボールがある。
for _ in range(m):
x, y = list(map(int, input().split()))
ball[x - 1] -= 1 # x-1番目の箱のボールを1つ減らす
ball[y - 1] += 1 # y-1番目の箱のボールを1つ増やす
if x - 1 in red: # x-1番目の箱に赤いボールがあるなら、y-1番目の箱に移動したとする。
red.add(y - 1)
if ball[x - 1] == 0: # x-1番目の箱にボールがなくなったら、赤いボールもないはずなので
red.discard(x - 1) # 可能性のある箱から削除しとく
print((len(red))) # 可能性のある箱の個数を出力
| n, m = list(map(int, input().split()))
red = [0 for _ in range(n)]
red[0] = 1
balls = [1 for _ in range(n)]
for _ in range(m):
x, y = list(map(int, input().split()))
if balls[x - 1]:
balls[x - 1] -= 1
balls[y - 1] += 1
if red[x - 1]:
red[y - 1] = 1
if balls[x - 1] == 0:
red[x - 1] = 0
cnt = 0
for i in range(n):
if red[i] and balls[i]:
cnt += 1
print(cnt)
| false | 33.333333 | [
"-ball = [1] * n # 各箱のボールの個数。初めは各箱に1つずつ。",
"-red = set([0]) # 赤いボールがある可能性のある箱のインデックス。初めは0番目の箱に赤いボールがある。",
"+red = [0 for _ in range(n)]",
"+red[0] = 1",
"+balls = [1 for _ in range(n)]",
"- ball[x - 1] -= 1 # x-1番目の箱のボールを1つ減らす",
"- ball[y - 1] += 1 # y-1番目の箱のボールを1つ増やす",
"- if x - 1 in red: # x-1番目の箱に赤いボールがあるなら、y-1番目の箱に移動したとする。",
"- red.add(y - 1)",
"- if ball[x - 1] == 0: # x-1番目の箱にボールがなくなったら、赤いボールもないはずなので",
"- red.discard(x - 1) # 可能性のある箱から削除しとく",
"-print((len(red))) # 可能性のある箱の個数を出力",
"+ if balls[x - 1]:",
"+ balls[x - 1] -= 1",
"+ balls[y - 1] += 1",
"+ if red[x - 1]:",
"+ red[y - 1] = 1",
"+ if balls[x - 1] == 0:",
"+ red[x - 1] = 0",
"+cnt = 0",
"+for i in range(n):",
"+ if red[i] and balls[i]:",
"+ cnt += 1",
"+print(cnt)"
] | false | 0.074961 | 0.066063 | 1.134691 | [
"s961389816",
"s116393949"
] |
u729133443 | p03694 | python | s504617956 | s201816887 | 177 | 17 | 38,384 | 2,940 | Accepted | Accepted | 90.4 | _,*a=list(map(int,open(0).read().split()));print((max(a)-min(a))) | _,t=open(0);*a,=list(map(int,t.split()));print((max(a)-min(a))) | 1 | 1 | 57 | 55 | _, *a = list(map(int, open(0).read().split()))
print((max(a) - min(a)))
| _, t = open(0)
(*a,) = list(map(int, t.split()))
print((max(a) - min(a)))
| false | 0 | [
"-_, *a = list(map(int, open(0).read().split()))",
"+_, t = open(0)",
"+(*a,) = list(map(int, t.split()))"
] | false | 0.041766 | 0.035541 | 1.175146 | [
"s504617956",
"s201816887"
] |
u737758066 | p02706 | python | s804537201 | s139342250 | 63 | 24 | 66,936 | 10,012 | Accepted | Accepted | 61.9 | n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
sm = sum(a)
if sm > n:
print((-1))
else:
print((n-sm))
| n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
if sum(a) > n:
print((-1))
else:
print((n-sum(a)))
| 8 | 7 | 136 | 131 | n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
sm = sum(a)
if sm > n:
print((-1))
else:
print((n - sm))
| n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
if sum(a) > n:
print((-1))
else:
print((n - sum(a)))
| false | 12.5 | [
"-sm = sum(a)",
"-if sm > n:",
"+if sum(a) > n:",
"- print((n - sm))",
"+ print((n - sum(a)))"
] | false | 0.041319 | 0.037236 | 1.109649 | [
"s804537201",
"s139342250"
] |
u382880969 | p03078 | python | s454185942 | s763016407 | 976 | 245 | 152,792 | 47,856 | Accepted | Accepted | 74.9 | import sys
if __name__ == "__main__":
(X, Y, Z, K) = list(map(int, sys.stdin.readline().split()))
A = list(map(int, sys.stdin.readline().split()))
B = list(map(int, sys.stdin.readline().split()))
C = list(map(int, sys.stdin.readline().split()))
v = []
for a in A:
for b in B:
v.append(a + b)
v.sort(reverse=True)
ans = []
for i in range(min(len(v),3000)):
for c in C:
ans.append(v[i] + c)
ans.sort(reverse=True)
for i in range(K):
sys.stdout.write("%d\n" % ans[i]) | import sys
if __name__ == "__main__":
(X, Y, Z, K) = list(map(int, sys.stdin.readline().split()))
A = list(map(int, sys.stdin.readline().split()))
B = list(map(int, sys.stdin.readline().split()))
C = list(map(int, sys.stdin.readline().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
v = []
for a in range(len(A)):
for b in range(len(B)):
if (a + 1) * (b + 1) > K:
break
for c in range(len(C)):
if (a + 1) * (b + 1) * (c + 1) > K:
break
v.append(A[a] + B[b] + C[c])
v.sort(reverse=True)
for i in range(K):
sys.stdout.write("%d\n" % v[i]) | 24 | 25 | 585 | 741 | import sys
if __name__ == "__main__":
(X, Y, Z, K) = list(map(int, sys.stdin.readline().split()))
A = list(map(int, sys.stdin.readline().split()))
B = list(map(int, sys.stdin.readline().split()))
C = list(map(int, sys.stdin.readline().split()))
v = []
for a in A:
for b in B:
v.append(a + b)
v.sort(reverse=True)
ans = []
for i in range(min(len(v), 3000)):
for c in C:
ans.append(v[i] + c)
ans.sort(reverse=True)
for i in range(K):
sys.stdout.write("%d\n" % ans[i])
| import sys
if __name__ == "__main__":
(X, Y, Z, K) = list(map(int, sys.stdin.readline().split()))
A = list(map(int, sys.stdin.readline().split()))
B = list(map(int, sys.stdin.readline().split()))
C = list(map(int, sys.stdin.readline().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
v = []
for a in range(len(A)):
for b in range(len(B)):
if (a + 1) * (b + 1) > K:
break
for c in range(len(C)):
if (a + 1) * (b + 1) * (c + 1) > K:
break
v.append(A[a] + B[b] + C[c])
v.sort(reverse=True)
for i in range(K):
sys.stdout.write("%d\n" % v[i])
| false | 4 | [
"+ A.sort(reverse=True)",
"+ B.sort(reverse=True)",
"+ C.sort(reverse=True)",
"- for a in A:",
"- for b in B:",
"- v.append(a + b)",
"+ for a in range(len(A)):",
"+ for b in range(len(B)):",
"+ if (a + 1) * (b + 1) > K:",
"+ break",
"+ for c in range(len(C)):",
"+ if (a + 1) * (b + 1) * (c + 1) > K:",
"+ break",
"+ v.append(A[a] + B[b] + C[c])",
"- ans = []",
"- for i in range(min(len(v), 3000)):",
"- for c in C:",
"- ans.append(v[i] + c)",
"- ans.sort(reverse=True)",
"- sys.stdout.write(\"%d\\n\" % ans[i])",
"+ sys.stdout.write(\"%d\\n\" % v[i])"
] | false | 0.042391 | 0.059918 | 0.707488 | [
"s454185942",
"s763016407"
] |
u058781705 | p02744 | python | s109731731 | s797022821 | 449 | 298 | 62,040 | 80,604 | Accepted | Accepted | 33.63 | import math
def div_with_mod(x, y, mod):
# Fermat's little theorem
return x*pow(y, mod - 2, mod)
def comb(n, r, mod):
# calculates C(n,r) with mod (assuming mod is prime)
nc = n
for rc in range(1, r):
nc -= 1
n = n*nc % mod
r = r*rc % mod
return div_with_mod(n, r, mod)
def solve():
N = int(input())
# ord("a") Unicode コードポイントを返す
codepoint = ord("a")
def dfs(word, dep):
if len(word) == N:
return print(word)
for i in range(dep):
dfs(word + chr(codepoint+i), dep)
dfs(word + chr(codepoint+dep), dep+1)
dfs("a", 1)
# Solve
if __name__ == "__main__":
solve()
| def solve():
N = int(input())
# ord("a") Unicode コードポイントを返す
codepoint = ord("a")
# たどるグラフの深さ
i = 1
# 標準形文字列とその次の辞書順
ans = [["a", 1]]
# 一つづつ潜る
while i < N:
# 次の深さをtmpとする
tmp = []
# 各ノード
for w, j in ans:
# 辞書順で追加していく
for k in range(j+1):
if k != j:
tmp.append([w + chr(codepoint+k), j])
# 辞書順のインクリメント
else:
tmp.append([w + chr(codepoint+k), j+1])
ans = tmp
i += 1
[print(a[0]) for a in ans]
# Solve
if __name__ == "__main__":
solve()
| 39 | 30 | 728 | 674 | import math
def div_with_mod(x, y, mod):
# Fermat's little theorem
return x * pow(y, mod - 2, mod)
def comb(n, r, mod):
# calculates C(n,r) with mod (assuming mod is prime)
nc = n
for rc in range(1, r):
nc -= 1
n = n * nc % mod
r = r * rc % mod
return div_with_mod(n, r, mod)
def solve():
N = int(input())
# ord("a") Unicode コードポイントを返す
codepoint = ord("a")
def dfs(word, dep):
if len(word) == N:
return print(word)
for i in range(dep):
dfs(word + chr(codepoint + i), dep)
dfs(word + chr(codepoint + dep), dep + 1)
dfs("a", 1)
# Solve
if __name__ == "__main__":
solve()
| def solve():
N = int(input())
# ord("a") Unicode コードポイントを返す
codepoint = ord("a")
# たどるグラフの深さ
i = 1
# 標準形文字列とその次の辞書順
ans = [["a", 1]]
# 一つづつ潜る
while i < N:
# 次の深さをtmpとする
tmp = []
# 各ノード
for w, j in ans:
# 辞書順で追加していく
for k in range(j + 1):
if k != j:
tmp.append([w + chr(codepoint + k), j])
# 辞書順のインクリメント
else:
tmp.append([w + chr(codepoint + k), j + 1])
ans = tmp
i += 1
[print(a[0]) for a in ans]
# Solve
if __name__ == "__main__":
solve()
| false | 23.076923 | [
"-import math",
"-",
"-",
"-def div_with_mod(x, y, mod):",
"- # Fermat's little theorem",
"- return x * pow(y, mod - 2, mod)",
"-",
"-",
"-def comb(n, r, mod):",
"- # calculates C(n,r) with mod (assuming mod is prime)",
"- nc = n",
"- for rc in range(1, r):",
"- nc -= 1",
"- n = n * nc % mod",
"- r = r * rc % mod",
"- return div_with_mod(n, r, mod)",
"-",
"-",
"-",
"- def dfs(word, dep):",
"- if len(word) == N:",
"- return print(word)",
"- for i in range(dep):",
"- dfs(word + chr(codepoint + i), dep)",
"- dfs(word + chr(codepoint + dep), dep + 1)",
"-",
"- dfs(\"a\", 1)",
"+ # たどるグラフの深さ",
"+ i = 1",
"+ # 標準形文字列とその次の辞書順",
"+ ans = [[\"a\", 1]]",
"+ # 一つづつ潜る",
"+ while i < N:",
"+ # 次の深さをtmpとする",
"+ tmp = []",
"+ # 各ノード",
"+ for w, j in ans:",
"+ # 辞書順で追加していく",
"+ for k in range(j + 1):",
"+ if k != j:",
"+ tmp.append([w + chr(codepoint + k), j])",
"+ # 辞書順のインクリメント",
"+ else:",
"+ tmp.append([w + chr(codepoint + k), j + 1])",
"+ ans = tmp",
"+ i += 1",
"+ [print(a[0]) for a in ans]",
"+ # Solve",
"-# Solve"
] | false | 0.039108 | 0.037851 | 1.033225 | [
"s109731731",
"s797022821"
] |
u775681539 | p02948 | python | s165389987 | s232503539 | 236 | 186 | 22,288 | 27,064 | Accepted | Accepted | 21.19 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from heapq import heappop, heappush
def main():
N, M = list(map(int, readline().split()))
tasks = [[] for _ in range(M)]
for _ in range(N):
a, b = list(map(int, readline().split()))
if M-a<0:
continue
tasks[M-a].append(b)
s = 0
h = []
for i in [i for i in range(M)][::-1]:
for b in tasks[i]:
heappush(h, -b)
if len(h)>0:
s-=heappop(h)
print(s)
if __name__ == '__main__':
main()
| import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from heapq import heappop, heappush
def main():
N, M = list(map(int, readline().split()))
m = list(map(int, read().split()))
tasks = [[] for _ in range(M)]
for a, b in zip(m, m):
if M-a>=0:
tasks[M-a].append(b)
s = 0
h = []
for i in [i for i in range(M)][::-1]:
for b in tasks[i]:
heappush(h, -b)
if len(h)>0:
s-=heappop(h)
print(s)
if __name__ == '__main__':
main()
| 23 | 22 | 613 | 589 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from heapq import heappop, heappush
def main():
N, M = list(map(int, readline().split()))
tasks = [[] for _ in range(M)]
for _ in range(N):
a, b = list(map(int, readline().split()))
if M - a < 0:
continue
tasks[M - a].append(b)
s = 0
h = []
for i in [i for i in range(M)][::-1]:
for b in tasks[i]:
heappush(h, -b)
if len(h) > 0:
s -= heappop(h)
print(s)
if __name__ == "__main__":
main()
| import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from heapq import heappop, heappush
def main():
N, M = list(map(int, readline().split()))
m = list(map(int, read().split()))
tasks = [[] for _ in range(M)]
for a, b in zip(m, m):
if M - a >= 0:
tasks[M - a].append(b)
s = 0
h = []
for i in [i for i in range(M)][::-1]:
for b in tasks[i]:
heappush(h, -b)
if len(h) > 0:
s -= heappop(h)
print(s)
if __name__ == "__main__":
main()
| false | 4.347826 | [
"+ m = list(map(int, read().split()))",
"- for _ in range(N):",
"- a, b = list(map(int, readline().split()))",
"- if M - a < 0:",
"- continue",
"- tasks[M - a].append(b)",
"+ for a, b in zip(m, m):",
"+ if M - a >= 0:",
"+ tasks[M - a].append(b)"
] | false | 0.040058 | 0.040883 | 0.979806 | [
"s165389987",
"s232503539"
] |
u987164499 | p02597 | python | s248636480 | s192587490 | 58 | 48 | 9,468 | 9,396 | Accepted | Accepted | 17.24 | from sys import stdin
from sys import setrecursionlimit
import bisect
setrecursionlimit(10 ** 7)
n = int(eval(input()))
c = eval(input())
count = c.count("R")
point = 0
for i,j in enumerate(c,1):
if j == "R":
if i > count:
point += 1
print(point) | n = int(eval(input()))
s = eval(input())
num_r = s.count("R")
count = 0
for i in range(num_r):
if s[i] != "R":
count += 1
print(count) | 17 | 11 | 278 | 151 | from sys import stdin
from sys import setrecursionlimit
import bisect
setrecursionlimit(10**7)
n = int(eval(input()))
c = eval(input())
count = c.count("R")
point = 0
for i, j in enumerate(c, 1):
if j == "R":
if i > count:
point += 1
print(point)
| n = int(eval(input()))
s = eval(input())
num_r = s.count("R")
count = 0
for i in range(num_r):
if s[i] != "R":
count += 1
print(count)
| false | 35.294118 | [
"-from sys import stdin",
"-from sys import setrecursionlimit",
"-import bisect",
"-",
"-setrecursionlimit(10**7)",
"-c = eval(input())",
"-count = c.count(\"R\")",
"-point = 0",
"-for i, j in enumerate(c, 1):",
"- if j == \"R\":",
"- if i > count:",
"- point += 1",
"-print(point)",
"+s = eval(input())",
"+num_r = s.count(\"R\")",
"+count = 0",
"+for i in range(num_r):",
"+ if s[i] != \"R\":",
"+ count += 1",
"+print(count)"
] | false | 0.046714 | 0.043781 | 1.067001 | [
"s248636480",
"s192587490"
] |
u698919163 | p03168 | python | s332856505 | s584908710 | 740 | 361 | 263,048 | 112,092 | Accepted | Accepted | 51.22 | N = int(eval(input()))
p = list(map(float,input().split()))
dp = [[0]*(N+1) for i in range(N)]
dp[0][0] = 1-p[0]
dp[0][1] = p[0]
for i in range(1,N):
dp[i][0] = (1-p[i])*dp[i-1][0]
for j in range(1,i+2):
dp[i][j] = dp[i-1][j-1]*p[i] + dp[i-1][j]*(1-p[i])
print((sum(dp[-1][(N+1)//2:]))) | N = int(eval(input()))
p = list(map(float,input().split()))
dp = [[0.0]*(N+1) for i in range(N+1)]
dp[0][0] = 1.0
for i in range(1,N+1):
for j in range(0,N+1):
dp[i][j] = dp[i-1][j-1]*(p[i-1]) + dp[i-1][j]*(1-p[i-1])
res = 0.0
for i in range((N+1)//2,N+1):
res += dp[-1][i]
print(res) | 14 | 14 | 319 | 310 | N = int(eval(input()))
p = list(map(float, input().split()))
dp = [[0] * (N + 1) for i in range(N)]
dp[0][0] = 1 - p[0]
dp[0][1] = p[0]
for i in range(1, N):
dp[i][0] = (1 - p[i]) * dp[i - 1][0]
for j in range(1, i + 2):
dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i])
print((sum(dp[-1][(N + 1) // 2 :])))
| N = int(eval(input()))
p = list(map(float, input().split()))
dp = [[0.0] * (N + 1) for i in range(N + 1)]
dp[0][0] = 1.0
for i in range(1, N + 1):
for j in range(0, N + 1):
dp[i][j] = dp[i - 1][j - 1] * (p[i - 1]) + dp[i - 1][j] * (1 - p[i - 1])
res = 0.0
for i in range((N + 1) // 2, N + 1):
res += dp[-1][i]
print(res)
| false | 0 | [
"-dp = [[0] * (N + 1) for i in range(N)]",
"-dp[0][0] = 1 - p[0]",
"-dp[0][1] = p[0]",
"-for i in range(1, N):",
"- dp[i][0] = (1 - p[i]) * dp[i - 1][0]",
"- for j in range(1, i + 2):",
"- dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i])",
"-print((sum(dp[-1][(N + 1) // 2 :])))",
"+dp = [[0.0] * (N + 1) for i in range(N + 1)]",
"+dp[0][0] = 1.0",
"+for i in range(1, N + 1):",
"+ for j in range(0, N + 1):",
"+ dp[i][j] = dp[i - 1][j - 1] * (p[i - 1]) + dp[i - 1][j] * (1 - p[i - 1])",
"+res = 0.0",
"+for i in range((N + 1) // 2, N + 1):",
"+ res += dp[-1][i]",
"+print(res)"
] | false | 0.035582 | 0.034328 | 1.03652 | [
"s332856505",
"s584908710"
] |
u814781830 | p03241 | python | s180079483 | s697871342 | 193 | 178 | 39,280 | 38,768 | Accepted | Accepted | 7.77 | N, M = list(map(int, input().split()))
n = M
# 約数列挙(1,N)も含まれる
prime, i = set(), 1
while i * i <= n:
if n % i == 0:
prime.add(i)
prime.add(n//i)
i += 1
ans = 1
l = list(prime)
for i in l:
if i * N <= M:
ans = max(ans, i)
print(ans)
| N, M = list(map(int, input().split()))
prime, i = set(), 1
while i * i <= M:
if M % i == 0:
prime.add(i)
prime.add(M//i)
i += 1
ans = 0
for i in prime:
if i * N <= M:
ans = max(ans, i)
print(ans)
| 18 | 14 | 281 | 241 | N, M = list(map(int, input().split()))
n = M
# 約数列挙(1,N)も含まれる
prime, i = set(), 1
while i * i <= n:
if n % i == 0:
prime.add(i)
prime.add(n // i)
i += 1
ans = 1
l = list(prime)
for i in l:
if i * N <= M:
ans = max(ans, i)
print(ans)
| N, M = list(map(int, input().split()))
prime, i = set(), 1
while i * i <= M:
if M % i == 0:
prime.add(i)
prime.add(M // i)
i += 1
ans = 0
for i in prime:
if i * N <= M:
ans = max(ans, i)
print(ans)
| false | 22.222222 | [
"-n = M",
"-# 約数列挙(1,N)も含まれる",
"-while i * i <= n:",
"- if n % i == 0:",
"+while i * i <= M:",
"+ if M % i == 0:",
"- prime.add(n // i)",
"+ prime.add(M // i)",
"-ans = 1",
"-l = list(prime)",
"-for i in l:",
"+ans = 0",
"+for i in prime:"
] | false | 0.057023 | 0.135361 | 0.421266 | [
"s180079483",
"s697871342"
] |
u167647458 | p03944 | python | s147787700 | s330136910 | 294 | 18 | 3,064 | 3,064 | Accepted | Accepted | 93.88 | w, h, n = list(map(int, input().split()))
xya = [list(map(int, input().split())) for _ in range(n)]
field = [[1 for _ in range(w)] for _ in range(h)]
for x, y, a in xya:
for i in range(h):
for j in range(w):
if a == 1 and j < x:
field[i][j] = 0
if a == 2 and j >= x:
field[i][j] = 0
if a == 3 and i < y:
field[i][j] = 0
if a == 4 and i >= y:
field[i][j] = 0
ans = 0
for i in field:
ans += sum(i)
print(ans) | w, h, n = list(map(int, input().split()))
xya = [list(map(int, input().split())) for _ in range(n)]
w1 = 0
w2 = w
h1 = 0
h2 = h
for x, y, a in xya:
if a == 1:
w1= max(w1, x)
if a == 2:
w2 = min(w2, x)
if a == 3:
h1 = max(h1, y)
if a == 4:
h2 = min(h2, y)
print((max(0, (w2-w1))*max(0, (h2-h1)))) | 21 | 18 | 624 | 362 | w, h, n = list(map(int, input().split()))
xya = [list(map(int, input().split())) for _ in range(n)]
field = [[1 for _ in range(w)] for _ in range(h)]
for x, y, a in xya:
for i in range(h):
for j in range(w):
if a == 1 and j < x:
field[i][j] = 0
if a == 2 and j >= x:
field[i][j] = 0
if a == 3 and i < y:
field[i][j] = 0
if a == 4 and i >= y:
field[i][j] = 0
ans = 0
for i in field:
ans += sum(i)
print(ans)
| w, h, n = list(map(int, input().split()))
xya = [list(map(int, input().split())) for _ in range(n)]
w1 = 0
w2 = w
h1 = 0
h2 = h
for x, y, a in xya:
if a == 1:
w1 = max(w1, x)
if a == 2:
w2 = min(w2, x)
if a == 3:
h1 = max(h1, y)
if a == 4:
h2 = min(h2, y)
print((max(0, (w2 - w1)) * max(0, (h2 - h1))))
| false | 14.285714 | [
"-field = [[1 for _ in range(w)] for _ in range(h)]",
"+w1 = 0",
"+w2 = w",
"+h1 = 0",
"+h2 = h",
"- for i in range(h):",
"- for j in range(w):",
"- if a == 1 and j < x:",
"- field[i][j] = 0",
"- if a == 2 and j >= x:",
"- field[i][j] = 0",
"- if a == 3 and i < y:",
"- field[i][j] = 0",
"- if a == 4 and i >= y:",
"- field[i][j] = 0",
"-ans = 0",
"-for i in field:",
"- ans += sum(i)",
"-print(ans)",
"+ if a == 1:",
"+ w1 = max(w1, x)",
"+ if a == 2:",
"+ w2 = min(w2, x)",
"+ if a == 3:",
"+ h1 = max(h1, y)",
"+ if a == 4:",
"+ h2 = min(h2, y)",
"+print((max(0, (w2 - w1)) * max(0, (h2 - h1))))"
] | false | 0.134035 | 0.036886 | 3.633748 | [
"s147787700",
"s330136910"
] |
u864197622 | p02670 | python | s196367550 | s446766667 | 1,947 | 1,731 | 171,704 | 173,636 | Accepted | Accepted | 11.09 | from collections import deque
N = int(eval(input()))
A = [int(a)-1 for a in input().split()]
M = N + 2
X = [max(min(i-1, j-1, M-2-i, M-2-j), -1) for j in range(M) for i in range(M)]
Y = [min(x, 0) + 1 for x in X]
def calc(i0):
h = X[i0]
if h < 0: return
Q = deque([(i0, h)])
X[i0] -= 1
Y[i0] = 0
dd = (-1, 1, M, -M)
while Q:
i, h = deque.popleft(Q)
for d in dd:
j = i + d
y = Y[j]
if X[j] >= h + y:
X[j] -= 1
deque.append(Q, (j, h + y))
ans = 0
for a in A:
aa = (a // N + 1) * M + a % N + 1
ans += X[aa]
calc(aa)
print(ans) | from collections import deque
N = int(eval(input()))
A = [int(a)-1 for a in input().split()]
M = N + 2
X = [max(min(i-1, j-1, M-2-i, M-2-j), -1) for j in range(M) for i in range(M)]
Y = [min(x, 0) + 1 for x in X]
ans = 0
for a in A:
aa = (a // N + 1) * M + a % N + 1
ans += X[aa]
h = X[aa]
if h < 0: continue
Q = deque([(aa, h)])
X[aa] -= 1
Y[aa] = 0
dd = (-1, 1, M, -M)
while Q:
i, h = deque.popleft(Q)
for d in dd:
j = i + d
y = Y[j]
if X[j] >= h + y:
X[j] -= 1
deque.append(Q, (j, h + y))
print(ans) | 28 | 26 | 669 | 642 | from collections import deque
N = int(eval(input()))
A = [int(a) - 1 for a in input().split()]
M = N + 2
X = [
max(min(i - 1, j - 1, M - 2 - i, M - 2 - j), -1) for j in range(M) for i in range(M)
]
Y = [min(x, 0) + 1 for x in X]
def calc(i0):
h = X[i0]
if h < 0:
return
Q = deque([(i0, h)])
X[i0] -= 1
Y[i0] = 0
dd = (-1, 1, M, -M)
while Q:
i, h = deque.popleft(Q)
for d in dd:
j = i + d
y = Y[j]
if X[j] >= h + y:
X[j] -= 1
deque.append(Q, (j, h + y))
ans = 0
for a in A:
aa = (a // N + 1) * M + a % N + 1
ans += X[aa]
calc(aa)
print(ans)
| from collections import deque
N = int(eval(input()))
A = [int(a) - 1 for a in input().split()]
M = N + 2
X = [
max(min(i - 1, j - 1, M - 2 - i, M - 2 - j), -1) for j in range(M) for i in range(M)
]
Y = [min(x, 0) + 1 for x in X]
ans = 0
for a in A:
aa = (a // N + 1) * M + a % N + 1
ans += X[aa]
h = X[aa]
if h < 0:
continue
Q = deque([(aa, h)])
X[aa] -= 1
Y[aa] = 0
dd = (-1, 1, M, -M)
while Q:
i, h = deque.popleft(Q)
for d in dd:
j = i + d
y = Y[j]
if X[j] >= h + y:
X[j] -= 1
deque.append(Q, (j, h + y))
print(ans)
| false | 7.142857 | [
"-",
"-",
"-def calc(i0):",
"- h = X[i0]",
"+ans = 0",
"+for a in A:",
"+ aa = (a // N + 1) * M + a % N + 1",
"+ ans += X[aa]",
"+ h = X[aa]",
"- return",
"- Q = deque([(i0, h)])",
"- X[i0] -= 1",
"- Y[i0] = 0",
"+ continue",
"+ Q = deque([(aa, h)])",
"+ X[aa] -= 1",
"+ Y[aa] = 0",
"-",
"-",
"-ans = 0",
"-for a in A:",
"- aa = (a // N + 1) * M + a % N + 1",
"- ans += X[aa]",
"- calc(aa)"
] | false | 0.040663 | 0.036358 | 1.118385 | [
"s196367550",
"s446766667"
] |
u525065967 | p02767 | python | s681605767 | s375961827 | 23 | 21 | 3,060 | 3,060 | Accepted | Accepted | 8.7 | n = int(eval(input()))
X = list(map(int, input().split()))
ans = 1000000000
for p in range(1,100):
s = 0
for x in X:
s += (x-p)**2
ans = min(ans, s)
print(ans) | n = int(eval(input()))
X = list(map(int, input().split()))
ans = 1000000000
for p in range(1,101):
s = 0
for x in X:
s += (x-p)**2
ans = min(ans, s)
print(ans) | 9 | 9 | 181 | 181 | n = int(eval(input()))
X = list(map(int, input().split()))
ans = 1000000000
for p in range(1, 100):
s = 0
for x in X:
s += (x - p) ** 2
ans = min(ans, s)
print(ans)
| n = int(eval(input()))
X = list(map(int, input().split()))
ans = 1000000000
for p in range(1, 101):
s = 0
for x in X:
s += (x - p) ** 2
ans = min(ans, s)
print(ans)
| false | 0 | [
"-for p in range(1, 100):",
"+for p in range(1, 101):"
] | false | 0.043469 | 0.041462 | 1.048417 | [
"s681605767",
"s375961827"
] |
u989345508 | p03574 | python | s557217036 | s716463461 | 26 | 21 | 3,572 | 3,064 | Accepted | Accepted | 19.23 | h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
def count_8(i,j):
global h,w,s
cnt=0
if i-1>=0 and j-1>=0:
if s[i-1][j-1]=="#":
cnt+=1
if i-1>=0 and j+1<=w-1:
if s[i-1][j+1]=="#":
cnt+=1
if i+1<=h-1 and j-1>=0:
if s[i+1][j-1]=="#":
cnt+=1
if i+1<=h-1 and j+1<=w-1:
if s[i+1][j+1]=="#":
cnt+=1
if i-1>=0:
if s[i-1][j]=="#":
cnt+=1
if j-1>=0:
if s[i][j-1]=="#":
cnt+=1
if i+1<=h-1:
if s[i+1][j]=="#":
cnt+=1
if j+1<=w-1:
if s[i][j+1]=="#":
cnt+=1
return str(cnt)
for i in range(h):
for j in range(w):
if s[i][j]=="#":
print("#",end="")
else:
print(count_8(i,j),end="")
print()
| h,w=list(map(int,input().split()))
s=[eval(input())+"." if i!=h else "."*(w+1) for i in range(h+1)]
def count_8(i,j):
global h,w,s
cnt=str((s[i-1][j-1]=="#")+(s[i-1][j+1]=="#")+(s[i+1][j-1]=="#")+(s[i+1][j+1]=="#") \
+(s[i-1][j]=="#")+(s[i][j-1]=="#")+(s[i+1][j]=="#")+(s[i][j+1]=="#"))
return cnt
for i in range(h):
s_sub=""
for j in range(w):
if s[i][j]=="#":
s_sub+="#"
else:
s_sub+=count_8(i,j)
print(s_sub)
| 37 | 15 | 880 | 486 | h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
def count_8(i, j):
global h, w, s
cnt = 0
if i - 1 >= 0 and j - 1 >= 0:
if s[i - 1][j - 1] == "#":
cnt += 1
if i - 1 >= 0 and j + 1 <= w - 1:
if s[i - 1][j + 1] == "#":
cnt += 1
if i + 1 <= h - 1 and j - 1 >= 0:
if s[i + 1][j - 1] == "#":
cnt += 1
if i + 1 <= h - 1 and j + 1 <= w - 1:
if s[i + 1][j + 1] == "#":
cnt += 1
if i - 1 >= 0:
if s[i - 1][j] == "#":
cnt += 1
if j - 1 >= 0:
if s[i][j - 1] == "#":
cnt += 1
if i + 1 <= h - 1:
if s[i + 1][j] == "#":
cnt += 1
if j + 1 <= w - 1:
if s[i][j + 1] == "#":
cnt += 1
return str(cnt)
for i in range(h):
for j in range(w):
if s[i][j] == "#":
print("#", end="")
else:
print(count_8(i, j), end="")
print()
| h, w = list(map(int, input().split()))
s = [eval(input()) + "." if i != h else "." * (w + 1) for i in range(h + 1)]
def count_8(i, j):
global h, w, s
cnt = str(
(s[i - 1][j - 1] == "#")
+ (s[i - 1][j + 1] == "#")
+ (s[i + 1][j - 1] == "#")
+ (s[i + 1][j + 1] == "#")
+ (s[i - 1][j] == "#")
+ (s[i][j - 1] == "#")
+ (s[i + 1][j] == "#")
+ (s[i][j + 1] == "#")
)
return cnt
for i in range(h):
s_sub = ""
for j in range(w):
if s[i][j] == "#":
s_sub += "#"
else:
s_sub += count_8(i, j)
print(s_sub)
| false | 59.459459 | [
"-h, w = map(int, input().split())",
"-s = [list(input()) for i in range(h)]",
"+h, w = list(map(int, input().split()))",
"+s = [eval(input()) + \".\" if i != h else \".\" * (w + 1) for i in range(h + 1)]",
"- cnt = 0",
"- if i - 1 >= 0 and j - 1 >= 0:",
"- if s[i - 1][j - 1] == \"#\":",
"- cnt += 1",
"- if i - 1 >= 0 and j + 1 <= w - 1:",
"- if s[i - 1][j + 1] == \"#\":",
"- cnt += 1",
"- if i + 1 <= h - 1 and j - 1 >= 0:",
"- if s[i + 1][j - 1] == \"#\":",
"- cnt += 1",
"- if i + 1 <= h - 1 and j + 1 <= w - 1:",
"- if s[i + 1][j + 1] == \"#\":",
"- cnt += 1",
"- if i - 1 >= 0:",
"- if s[i - 1][j] == \"#\":",
"- cnt += 1",
"- if j - 1 >= 0:",
"- if s[i][j - 1] == \"#\":",
"- cnt += 1",
"- if i + 1 <= h - 1:",
"- if s[i + 1][j] == \"#\":",
"- cnt += 1",
"- if j + 1 <= w - 1:",
"- if s[i][j + 1] == \"#\":",
"- cnt += 1",
"- return str(cnt)",
"+ cnt = str(",
"+ (s[i - 1][j - 1] == \"#\")",
"+ + (s[i - 1][j + 1] == \"#\")",
"+ + (s[i + 1][j - 1] == \"#\")",
"+ + (s[i + 1][j + 1] == \"#\")",
"+ + (s[i - 1][j] == \"#\")",
"+ + (s[i][j - 1] == \"#\")",
"+ + (s[i + 1][j] == \"#\")",
"+ + (s[i][j + 1] == \"#\")",
"+ )",
"+ return cnt",
"+ s_sub = \"\"",
"- print(\"#\", end=\"\")",
"+ s_sub += \"#\"",
"- print(count_8(i, j), end=\"\")",
"- print()",
"+ s_sub += count_8(i, j)",
"+ print(s_sub)"
] | false | 0.081552 | 0.038441 | 2.121499 | [
"s557217036",
"s716463461"
] |
u700388551 | p02577 | python | s822864524 | s555919261 | 204 | 48 | 9,236 | 10,544 | Accepted | Accepted | 76.47 | N = int(eval(input()))
if(N%9 == 0):
print("Yes")
else:
print("No") | N = list(map(int,eval(input())))
if(sum(N) % 9 == 0):
print("Yes")
else:
print("No") | 5 | 5 | 67 | 84 | N = int(eval(input()))
if N % 9 == 0:
print("Yes")
else:
print("No")
| N = list(map(int, eval(input())))
if sum(N) % 9 == 0:
print("Yes")
else:
print("No")
| false | 0 | [
"-N = int(eval(input()))",
"-if N % 9 == 0:",
"+N = list(map(int, eval(input())))",
"+if sum(N) % 9 == 0:"
] | false | 0.085719 | 0.038236 | 2.241872 | [
"s822864524",
"s555919261"
] |
u504836877 | p02757 | python | s567233143 | s240572570 | 498 | 327 | 3,628 | 9,516 | Accepted | Accepted | 34.34 | N,P = list(map(int, input().split()))
S = eval(input())
ans = 0
if P == 2:
for i in range(N-1, -1, -1):
if int(S[i])%2 == 0:
ans += i+1
elif P == 5:
for i in range(N-1, -1, -1):
if int(S[i])%5 == 0:
ans += i+1
else:
L = [0]*P
num = 0
for i in range(N-1, -1, -1):
num += int(S[i])*pow(10, N-1-i, P)
num %= P
L[num] += 1
ans += L[0]
for i in range(P):
ans += L[i]*(L[i]-1)//2
print(ans) | N,P = list(map(int, input().split()))
S = eval(input())
if P == 2:
ans = 0
for i in range(N):
if int(S[i])%2 == 0:
ans += i+1
elif P == 5:
ans = 0
for i in range(N):
if S[i] == "0" or S[i] == "5":
ans += i+1
else:
L = [0]*P
num = 0
for i in range(N):
num += int(S[N-i-1])*pow(10, i, P)
num %= P
L[num] += 1
ans = L[0]
for i in range(P):
ans += L[i]*(L[i]-1)//2
print(ans) | 25 | 25 | 499 | 493 | N, P = list(map(int, input().split()))
S = eval(input())
ans = 0
if P == 2:
for i in range(N - 1, -1, -1):
if int(S[i]) % 2 == 0:
ans += i + 1
elif P == 5:
for i in range(N - 1, -1, -1):
if int(S[i]) % 5 == 0:
ans += i + 1
else:
L = [0] * P
num = 0
for i in range(N - 1, -1, -1):
num += int(S[i]) * pow(10, N - 1 - i, P)
num %= P
L[num] += 1
ans += L[0]
for i in range(P):
ans += L[i] * (L[i] - 1) // 2
print(ans)
| N, P = list(map(int, input().split()))
S = eval(input())
if P == 2:
ans = 0
for i in range(N):
if int(S[i]) % 2 == 0:
ans += i + 1
elif P == 5:
ans = 0
for i in range(N):
if S[i] == "0" or S[i] == "5":
ans += i + 1
else:
L = [0] * P
num = 0
for i in range(N):
num += int(S[N - i - 1]) * pow(10, i, P)
num %= P
L[num] += 1
ans = L[0]
for i in range(P):
ans += L[i] * (L[i] - 1) // 2
print(ans)
| false | 0 | [
"-ans = 0",
"- for i in range(N - 1, -1, -1):",
"+ ans = 0",
"+ for i in range(N):",
"- for i in range(N - 1, -1, -1):",
"- if int(S[i]) % 5 == 0:",
"+ ans = 0",
"+ for i in range(N):",
"+ if S[i] == \"0\" or S[i] == \"5\":",
"- for i in range(N - 1, -1, -1):",
"- num += int(S[i]) * pow(10, N - 1 - i, P)",
"+ for i in range(N):",
"+ num += int(S[N - i - 1]) * pow(10, i, P)",
"- ans += L[0]",
"+ ans = L[0]"
] | false | 0.038867 | 0.038634 | 1.006022 | [
"s567233143",
"s240572570"
] |
u888092736 | p02975 | python | s896938666 | s947599443 | 85 | 58 | 14,704 | 20,080 | Accepted | Accepted | 31.76 | from functools import reduce
from collections import Counter
N = int(eval(input()))
a = list(map(int, input().split()))
if N % 3 and a != [0] * N:
print("No")
exit()
nums = Counter(a)
ks = sorted(nums)
vs = sorted(nums.values())
if (
(len(nums) == 1 and ks[0] == 0)
or (len(nums) == 2 and ks[0] == 0 and vs[0] == N // 3)
or (
len(nums) == 3
and all(v == N // 3 for v in vs)
and reduce(lambda x, y: x ^ y, ks) == 0
)
):
print("Yes")
else:
print("No")
| N, *A = map(int, open(0).read().split())
A_set = set(A)
if len(A_set) == 1:
print("Yes") if sum(A) == 0 else print("No")
elif len(A_set) == 2:
a1, a2 = sorted(A_set)
print("Yes") if a1 == 0 and A.count(a1) * 3 == N else print("No")
elif len(A_set) == 3:
a1, a2, a3 = list(A_set)
if a1 ^ a2 ^ a3 == 0 and A.count(a1) == A.count(a2) == A.count(a3):
print("Yes")
else:
print("No")
else:
print("No")
| 25 | 16 | 527 | 456 | from functools import reduce
from collections import Counter
N = int(eval(input()))
a = list(map(int, input().split()))
if N % 3 and a != [0] * N:
print("No")
exit()
nums = Counter(a)
ks = sorted(nums)
vs = sorted(nums.values())
if (
(len(nums) == 1 and ks[0] == 0)
or (len(nums) == 2 and ks[0] == 0 and vs[0] == N // 3)
or (
len(nums) == 3
and all(v == N // 3 for v in vs)
and reduce(lambda x, y: x ^ y, ks) == 0
)
):
print("Yes")
else:
print("No")
| N, *A = map(int, open(0).read().split())
A_set = set(A)
if len(A_set) == 1:
print("Yes") if sum(A) == 0 else print("No")
elif len(A_set) == 2:
a1, a2 = sorted(A_set)
print("Yes") if a1 == 0 and A.count(a1) * 3 == N else print("No")
elif len(A_set) == 3:
a1, a2, a3 = list(A_set)
if a1 ^ a2 ^ a3 == 0 and A.count(a1) == A.count(a2) == A.count(a3):
print("Yes")
else:
print("No")
else:
print("No")
| false | 36 | [
"-from functools import reduce",
"-from collections import Counter",
"-",
"-N = int(eval(input()))",
"-a = list(map(int, input().split()))",
"-if N % 3 and a != [0] * N:",
"- print(\"No\")",
"- exit()",
"-nums = Counter(a)",
"-ks = sorted(nums)",
"-vs = sorted(nums.values())",
"-if (",
"- (len(nums) == 1 and ks[0] == 0)",
"- or (len(nums) == 2 and ks[0] == 0 and vs[0] == N // 3)",
"- or (",
"- len(nums) == 3",
"- and all(v == N // 3 for v in vs)",
"- and reduce(lambda x, y: x ^ y, ks) == 0",
"- )",
"-):",
"- print(\"Yes\")",
"+N, *A = map(int, open(0).read().split())",
"+A_set = set(A)",
"+if len(A_set) == 1:",
"+ print(\"Yes\") if sum(A) == 0 else print(\"No\")",
"+elif len(A_set) == 2:",
"+ a1, a2 = sorted(A_set)",
"+ print(\"Yes\") if a1 == 0 and A.count(a1) * 3 == N else print(\"No\")",
"+elif len(A_set) == 3:",
"+ a1, a2, a3 = list(A_set)",
"+ if a1 ^ a2 ^ a3 == 0 and A.count(a1) == A.count(a2) == A.count(a3):",
"+ print(\"Yes\")",
"+ else:",
"+ print(\"No\")"
] | false | 0.075864 | 0.111303 | 0.681601 | [
"s896938666",
"s947599443"
] |
u084320347 | p02836 | python | s384647470 | s784538897 | 19 | 17 | 3,060 | 2,940 | Accepted | Accepted | 10.53 | S = eval(input())
count=0
for i in range(len(S)//2):
if S[i] != S[-i-1]:
count+=1
print(count) | s = eval(input())
n_s = s[::-1]
ans = 0
for i in range(len(s)//2):
if s[i] != n_s[i]:
ans += 1
print(ans)
| 8 | 8 | 104 | 120 | S = eval(input())
count = 0
for i in range(len(S) // 2):
if S[i] != S[-i - 1]:
count += 1
print(count)
| s = eval(input())
n_s = s[::-1]
ans = 0
for i in range(len(s) // 2):
if s[i] != n_s[i]:
ans += 1
print(ans)
| false | 0 | [
"-S = eval(input())",
"-count = 0",
"-for i in range(len(S) // 2):",
"- if S[i] != S[-i - 1]:",
"- count += 1",
"-print(count)",
"+s = eval(input())",
"+n_s = s[::-1]",
"+ans = 0",
"+for i in range(len(s) // 2):",
"+ if s[i] != n_s[i]:",
"+ ans += 1",
"+print(ans)"
] | false | 0.047598 | 0.050716 | 0.938516 | [
"s384647470",
"s784538897"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.