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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u285891772 | p03017 | python | s917208492 | s845972995 | 70 | 44 | 12,260 | 10,936 | Accepted | Accepted | 37.14 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
def ZIP(n): return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *
N, A, B, C, D = MAP()
S = list(eval(input()))
def cango(a, b):
for i in range(a, b):
if S[i] == "#" and S[i+1] == "#":
return False
break
else:
return True
if C < D:
if cango(A-1, C-1) and cango(B-1, D-1):
print("Yes")
else:
print("No")
else:
for i in range(B-2, D-1):
if S[i] == S[i+1] == S[i+2] == ".":
S[i+1] = "#"
break
else:
print("No")
exit()
if cango(A-1, C-1):
print("Yes")
else:
print("No") | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
def ZIP(n): return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *
N, A, B, C, D = MAP()
S = eval(input())
if 1 <= S[A:max(C, D)].count("##"):
print("No")
elif C < D:
print("Yes")
else:
if 1 <= S[B-2:D+1].count("..."):
print("Yes")
else:
print("No") | 51 | 33 | 1,360 | 1,092 | import sys, re
from collections import deque, defaultdict, Counter
from math import (
ceil,
sqrt,
hypot,
factorial,
pi,
sin,
cos,
tan,
asin,
acos,
atan,
radians,
degrees,
) # , log2
from itertools import (
accumulate,
permutations,
combinations,
combinations_with_replacement,
product,
groupby,
)
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input():
return sys.stdin.readline().strip()
def INT():
return int(eval(input()))
def MAP():
return list(map(int, input().split()))
def LIST():
return list(map(int, input().split()))
def ZIP(n):
return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10**9)
INF = float("inf")
mod = 10**9 + 7
# from decimal import *
N, A, B, C, D = MAP()
S = list(eval(input()))
def cango(a, b):
for i in range(a, b):
if S[i] == "#" and S[i + 1] == "#":
return False
break
else:
return True
if C < D:
if cango(A - 1, C - 1) and cango(B - 1, D - 1):
print("Yes")
else:
print("No")
else:
for i in range(B - 2, D - 1):
if S[i] == S[i + 1] == S[i + 2] == ".":
S[i + 1] = "#"
break
else:
print("No")
exit()
if cango(A - 1, C - 1):
print("Yes")
else:
print("No")
| import sys, re
from collections import deque, defaultdict, Counter
from math import (
ceil,
sqrt,
hypot,
factorial,
pi,
sin,
cos,
tan,
asin,
acos,
atan,
radians,
degrees,
) # , log2
from itertools import (
accumulate,
permutations,
combinations,
combinations_with_replacement,
product,
groupby,
)
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input():
return sys.stdin.readline().strip()
def INT():
return int(eval(input()))
def MAP():
return list(map(int, input().split()))
def LIST():
return list(map(int, input().split()))
def ZIP(n):
return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10**9)
INF = float("inf")
mod = 10**9 + 7
# from decimal import *
N, A, B, C, D = MAP()
S = eval(input())
if 1 <= S[A : max(C, D)].count("##"):
print("No")
elif C < D:
print("Yes")
else:
if 1 <= S[B - 2 : D + 1].count("..."):
print("Yes")
else:
print("No")
| false | 35.294118 | [
"-S = list(eval(input()))",
"-",
"-",
"-def cango(a, b):",
"- for i in range(a, b):",
"- if S[i] == \"#\" and S[i + 1] == \"#\":",
"- return False",
"- break",
"- else:",
"- return True",
"-",
"-",
"-if C < D:",
"- if cango(A - 1, C - 1) and cango(B - 1, D - 1):",
"+S = eval(input())",
"+if 1 <= S[A : max(C, D)].count(\"##\"):",
"+ print(\"No\")",
"+elif C < D:",
"+ print(\"Yes\")",
"+else:",
"+ if 1 <= S[B - 2 : D + 1].count(\"...\"):",
"-else:",
"- for i in range(B - 2, D - 1):",
"- if S[i] == S[i + 1] == S[i + 2] == \".\":",
"- S[i + 1] = \"#\"",
"- break",
"- else:",
"- print(\"No\")",
"- exit()",
"- if cango(A - 1, C - 1):",
"- print(\"Yes\")",
"- else:",
"- print(\"No\")"
] | false | 0.038645 | 0.037986 | 1.017349 | [
"s917208492",
"s845972995"
] |
u625729943 | p02861 | python | s366383672 | s582506038 | 439 | 209 | 7,972 | 40,556 | Accepted | Accepted | 52.39 | import sys
import itertools
import math
#input = sys.stdin.readline
sys.setrecursionlimit(10**7)
N = int(eval(input()))
xy = [list(map(int, input().split())) for _ in range(N)]
pattern = list(itertools.permutations(list(range(N))))
pall = 0
for pat in pattern:
for i in range(N-1):
currp = xy[pat[i]]
nextp = xy[pat[i+1]]
dist = math.sqrt(
(currp[0] - nextp[0])**2
+ (currp[1] - nextp[1])**2
)
pall += dist
print((pall/(len(pattern))))
| import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print(('\n'.join(map(str, x))))
N = int(eval(input()))
xy = [list(map(int, input().split())) for _ in range(N)]
d = [[0]*(N) for _ in range(N)]
cnt = 0
for route in permutations(list(range(1, N+1))):
for val1, val2 in zip(route[:-1], route[1:]):
val1, val2 = val1-1, val2-1
dist = d[val1][val2]
if dist > 0:
cnt += dist
elif dist == 0:
d[val1][val2] = (pow(xy[val1][0]-xy[val2][0], 2) + pow(xy[val1][1]-xy[val2][1], 2))**(1/2)
cnt += d[val1][val2]
res = cnt/factorial(N)
print(res)
| 23 | 28 | 528 | 895 | import sys
import itertools
import math
# input = sys.stdin.readline
sys.setrecursionlimit(10**7)
N = int(eval(input()))
xy = [list(map(int, input().split())) for _ in range(N)]
pattern = list(itertools.permutations(list(range(N))))
pall = 0
for pat in pattern:
for i in range(N - 1):
currp = xy[pat[i]]
nextp = xy[pat[i + 1]]
dist = math.sqrt((currp[0] - nextp[0]) ** 2 + (currp[1] - nextp[1]) ** 2)
pall += dist
print((pall / (len(pattern))))
| import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial # , gcd
from bisect import bisect_left # bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9 + 7
def input():
return sys.stdin.readline()[:-1]
def pri(x):
print(("\n".join(map(str, x))))
N = int(eval(input()))
xy = [list(map(int, input().split())) for _ in range(N)]
d = [[0] * (N) for _ in range(N)]
cnt = 0
for route in permutations(list(range(1, N + 1))):
for val1, val2 in zip(route[:-1], route[1:]):
val1, val2 = val1 - 1, val2 - 1
dist = d[val1][val2]
if dist > 0:
cnt += dist
elif dist == 0:
d[val1][val2] = (
pow(xy[val1][0] - xy[val2][0], 2) + pow(xy[val1][1] - xy[val2][1], 2)
) ** (1 / 2)
cnt += d[val1][val2]
res = cnt / factorial(N)
print(res)
| false | 17.857143 | [
"-import sys",
"-import itertools",
"-import math",
"+import sys, math",
"+from itertools import permutations, combinations",
"+from collections import defaultdict, Counter, deque",
"+from math import factorial # , gcd",
"+from bisect import bisect_left # bisect_left(list, value)",
"-# input = sys.stdin.readline",
"+enu = enumerate",
"+MOD = 10**9 + 7",
"+",
"+",
"+def input():",
"+ return sys.stdin.readline()[:-1]",
"+",
"+",
"+def pri(x):",
"+ print((\"\\n\".join(map(str, x))))",
"+",
"+",
"-pattern = list(itertools.permutations(list(range(N))))",
"-pall = 0",
"-for pat in pattern:",
"- for i in range(N - 1):",
"- currp = xy[pat[i]]",
"- nextp = xy[pat[i + 1]]",
"- dist = math.sqrt((currp[0] - nextp[0]) ** 2 + (currp[1] - nextp[1]) ** 2)",
"- pall += dist",
"-print((pall / (len(pattern))))",
"+d = [[0] * (N) for _ in range(N)]",
"+cnt = 0",
"+for route in permutations(list(range(1, N + 1))):",
"+ for val1, val2 in zip(route[:-1], route[1:]):",
"+ val1, val2 = val1 - 1, val2 - 1",
"+ dist = d[val1][val2]",
"+ if dist > 0:",
"+ cnt += dist",
"+ elif dist == 0:",
"+ d[val1][val2] = (",
"+ pow(xy[val1][0] - xy[val2][0], 2) + pow(xy[val1][1] - xy[val2][1], 2)",
"+ ) ** (1 / 2)",
"+ cnt += d[val1][val2]",
"+res = cnt / factorial(N)",
"+print(res)"
] | false | 0.04737 | 0.042368 | 1.118064 | [
"s366383672",
"s582506038"
] |
u141610915 | p03304 | python | s258652547 | s646743111 | 167 | 66 | 38,384 | 61,580 | Accepted | Accepted | 60.48 | import sys
input = sys.stdin.readline
n, m, d = list(map(float, input().split()))
t = float(n - d)
if d == 0: print(((m - 1) * (1 / n)))
else: print(((m - 1) * 2 * t / pow(n, 2))) | import sys
input = sys.stdin.readline
N, M, D = list(map(float, input().split()))
print(((M - 1) / N + ((N - 2 * D) > 0 and (D > 0)) * (N - 2 * D) * (M - 1) / (N ** 2))) | 6 | 4 | 174 | 164 | import sys
input = sys.stdin.readline
n, m, d = list(map(float, input().split()))
t = float(n - d)
if d == 0:
print(((m - 1) * (1 / n)))
else:
print(((m - 1) * 2 * t / pow(n, 2)))
| import sys
input = sys.stdin.readline
N, M, D = list(map(float, input().split()))
print(((M - 1) / N + ((N - 2 * D) > 0 and (D > 0)) * (N - 2 * D) * (M - 1) / (N**2)))
| false | 33.333333 | [
"-n, m, d = list(map(float, input().split()))",
"-t = float(n - d)",
"-if d == 0:",
"- print(((m - 1) * (1 / n)))",
"-else:",
"- print(((m - 1) * 2 * t / pow(n, 2)))",
"+N, M, D = list(map(float, input().split()))",
"+print(((M - 1) / N + ((N - 2 * D) > 0 and (D > 0)) * (N - 2 * D) * (M - 1) / (N**2)))"
] | false | 0.033974 | 0.03496 | 0.971781 | [
"s258652547",
"s646743111"
] |
u753803401 | p03013 | python | s200910479 | s280179504 | 238 | 203 | 52,696 | 50,008 | Accepted | Accepted | 14.71 | import sys
import collections
def solve():
input = sys.stdin.readline
mod = 10 ** 9 + 7
n, m = list(map(int, input().rstrip('\n').split()))
a = collections.defaultdict(list)
for _ in range(m):
a[int(input().rstrip('\n'))]
ls = [0] * (n + 1)
ls[0] = 1 if 0 not in a else 0
ls[1] = 1 if 1 not in a else 0
for i in range(2, n + 1):
if i not in a:
ls[i] = (ls[i-1] + ls[i-2]) % mod
else:
ls[i] = 0
print((ls[-1]))
if __name__ == '__main__':
solve()
| import sys
import collections
def solve():
readline = sys.stdin.buffer.readline
mod = 10 ** 9 + 7
n, m = list(map(int, readline().split()))
d = collections.defaultdict(int)
for i in range(m):
d[int(readline())]
dp = [0] * (n + 1)
dp[0] = 1
for i in range(1, n + 1):
if i not in d:
if i == 1:
dp[i] += dp[i-1]
else:
dp[i] += dp[i-1]
dp[i] += dp[i-2]
dp[i] %= mod
print((dp[-1]))
if __name__ == '__main__':
solve()
| 24 | 26 | 562 | 580 | import sys
import collections
def solve():
input = sys.stdin.readline
mod = 10**9 + 7
n, m = list(map(int, input().rstrip("\n").split()))
a = collections.defaultdict(list)
for _ in range(m):
a[int(input().rstrip("\n"))]
ls = [0] * (n + 1)
ls[0] = 1 if 0 not in a else 0
ls[1] = 1 if 1 not in a else 0
for i in range(2, n + 1):
if i not in a:
ls[i] = (ls[i - 1] + ls[i - 2]) % mod
else:
ls[i] = 0
print((ls[-1]))
if __name__ == "__main__":
solve()
| import sys
import collections
def solve():
readline = sys.stdin.buffer.readline
mod = 10**9 + 7
n, m = list(map(int, readline().split()))
d = collections.defaultdict(int)
for i in range(m):
d[int(readline())]
dp = [0] * (n + 1)
dp[0] = 1
for i in range(1, n + 1):
if i not in d:
if i == 1:
dp[i] += dp[i - 1]
else:
dp[i] += dp[i - 1]
dp[i] += dp[i - 2]
dp[i] %= mod
print((dp[-1]))
if __name__ == "__main__":
solve()
| false | 7.692308 | [
"- input = sys.stdin.readline",
"+ readline = sys.stdin.buffer.readline",
"- n, m = list(map(int, input().rstrip(\"\\n\").split()))",
"- a = collections.defaultdict(list)",
"- for _ in range(m):",
"- a[int(input().rstrip(\"\\n\"))]",
"- ls = [0] * (n + 1)",
"- ls[0] = 1 if 0 not in a else 0",
"- ls[1] = 1 if 1 not in a else 0",
"- for i in range(2, n + 1):",
"- if i not in a:",
"- ls[i] = (ls[i - 1] + ls[i - 2]) % mod",
"- else:",
"- ls[i] = 0",
"- print((ls[-1]))",
"+ n, m = list(map(int, readline().split()))",
"+ d = collections.defaultdict(int)",
"+ for i in range(m):",
"+ d[int(readline())]",
"+ dp = [0] * (n + 1)",
"+ dp[0] = 1",
"+ for i in range(1, n + 1):",
"+ if i not in d:",
"+ if i == 1:",
"+ dp[i] += dp[i - 1]",
"+ else:",
"+ dp[i] += dp[i - 1]",
"+ dp[i] += dp[i - 2]",
"+ dp[i] %= mod",
"+ print((dp[-1]))"
] | false | 0.03581 | 0.035848 | 0.998948 | [
"s200910479",
"s280179504"
] |
u723711163 | p03476 | python | s016021197 | s396555642 | 1,006 | 447 | 51,416 | 78,820 | Accepted | Accepted | 55.57 | import math
primes = [True]*(10**5+1)
primes[0],primes[1] = False,False
cumsum = [0]*(10**5+1)
for i in range(2, int(math.sqrt(10**5)+1)):
if primes[i]:
j = 2
while i*j <= 10**5:
primes[i*j] = False
j += 1
for i in range(2, 10**5+1):
if primes[i] and primes[(i+1)//2]:
cumsum[i] = cumsum[i-1]+1
else:
cumsum[i] = cumsum[i-1]
Q = int(eval(input()))
for _ in range(Q):
l,r = list(map(int,input().split()))
print((cumsum[r]-cumsum[l-1])) | MAX_INT = 10**5+1
primes = [True] * (10**5+1)
primes[0], primes[1] = False, False
for i in range(2, int(MAX_INT**0.5)+1):
if primes[i]:
for j in range(i*2, MAX_INT, i):
primes[j] = False
cumsum = [0] * (10**5+1)
for i in range(1, 10**5+1, 2):
if primes[i] and primes[(i+1)//2]:
cumsum[i] = 1
for i in range(1, 10**5+1):
cumsum[i] += cumsum[i-1]
Q = int(eval(input()))
for _ in range(Q):
l,r = list(map(int,input().split()))
print((cumsum[r]-cumsum[l-1])) | 22 | 20 | 482 | 488 | import math
primes = [True] * (10**5 + 1)
primes[0], primes[1] = False, False
cumsum = [0] * (10**5 + 1)
for i in range(2, int(math.sqrt(10**5) + 1)):
if primes[i]:
j = 2
while i * j <= 10**5:
primes[i * j] = False
j += 1
for i in range(2, 10**5 + 1):
if primes[i] and primes[(i + 1) // 2]:
cumsum[i] = cumsum[i - 1] + 1
else:
cumsum[i] = cumsum[i - 1]
Q = int(eval(input()))
for _ in range(Q):
l, r = list(map(int, input().split()))
print((cumsum[r] - cumsum[l - 1]))
| MAX_INT = 10**5 + 1
primes = [True] * (10**5 + 1)
primes[0], primes[1] = False, False
for i in range(2, int(MAX_INT**0.5) + 1):
if primes[i]:
for j in range(i * 2, MAX_INT, i):
primes[j] = False
cumsum = [0] * (10**5 + 1)
for i in range(1, 10**5 + 1, 2):
if primes[i] and primes[(i + 1) // 2]:
cumsum[i] = 1
for i in range(1, 10**5 + 1):
cumsum[i] += cumsum[i - 1]
Q = int(eval(input()))
for _ in range(Q):
l, r = list(map(int, input().split()))
print((cumsum[r] - cumsum[l - 1]))
| false | 9.090909 | [
"-import math",
"-",
"+MAX_INT = 10**5 + 1",
"+for i in range(2, int(MAX_INT**0.5) + 1):",
"+ if primes[i]:",
"+ for j in range(i * 2, MAX_INT, i):",
"+ primes[j] = False",
"-for i in range(2, int(math.sqrt(10**5) + 1)):",
"- if primes[i]:",
"- j = 2",
"- while i * j <= 10**5:",
"- primes[i * j] = False",
"- j += 1",
"-for i in range(2, 10**5 + 1):",
"+for i in range(1, 10**5 + 1, 2):",
"- cumsum[i] = cumsum[i - 1] + 1",
"- else:",
"- cumsum[i] = cumsum[i - 1]",
"+ cumsum[i] = 1",
"+for i in range(1, 10**5 + 1):",
"+ cumsum[i] += cumsum[i - 1]"
] | false | 0.461511 | 0.098494 | 4.685682 | [
"s016021197",
"s396555642"
] |
u847467233 | p00092 | python | s113043832 | s078462948 | 4,660 | 3,930 | 33,068 | 33,064 | Accepted | Accepted | 15.67 | # AOJ 0092 Square Searching
# Python3 2018.6.21 bal4u
cin = [[''] for r in range(1002)]
dp = [[0 for c in range(1002)] for r in range(1002)]
while 1:
n = int(eval(input()))
if n == 0: break
for r in range(n):
cin[r] = eval(input())
ans = 0
for r in range(n):
for c in range(n):
if cin[r][c] == '*': dp[r][c] = 0
else :
t = dp[r-1][c-1]
if t > 0 and dp[r ][c-1] < t: t = dp[r ][c-1];
if t > 0 and dp[r-1][c ] < t: t = dp[r-1][c ];
t += 1
dp[r][c] = t
if t > ans: ans = t
print(ans)
| # AOJ 0092 Square Searching
# Python3 2018.6.21 bal4u
cin = [[''] for r in range(1002)]
dp = [[0 for c in range(1002)] for r in range(1002)]
while 1:
n = int(eval(input()))
if n == 0: break
for r in range(n): cin[r] = eval(input())
ans = 0
for r in range(n):
for c in range(n):
if cin[r][c] == '*': dp[r][c] = 0
else :
t = dp[r-1][c-1]
if dp[r ][c-1] < t: t = dp[r ][c-1];
if dp[r-1][c ] < t: t = dp[r-1][c ];
t += 1
dp[r][c] = t
if t > ans: ans = t
print(ans)
| 23 | 22 | 538 | 515 | # AOJ 0092 Square Searching
# Python3 2018.6.21 bal4u
cin = [[""] for r in range(1002)]
dp = [[0 for c in range(1002)] for r in range(1002)]
while 1:
n = int(eval(input()))
if n == 0:
break
for r in range(n):
cin[r] = eval(input())
ans = 0
for r in range(n):
for c in range(n):
if cin[r][c] == "*":
dp[r][c] = 0
else:
t = dp[r - 1][c - 1]
if t > 0 and dp[r][c - 1] < t:
t = dp[r][c - 1]
if t > 0 and dp[r - 1][c] < t:
t = dp[r - 1][c]
t += 1
dp[r][c] = t
if t > ans:
ans = t
print(ans)
| # AOJ 0092 Square Searching
# Python3 2018.6.21 bal4u
cin = [[""] for r in range(1002)]
dp = [[0 for c in range(1002)] for r in range(1002)]
while 1:
n = int(eval(input()))
if n == 0:
break
for r in range(n):
cin[r] = eval(input())
ans = 0
for r in range(n):
for c in range(n):
if cin[r][c] == "*":
dp[r][c] = 0
else:
t = dp[r - 1][c - 1]
if dp[r][c - 1] < t:
t = dp[r][c - 1]
if dp[r - 1][c] < t:
t = dp[r - 1][c]
t += 1
dp[r][c] = t
if t > ans:
ans = t
print(ans)
| false | 4.347826 | [
"- if t > 0 and dp[r][c - 1] < t:",
"+ if dp[r][c - 1] < t:",
"- if t > 0 and dp[r - 1][c] < t:",
"+ if dp[r - 1][c] < t:"
] | false | 0.116852 | 0.120423 | 0.970347 | [
"s113043832",
"s078462948"
] |
u511379665 | p03363 | python | s391662756 | s911084439 | 858 | 240 | 99,536 | 39,264 | Accepted | Accepted | 72.03 | from math import factorial
N=list(map(int,input().split()))
A=list(map(int,input().split()))
tmp=[0]
sum=0
for i in range(len(A)):
sum+=A[i]
tmp.append(sum)
tmp.sort()
tmp.append(1.2)
def combinations_count(n, r):
return factorial(n) // (factorial(n - r) * factorial(r))
cnt=1
ans=0
for i in range(0,len(tmp)-1):
if tmp[i]==tmp[i+1]:
cnt+=1
elif tmp[i]!=tmp[i+1]:
if cnt>1:
ans+=combinations_count(cnt,2)
cnt=1
print(ans) | from collections import defaultdict
n=int(eval(input()))
a=list(map(int,input().split()))
ans=0
d=defaultdict(int)
sum_a=0
d[sum_a]+=1
for i in range(n):
sum_a+=a[i]
ans+=d[sum_a]
d[sum_a]+=1
print(ans) | 27 | 13 | 503 | 221 | from math import factorial
N = list(map(int, input().split()))
A = list(map(int, input().split()))
tmp = [0]
sum = 0
for i in range(len(A)):
sum += A[i]
tmp.append(sum)
tmp.sort()
tmp.append(1.2)
def combinations_count(n, r):
return factorial(n) // (factorial(n - r) * factorial(r))
cnt = 1
ans = 0
for i in range(0, len(tmp) - 1):
if tmp[i] == tmp[i + 1]:
cnt += 1
elif tmp[i] != tmp[i + 1]:
if cnt > 1:
ans += combinations_count(cnt, 2)
cnt = 1
print(ans)
| from collections import defaultdict
n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
d = defaultdict(int)
sum_a = 0
d[sum_a] += 1
for i in range(n):
sum_a += a[i]
ans += d[sum_a]
d[sum_a] += 1
print(ans)
| false | 51.851852 | [
"-from math import factorial",
"+from collections import defaultdict",
"-N = list(map(int, input().split()))",
"-A = list(map(int, input().split()))",
"-tmp = [0]",
"-sum = 0",
"-for i in range(len(A)):",
"- sum += A[i]",
"- tmp.append(sum)",
"-tmp.sort()",
"-tmp.append(1.2)",
"-",
"-",
"-def combinations_count(n, r):",
"- return factorial(n) // (factorial(n - r) * factorial(r))",
"-",
"-",
"-cnt = 1",
"+n = int(eval(input()))",
"+a = list(map(int, input().split()))",
"-for i in range(0, len(tmp) - 1):",
"- if tmp[i] == tmp[i + 1]:",
"- cnt += 1",
"- elif tmp[i] != tmp[i + 1]:",
"- if cnt > 1:",
"- ans += combinations_count(cnt, 2)",
"- cnt = 1",
"+d = defaultdict(int)",
"+sum_a = 0",
"+d[sum_a] += 1",
"+for i in range(n):",
"+ sum_a += a[i]",
"+ ans += d[sum_a]",
"+ d[sum_a] += 1"
] | false | 0.042347 | 0.151663 | 0.279218 | [
"s391662756",
"s911084439"
] |
u905582793 | p02782 | python | s592866838 | s918398856 | 1,823 | 225 | 105,200 | 71,664 | Accepted | Accepted | 87.66 | mod = 10**9+7
rng = 2000100
fctr = [1]+[0]*(rng-1)
finv = [1]+[0]*(rng-1)
for i in range(1,rng):
fctr[i] = fctr[i-1]*i%mod
for i in range(1,rng):
finv[i] = pow(fctr[i],mod-2,mod)
def cmb(n,k):
if n<0 or k<0:
return 0
else:
return fctr[n]*finv[n-k]*finv[k]%mod
x1,y1,x2,y2 = list(map(int,input().split()))
print(((cmb(x2+y2+2,x2+1)-cmb(x2+y1+1,y1)-cmb(x1+y2+1,x1)+cmb(x1+y1,x1))%mod)) | mod = 10**9+7
rng = 2000100
fctr = [1]+[0]*(rng-1)
for i in range(1,rng):
fctr[i] = fctr[i-1]*i%mod
def finv(x):
return pow(fctr[x],mod-2,mod)
def cmb(n,k):
if n<0 or k<0:
return 0
else:
return fctr[n]*finv(n-k)*finv(k)%mod
x1,y1,x2,y2 = list(map(int,input().split()))
print(((cmb(x2+y2+2,x2+1)-cmb(x2+y1+1,y1)-cmb(x1+y2+1,x1)+cmb(x1+y1,x1))%mod)) | 16 | 15 | 407 | 370 | mod = 10**9 + 7
rng = 2000100
fctr = [1] + [0] * (rng - 1)
finv = [1] + [0] * (rng - 1)
for i in range(1, rng):
fctr[i] = fctr[i - 1] * i % mod
for i in range(1, rng):
finv[i] = pow(fctr[i], mod - 2, mod)
def cmb(n, k):
if n < 0 or k < 0:
return 0
else:
return fctr[n] * finv[n - k] * finv[k] % mod
x1, y1, x2, y2 = list(map(int, input().split()))
print(
(
(
cmb(x2 + y2 + 2, x2 + 1)
- cmb(x2 + y1 + 1, y1)
- cmb(x1 + y2 + 1, x1)
+ cmb(x1 + y1, x1)
)
% mod
)
)
| mod = 10**9 + 7
rng = 2000100
fctr = [1] + [0] * (rng - 1)
for i in range(1, rng):
fctr[i] = fctr[i - 1] * i % mod
def finv(x):
return pow(fctr[x], mod - 2, mod)
def cmb(n, k):
if n < 0 or k < 0:
return 0
else:
return fctr[n] * finv(n - k) * finv(k) % mod
x1, y1, x2, y2 = list(map(int, input().split()))
print(
(
(
cmb(x2 + y2 + 2, x2 + 1)
- cmb(x2 + y1 + 1, y1)
- cmb(x1 + y2 + 1, x1)
+ cmb(x1 + y1, x1)
)
% mod
)
)
| false | 6.25 | [
"-finv = [1] + [0] * (rng - 1)",
"-for i in range(1, rng):",
"- finv[i] = pow(fctr[i], mod - 2, mod)",
"+",
"+",
"+def finv(x):",
"+ return pow(fctr[x], mod - 2, mod)",
"- return fctr[n] * finv[n - k] * finv[k] % mod",
"+ return fctr[n] * finv(n - k) * finv(k) % mod"
] | false | 0.006608 | 0.926884 | 0.007129 | [
"s592866838",
"s918398856"
] |
u832039789 | p02659 | python | s636698480 | s543971136 | 64 | 27 | 61,740 | 9,960 | Accepted | Accepted | 57.81 | a,b = input().split()
a = int(a)
c,d = b.split('.')
a *= int(c + d)
a //= 100
print(a) | from decimal import Decimal as D
a,b = input().split()
print((int(D(a) * D(b))))
| 6 | 4 | 91 | 83 | a, b = input().split()
a = int(a)
c, d = b.split(".")
a *= int(c + d)
a //= 100
print(a)
| from decimal import Decimal as D
a, b = input().split()
print((int(D(a) * D(b))))
| false | 33.333333 | [
"+from decimal import Decimal as D",
"+",
"-a = int(a)",
"-c, d = b.split(\".\")",
"-a *= int(c + d)",
"-a //= 100",
"-print(a)",
"+print((int(D(a) * D(b))))"
] | false | 0.041119 | 0.043613 | 0.942821 | [
"s636698480",
"s543971136"
] |
u276192130 | p03252 | python | s372289657 | s672008782 | 306 | 158 | 9,776 | 6,716 | Accepted | Accepted | 48.37 | S = list(eval(input()))
T = list(eval(input()))
S2, T2 = [], []
St, Tt = [], []
for i in range(26):
s = chr(ord('a') + i)
St.append(S.count(s))
Tt.append(T.count(s))
for i in range(len(S)):
S2.append(St[ord(S[i]) - ord('a')])
T2.append(Tt[ord(T[i]) - ord('a')])
if S2 != T2:
print('No')
else:
print('Yes')
| s = eval(input())
t = eval(input())
sal = [0 for i in range(26)]
tal = [0 for i in range(26)]
s2, t2 = [], []
for i in range(26):
sal[i] = s.count(chr(ord('a') + i))
tal[i] = t.count(chr(ord('a') + i))
for i in range(len(s)):
s2.append(sal[ord(s[i]) - ord('a')])
t2.append(tal[ord(t[i]) - ord('a')])
if s2 != t2:
print('No')
else:
print('Yes')
| 15 | 15 | 336 | 370 | S = list(eval(input()))
T = list(eval(input()))
S2, T2 = [], []
St, Tt = [], []
for i in range(26):
s = chr(ord("a") + i)
St.append(S.count(s))
Tt.append(T.count(s))
for i in range(len(S)):
S2.append(St[ord(S[i]) - ord("a")])
T2.append(Tt[ord(T[i]) - ord("a")])
if S2 != T2:
print("No")
else:
print("Yes")
| s = eval(input())
t = eval(input())
sal = [0 for i in range(26)]
tal = [0 for i in range(26)]
s2, t2 = [], []
for i in range(26):
sal[i] = s.count(chr(ord("a") + i))
tal[i] = t.count(chr(ord("a") + i))
for i in range(len(s)):
s2.append(sal[ord(s[i]) - ord("a")])
t2.append(tal[ord(t[i]) - ord("a")])
if s2 != t2:
print("No")
else:
print("Yes")
| false | 0 | [
"-S = list(eval(input()))",
"-T = list(eval(input()))",
"-S2, T2 = [], []",
"-St, Tt = [], []",
"+s = eval(input())",
"+t = eval(input())",
"+sal = [0 for i in range(26)]",
"+tal = [0 for i in range(26)]",
"+s2, t2 = [], []",
"- s = chr(ord(\"a\") + i)",
"- St.append(S.count(s))",
"- Tt.append(T.count(s))",
"-for i in range(len(S)):",
"- S2.append(St[ord(S[i]) - ord(\"a\")])",
"- T2.append(Tt[ord(T[i]) - ord(\"a\")])",
"-if S2 != T2:",
"+ sal[i] = s.count(chr(ord(\"a\") + i))",
"+ tal[i] = t.count(chr(ord(\"a\") + i))",
"+for i in range(len(s)):",
"+ s2.append(sal[ord(s[i]) - ord(\"a\")])",
"+ t2.append(tal[ord(t[i]) - ord(\"a\")])",
"+if s2 != t2:"
] | false | 0.037416 | 0.065892 | 0.567843 | [
"s372289657",
"s672008782"
] |
u503228842 | p03575 | python | s039386262 | s117215592 | 40 | 20 | 3,700 | 3,064 | Accepted | Accepted | 50 | import copy
N,M = list(map(int,input().split()))
graph = [[] for _ in range(N)]
edges = []
for _ in range(M):
a,b = list(map(int,input().split()))
graph[a-1].append(b-1)
graph[b-1].append(a-1)
edges.append([a-1,b-1])
def dfs(G,v):
seen[v] = True
#print(seen)
for nv in G[v]:
#print(nv)
if seen[nv]:
continue
dfs(G,nv)
ans = 0
for edge in edges:
seen = [False] * N
copied_graph = copy.deepcopy(graph)
copied_graph[edge[0]].remove(edge[1])
copied_graph[edge[1]].remove(edge[0])
dfs(copied_graph,0)
if not all(seen):
ans += 1
print(ans) | N,M = list(map(int,input().split()))
def find(x):
if par[x] < 0:
return x
else:
par[x] = find(par[x])
return par[x]
def unite(x,y):
x = find(x)
y = find(y)
if x == y:
return False
else:
if par[x] > par[y]:
x,y = y,x
par[x] += par[y]
par[y] = x
return True
def same(x,y):
return find(x) == find(y)
def size(x):
return -par[find(x)]
a = [0]*M
b = [0]*M
for i in range(M):
a[i], b[i] = list(map(int,input().split()))
a[i] -= 1
b[i] -= 1
# 一つの辺以外を繋いでその辺の両端の点が同じ集合に属していたらその辺は橋ではない
ans = 0
for i in range(M):
par = [-1] * (N + 1)
for j in range(M):
if i != j:
unite(a[j],b[j])
if not same(a[i],b[i]):
ans += 1
print(ans)
| 31 | 47 | 651 | 818 | import copy
N, M = list(map(int, input().split()))
graph = [[] for _ in range(N)]
edges = []
for _ in range(M):
a, b = list(map(int, input().split()))
graph[a - 1].append(b - 1)
graph[b - 1].append(a - 1)
edges.append([a - 1, b - 1])
def dfs(G, v):
seen[v] = True
# print(seen)
for nv in G[v]:
# print(nv)
if seen[nv]:
continue
dfs(G, nv)
ans = 0
for edge in edges:
seen = [False] * N
copied_graph = copy.deepcopy(graph)
copied_graph[edge[0]].remove(edge[1])
copied_graph[edge[1]].remove(edge[0])
dfs(copied_graph, 0)
if not all(seen):
ans += 1
print(ans)
| N, M = list(map(int, input().split()))
def find(x):
if par[x] < 0:
return x
else:
par[x] = find(par[x])
return par[x]
def unite(x, y):
x = find(x)
y = find(y)
if x == y:
return False
else:
if par[x] > par[y]:
x, y = y, x
par[x] += par[y]
par[y] = x
return True
def same(x, y):
return find(x) == find(y)
def size(x):
return -par[find(x)]
a = [0] * M
b = [0] * M
for i in range(M):
a[i], b[i] = list(map(int, input().split()))
a[i] -= 1
b[i] -= 1
# 一つの辺以外を繋いでその辺の両端の点が同じ集合に属していたらその辺は橋ではない
ans = 0
for i in range(M):
par = [-1] * (N + 1)
for j in range(M):
if i != j:
unite(a[j], b[j])
if not same(a[i], b[i]):
ans += 1
print(ans)
| false | 34.042553 | [
"-import copy",
"-",
"-graph = [[] for _ in range(N)]",
"-edges = []",
"-for _ in range(M):",
"- a, b = list(map(int, input().split()))",
"- graph[a - 1].append(b - 1)",
"- graph[b - 1].append(a - 1)",
"- edges.append([a - 1, b - 1])",
"-def dfs(G, v):",
"- seen[v] = True",
"- # print(seen)",
"- for nv in G[v]:",
"- # print(nv)",
"- if seen[nv]:",
"- continue",
"- dfs(G, nv)",
"+def find(x):",
"+ if par[x] < 0:",
"+ return x",
"+ else:",
"+ par[x] = find(par[x])",
"+ return par[x]",
"+def unite(x, y):",
"+ x = find(x)",
"+ y = find(y)",
"+ if x == y:",
"+ return False",
"+ else:",
"+ if par[x] > par[y]:",
"+ x, y = y, x",
"+ par[x] += par[y]",
"+ par[y] = x",
"+ return True",
"+",
"+",
"+def same(x, y):",
"+ return find(x) == find(y)",
"+",
"+",
"+def size(x):",
"+ return -par[find(x)]",
"+",
"+",
"+a = [0] * M",
"+b = [0] * M",
"+for i in range(M):",
"+ a[i], b[i] = list(map(int, input().split()))",
"+ a[i] -= 1",
"+ b[i] -= 1",
"+# 一つの辺以外を繋いでその辺の両端の点が同じ集合に属していたらその辺は橋ではない",
"-for edge in edges:",
"- seen = [False] * N",
"- copied_graph = copy.deepcopy(graph)",
"- copied_graph[edge[0]].remove(edge[1])",
"- copied_graph[edge[1]].remove(edge[0])",
"- dfs(copied_graph, 0)",
"- if not all(seen):",
"+for i in range(M):",
"+ par = [-1] * (N + 1)",
"+ for j in range(M):",
"+ if i != j:",
"+ unite(a[j], b[j])",
"+ if not same(a[i], b[i]):"
] | false | 0.084102 | 0.038861 | 2.164195 | [
"s039386262",
"s117215592"
] |
u734252743 | p02659 | python | s474370644 | s087465245 | 24 | 22 | 8,984 | 9,116 | Accepted | Accepted | 8.33 | a, b = list(map(float, input().split()))
print((int(a)*int(b*1000)//1000))
| a, b = list(map(float, input().split()))
a = int(a)
b = int(float(b)*1000)
r = int((a*b)//1000)
print(r)
| 2 | 5 | 68 | 103 | a, b = list(map(float, input().split()))
print((int(a) * int(b * 1000) // 1000))
| a, b = list(map(float, input().split()))
a = int(a)
b = int(float(b) * 1000)
r = int((a * b) // 1000)
print(r)
| false | 60 | [
"-print((int(a) * int(b * 1000) // 1000))",
"+a = int(a)",
"+b = int(float(b) * 1000)",
"+r = int((a * b) // 1000)",
"+print(r)"
] | false | 0.116604 | 0.041006 | 2.843557 | [
"s474370644",
"s087465245"
] |
u115682115 | p03854 | python | s976653749 | s630264024 | 66 | 18 | 3,316 | 3,188 | Accepted | Accepted | 72.73 | S = eval(input())
SR = S[::-1]
temp =['dream','dreamer','erase','eraser']
T=""
j=0
count=0
while j<=10**5//5:
j +=1
for i in temp:
if i[::-1] == SR[count:len(i)+count]:
count+=len(i)
T+=i[::-1]
if SR==T:
print('YES')
exit()
print('NO') | a = ["eraser", "erase", "dreamer", "dream"]
s = eval(input())
for i in range(4):
s = s.replace(a[i], "")
print((['NO','YES'][s==""]))
| 16 | 5 | 328 | 134 | S = eval(input())
SR = S[::-1]
temp = ["dream", "dreamer", "erase", "eraser"]
T = ""
j = 0
count = 0
while j <= 10**5 // 5:
j += 1
for i in temp:
if i[::-1] == SR[count : len(i) + count]:
count += len(i)
T += i[::-1]
if SR == T:
print("YES")
exit()
print("NO")
| a = ["eraser", "erase", "dreamer", "dream"]
s = eval(input())
for i in range(4):
s = s.replace(a[i], "")
print((["NO", "YES"][s == ""]))
| false | 68.75 | [
"-S = eval(input())",
"-SR = S[::-1]",
"-temp = [\"dream\", \"dreamer\", \"erase\", \"eraser\"]",
"-T = \"\"",
"-j = 0",
"-count = 0",
"-while j <= 10**5 // 5:",
"- j += 1",
"- for i in temp:",
"- if i[::-1] == SR[count : len(i) + count]:",
"- count += len(i)",
"- T += i[::-1]",
"- if SR == T:",
"- print(\"YES\")",
"- exit()",
"-print(\"NO\")",
"+a = [\"eraser\", \"erase\", \"dreamer\", \"dream\"]",
"+s = eval(input())",
"+for i in range(4):",
"+ s = s.replace(a[i], \"\")",
"+print(([\"NO\", \"YES\"][s == \"\"]))"
] | false | 0.052968 | 0.041624 | 1.272533 | [
"s976653749",
"s630264024"
] |
u761320129 | p03937 | python | s314075806 | s111404399 | 22 | 18 | 3,316 | 3,064 | Accepted | Accepted | 18.18 | from collections import Counter
H,W = list(map(int,input().split()))
src = [eval(input()) for i in range(H)]
ctr = Counter()
for row in src:
ctr.update(row)
print(('Possible' if ctr['#'] == H+W-1 else 'Impossible')) | H,W = list(map(int,input().split()))
src = [eval(input()) for i in range(H)]
x = y = p = 0
while x < W-1 or y < H-1:
if x < W-1 and src[y][x+1] == '#':
p += 1
x += 1
elif y < H-1 and src[y+1][x] == '#':
p += 1
y += 1
else:
print('Impossible')
exit()
c = 0
for row in src:
c += row.count('#')
print(('Possible' if p+1==c else 'Impossible')) | 7 | 19 | 211 | 409 | from collections import Counter
H, W = list(map(int, input().split()))
src = [eval(input()) for i in range(H)]
ctr = Counter()
for row in src:
ctr.update(row)
print(("Possible" if ctr["#"] == H + W - 1 else "Impossible"))
| H, W = list(map(int, input().split()))
src = [eval(input()) for i in range(H)]
x = y = p = 0
while x < W - 1 or y < H - 1:
if x < W - 1 and src[y][x + 1] == "#":
p += 1
x += 1
elif y < H - 1 and src[y + 1][x] == "#":
p += 1
y += 1
else:
print("Impossible")
exit()
c = 0
for row in src:
c += row.count("#")
print(("Possible" if p + 1 == c else "Impossible"))
| false | 63.157895 | [
"-from collections import Counter",
"-",
"-ctr = Counter()",
"+x = y = p = 0",
"+while x < W - 1 or y < H - 1:",
"+ if x < W - 1 and src[y][x + 1] == \"#\":",
"+ p += 1",
"+ x += 1",
"+ elif y < H - 1 and src[y + 1][x] == \"#\":",
"+ p += 1",
"+ y += 1",
"+ else:",
"+ print(\"Impossible\")",
"+ exit()",
"+c = 0",
"- ctr.update(row)",
"-print((\"Possible\" if ctr[\"#\"] == H + W - 1 else \"Impossible\"))",
"+ c += row.count(\"#\")",
"+print((\"Possible\" if p + 1 == c else \"Impossible\"))"
] | false | 0.048564 | 0.049121 | 0.988657 | [
"s314075806",
"s111404399"
] |
u992910889 | p03087 | python | s642269115 | s802647182 | 414 | 358 | 16,628 | 58,376 | Accepted | Accepted | 13.53 | # import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
# import sys
# sys.setrecursionlimit(10**9)
def resolve():
N,Q=list(map(int,input().split()))
S=str(eval(input()))
L, R = [0] * Q, [0] * Q
for i in range(Q):
L[i], R[i] = list(map(int, input().split()))
L[i], R[i] = L[i]-1, R[i]-1
A=[0]*N
for i in range(N-1):
if S[i:i+2]=='AC':
A[i]=1
B = [0] + A
B = list(accumulate(B)) # 累積和を格納したリスト作成
# この問題は長さが1-Nの連続部分の和の最大値を出せというものなので以下の通り
for j in range(Q):
ans=B[R[j]]-B[L[j]]
print(ans)
resolve() | from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np # Pythonのみ!
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components # Pythonのみ!
# ↑cf. https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()
def resolve():
N,Q=list(map(int,input().split()))
S=list(eval(input()))
res=[0]*N
temp=False
for i in range(N):
if S[i]=='A':
temp=True
elif temp==True and S[i]=='C':
res[i-1]=1
temp=False
else: temp=False
B = [0] + res
# 累積和を格納したリスト.A[l:r]の総和はB[r] - B[l]
B = list(accumulate(B))
for i in range(Q):
l,r=list(map(int,input().split()))
print((B[r-1]-B[l-1]))
resolve() | 36 | 40 | 831 | 986 | # import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
from itertools import (
accumulate,
permutations,
combinations,
combinations_with_replacement,
groupby,
product,
)
# import math
# import numpy as np
# import sys
# sys.setrecursionlimit(10**9)
def resolve():
N, Q = list(map(int, input().split()))
S = str(eval(input()))
L, R = [0] * Q, [0] * Q
for i in range(Q):
L[i], R[i] = list(map(int, input().split()))
L[i], R[i] = L[i] - 1, R[i] - 1
A = [0] * N
for i in range(N - 1):
if S[i : i + 2] == "AC":
A[i] = 1
B = [0] + A
B = list(accumulate(B)) # 累積和を格納したリスト作成
# この問題は長さが1-Nの連続部分の和の最大値を出せというものなので以下の通り
for j in range(Q):
ans = B[R[j]] - B[L[j]]
print(ans)
resolve()
| from itertools import (
accumulate,
permutations,
combinations,
combinations_with_replacement,
groupby,
product,
)
# import math
# import numpy as np # Pythonのみ!
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components # Pythonのみ!
# ↑cf. https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10**5 + 10)
def input():
return sys.stdin.readline().strip()
def resolve():
N, Q = list(map(int, input().split()))
S = list(eval(input()))
res = [0] * N
temp = False
for i in range(N):
if S[i] == "A":
temp = True
elif temp == True and S[i] == "C":
res[i - 1] = 1
temp = False
else:
temp = False
B = [0] + res
# 累積和を格納したリスト.A[l:r]の総和はB[r] - B[l]
B = list(accumulate(B))
for i in range(Q):
l, r = list(map(int, input().split()))
print((B[r - 1] - B[l - 1]))
resolve()
| false | 10 | [
"-# import bisect",
"-# from collections import Counter, deque",
"-# import copy",
"-# from fractions import gcd",
"-# from functools import reduce",
"-# import numpy as np",
"-# import sys",
"-# sys.setrecursionlimit(10**9)",
"+# import numpy as np # Pythonのみ!",
"+# from operator import xor",
"+# import re",
"+# from scipy.sparse.csgraph import connected_components # Pythonのみ!",
"+# ↑cf. https://note.nkmk.me/python-scipy-connected-components/",
"+# from scipy.sparse import csr_matrix",
"+# import string",
"+import sys",
"+",
"+sys.setrecursionlimit(10**5 + 10)",
"+",
"+",
"+def input():",
"+ return sys.stdin.readline().strip()",
"+",
"+",
"- S = str(eval(input()))",
"- L, R = [0] * Q, [0] * Q",
"+ S = list(eval(input()))",
"+ res = [0] * N",
"+ temp = False",
"+ for i in range(N):",
"+ if S[i] == \"A\":",
"+ temp = True",
"+ elif temp == True and S[i] == \"C\":",
"+ res[i - 1] = 1",
"+ temp = False",
"+ else:",
"+ temp = False",
"+ B = [0] + res",
"+ # 累積和を格納したリスト.A[l:r]の総和はB[r] - B[l]",
"+ B = list(accumulate(B))",
"- L[i], R[i] = list(map(int, input().split()))",
"- L[i], R[i] = L[i] - 1, R[i] - 1",
"- A = [0] * N",
"- for i in range(N - 1):",
"- if S[i : i + 2] == \"AC\":",
"- A[i] = 1",
"- B = [0] + A",
"- B = list(accumulate(B)) # 累積和を格納したリスト作成",
"- # この問題は長さが1-Nの連続部分の和の最大値を出せというものなので以下の通り",
"- for j in range(Q):",
"- ans = B[R[j]] - B[L[j]]",
"- print(ans)",
"+ l, r = list(map(int, input().split()))",
"+ print((B[r - 1] - B[l - 1]))"
] | false | 0.040721 | 0.064998 | 0.626497 | [
"s642269115",
"s802647182"
] |
u462329577 | p03387 | python | s428334515 | s951535201 | 190 | 17 | 38,384 | 3,060 | Accepted | Accepted | 91.05 | #!/usr/bin/env python3
#最終上体がわかれば回数fin*3 - (a+b+c) //2
a =list(map(int,input().split()))
a.sort()
# maxがfinにならないのは、a[0]-1[1]が奇数の時
if (a[1] -a[0])%2 == 0:
print(((a[-1]*3-sum(a))//2))
else:
print(((a[-1]*3+3-sum(a))//2))
"""
x = a[-1]-a[1]
y = a[1] -a[0]
def dist(n):
if n % 2 == 0: return n//2
else: return n//2+2
print(min(2*x+y,dist(y)+x,dist(x+y)+dist(x)))""" | a, b, c = list(map(int, input().split()))
s = [a, b, c]
s.sort()
if (s[2] * 2 - s[0] - s[1]) % 2 == 0:
print(((3 * s[2] - sum(s)) // 2))
else:
print(((3 * s[2] + 3 - sum(s)) // 2))
| 16 | 8 | 389 | 187 | #!/usr/bin/env python3
# 最終上体がわかれば回数fin*3 - (a+b+c) //2
a = list(map(int, input().split()))
a.sort()
# maxがfinにならないのは、a[0]-1[1]が奇数の時
if (a[1] - a[0]) % 2 == 0:
print(((a[-1] * 3 - sum(a)) // 2))
else:
print(((a[-1] * 3 + 3 - sum(a)) // 2))
"""
x = a[-1]-a[1]
y = a[1] -a[0]
def dist(n):
if n % 2 == 0: return n//2
else: return n//2+2
print(min(2*x+y,dist(y)+x,dist(x+y)+dist(x)))"""
| a, b, c = list(map(int, input().split()))
s = [a, b, c]
s.sort()
if (s[2] * 2 - s[0] - s[1]) % 2 == 0:
print(((3 * s[2] - sum(s)) // 2))
else:
print(((3 * s[2] + 3 - sum(s)) // 2))
| false | 50 | [
"-#!/usr/bin/env python3",
"-# 最終上体がわかれば回数fin*3 - (a+b+c) //2",
"-a = list(map(int, input().split()))",
"-a.sort()",
"-# maxがfinにならないのは、a[0]-1[1]が奇数の時",
"-if (a[1] - a[0]) % 2 == 0:",
"- print(((a[-1] * 3 - sum(a)) // 2))",
"+a, b, c = list(map(int, input().split()))",
"+s = [a, b, c]",
"+s.sort()",
"+if (s[2] * 2 - s[0] - s[1]) % 2 == 0:",
"+ print(((3 * s[2] - sum(s)) // 2))",
"- print(((a[-1] * 3 + 3 - sum(a)) // 2))",
"-\"\"\"",
"-x = a[-1]-a[1]",
"-y = a[1] -a[0]",
"-def dist(n):",
"- if n % 2 == 0: return n//2",
"- else: return n//2+2",
"-print(min(2*x+y,dist(y)+x,dist(x+y)+dist(x)))\"\"\"",
"+ print(((3 * s[2] + 3 - sum(s)) // 2))"
] | false | 0.082148 | 0.063402 | 1.295675 | [
"s428334515",
"s951535201"
] |
u013513417 | p03835 | python | s094929549 | s612896827 | 1,843 | 1,400 | 2,940 | 9,172 | Accepted | Accepted | 24.04 | K,S=list(map(int,input().split()))
count=0
for x in range(K+1):
for y in range(K+1):
z=S-x-y
if z>=0 and z<=K:
count+=1
print(count) | K,S=list(map(int,input().split()))
count=0
for i in range(K+1):
for j in range(K+1):
if S-(i+j)<=K and S-(i+j)>=0:
count+=1
print(count) | 8 | 10 | 165 | 174 | K, S = list(map(int, input().split()))
count = 0
for x in range(K + 1):
for y in range(K + 1):
z = S - x - y
if z >= 0 and z <= K:
count += 1
print(count)
| K, S = list(map(int, input().split()))
count = 0
for i in range(K + 1):
for j in range(K + 1):
if S - (i + j) <= K and S - (i + j) >= 0:
count += 1
print(count)
| false | 20 | [
"-for x in range(K + 1):",
"- for y in range(K + 1):",
"- z = S - x - y",
"- if z >= 0 and z <= K:",
"+for i in range(K + 1):",
"+ for j in range(K + 1):",
"+ if S - (i + j) <= K and S - (i + j) >= 0:"
] | false | 0.085359 | 0.038213 | 2.233755 | [
"s094929549",
"s612896827"
] |
u863442865 | p03805 | python | s903042232 | s106996808 | 45 | 28 | 3,316 | 3,316 | Accepted | Accepted | 37.78 | def main():
import sys
#input = sys.stdin.readline
sys.setrecursionlimit(10000000)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations
#from itertools import accumulate, product, permutations
from math import floor, ceil
#mod = 1000000007
n,m = list(map(int, input().split()))
edge = [list(map(int, input().split())) for _ in range(m)]
res = []
visited = [0]*n
def dfs(node):
visited[node-1]=1
if sum(visited)==n:
res.append(1)
return
for x,y in edge:
if x == node:
if not visited[y-1]:
dfs(y)
visited[y-1] = 0
if y == node:
if not visited[x-1]:
dfs(x)
visited[x-1] = 0
for a,b in edge:
if a==1:
dfs(a)
print((len(res)))
exit()
if __name__ == '__main__':
main() | '''
頂点1から全頂点通る一筆書きが何個あるか
頂点数(N)は最大で8なので道順を全列挙して調べてもいける
'''
def main():
import sys
#input = sys.stdin.readline
sys.setrecursionlimit(10000000)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations
#from itertools import accumulate, product, permutations
from math import floor, ceil
#mod = 1000000007
N,M = list(map(int, input().split()))
g = [[] for _ in range(N)]
for _ in range(M):
a,b = list(map(int, input().split()))
g[a-1].append(b-1)
g[b-1].append(a-1)
res = []
visited = [0]*N
def dfs(node):
visited[node]=1
if sum(visited)==N:
res.append(1)
return
for n_node in g[node]:
if not visited[n_node]:
dfs(n_node)
visited[n_node] = 0
dfs(0)
print((len(res)))
# My
# n,m = map(int, input().split())
# edge = [list(map(int, input().split())) for _ in range(m)]
# res = []
# visited = [0]*n
# def dfs(node):
# visited[node-1]=1
# if sum(visited)==n:
# res.append(1)
# return
# for x,y in edge:
# if x == node:
# if not visited[y-1]:
# dfs(y)
# visited[y-1] = 0
# if y == node:
# if not visited[x-1]:
# dfs(x)
# visited[x-1] = 0
# for a,b in edge:
# if a==1:
# dfs(a)
# print(len(res))
# exit()
# if b==1:
# dfs(b)
# print(len(res))
# exit()
if __name__ == '__main__':
main() | 40 | 73 | 1,048 | 1,798 | def main():
import sys
# input = sys.stdin.readline
sys.setrecursionlimit(10000000)
from collections import Counter, deque
# from collections import defaultdict
from itertools import combinations
# from itertools import accumulate, product, permutations
from math import floor, ceil
# mod = 1000000007
n, m = list(map(int, input().split()))
edge = [list(map(int, input().split())) for _ in range(m)]
res = []
visited = [0] * n
def dfs(node):
visited[node - 1] = 1
if sum(visited) == n:
res.append(1)
return
for x, y in edge:
if x == node:
if not visited[y - 1]:
dfs(y)
visited[y - 1] = 0
if y == node:
if not visited[x - 1]:
dfs(x)
visited[x - 1] = 0
for a, b in edge:
if a == 1:
dfs(a)
print((len(res)))
exit()
if __name__ == "__main__":
main()
| """
頂点1から全頂点通る一筆書きが何個あるか
頂点数(N)は最大で8なので道順を全列挙して調べてもいける
"""
def main():
import sys
# input = sys.stdin.readline
sys.setrecursionlimit(10000000)
from collections import Counter, deque
# from collections import defaultdict
from itertools import combinations
# from itertools import accumulate, product, permutations
from math import floor, ceil
# mod = 1000000007
N, M = list(map(int, input().split()))
g = [[] for _ in range(N)]
for _ in range(M):
a, b = list(map(int, input().split()))
g[a - 1].append(b - 1)
g[b - 1].append(a - 1)
res = []
visited = [0] * N
def dfs(node):
visited[node] = 1
if sum(visited) == N:
res.append(1)
return
for n_node in g[node]:
if not visited[n_node]:
dfs(n_node)
visited[n_node] = 0
dfs(0)
print((len(res)))
# My
# n,m = map(int, input().split())
# edge = [list(map(int, input().split())) for _ in range(m)]
# res = []
# visited = [0]*n
# def dfs(node):
# visited[node-1]=1
# if sum(visited)==n:
# res.append(1)
# return
# for x,y in edge:
# if x == node:
# if not visited[y-1]:
# dfs(y)
# visited[y-1] = 0
# if y == node:
# if not visited[x-1]:
# dfs(x)
# visited[x-1] = 0
# for a,b in edge:
# if a==1:
# dfs(a)
# print(len(res))
# exit()
# if b==1:
# dfs(b)
# print(len(res))
# exit()
if __name__ == "__main__":
main()
| false | 45.205479 | [
"+\"\"\"",
"+頂点1から全頂点通る一筆書きが何個あるか",
"+頂点数(N)は最大で8なので道順を全列挙して調べてもいける",
"+\"\"\"",
"+",
"+",
"- n, m = list(map(int, input().split()))",
"- edge = [list(map(int, input().split())) for _ in range(m)]",
"+ N, M = list(map(int, input().split()))",
"+ g = [[] for _ in range(N)]",
"+ for _ in range(M):",
"+ a, b = list(map(int, input().split()))",
"+ g[a - 1].append(b - 1)",
"+ g[b - 1].append(a - 1)",
"- visited = [0] * n",
"+ visited = [0] * N",
"- visited[node - 1] = 1",
"- if sum(visited) == n:",
"+ visited[node] = 1",
"+ if sum(visited) == N:",
"- for x, y in edge:",
"- if x == node:",
"- if not visited[y - 1]:",
"- dfs(y)",
"- visited[y - 1] = 0",
"- if y == node:",
"- if not visited[x - 1]:",
"- dfs(x)",
"- visited[x - 1] = 0",
"+ for n_node in g[node]:",
"+ if not visited[n_node]:",
"+ dfs(n_node)",
"+ visited[n_node] = 0",
"- for a, b in edge:",
"- if a == 1:",
"- dfs(a)",
"- print((len(res)))",
"- exit()",
"+ dfs(0)",
"+ print((len(res)))",
"+ # My",
"+ # n,m = map(int, input().split())",
"+ # edge = [list(map(int, input().split())) for _ in range(m)]",
"+ # res = []",
"+ # visited = [0]*n",
"+ # def dfs(node):",
"+ # visited[node-1]=1",
"+ # if sum(visited)==n:",
"+ # res.append(1)",
"+ # return",
"+ # for x,y in edge:",
"+ # if x == node:",
"+ # if not visited[y-1]:",
"+ # dfs(y)",
"+ # visited[y-1] = 0",
"+ # if y == node:",
"+ # if not visited[x-1]:",
"+ # dfs(x)",
"+ # visited[x-1] = 0",
"+ # for a,b in edge:",
"+ # if a==1:",
"+ # dfs(a)",
"+ # print(len(res))",
"+ # exit()",
"+ # if b==1:",
"+ # dfs(b)",
"+ # print(len(res))",
"+ # exit()"
] | false | 0.099667 | 0.04057 | 2.456687 | [
"s903042232",
"s106996808"
] |
u925364229 | p03240 | python | s371983766 | s071155962 | 248 | 210 | 43,248 | 43,248 | Accepted | Accepted | 15.32 | N = int(eval(input()))
x,y,h = [0]*N,[0]*N,[0]*N
j = -1
for i in range(N):
x[i],y[i],h[i] = list(map(int,input().split(" ")))
if h[i] != 0:
j = i
H = 1
if j == (-1):
for cx in range(0,101):
for cy in range(0,101):
for i in range(N):
H = min(H,(abs(x[i]-cx) + abs(y[i]-cy)))
if H > 0:
print(("{0} {1} {2}".format(cx,cy,H)))
exit(0)
for cx in range(0,101):
for cy in range(0,101):
H = h[j] + abs(x[j]-cx) + abs(y[j]-cy)
flg = True
for i in range(N):
if (h[i] == 0 and ((abs(x[i]-cx) + abs(y[i]-cy))) < H):
flg = False
break
if (h[i] != 0 and H != (h[i] + abs(x[i]-cx) + abs(y[i]-cy))):
flg = False
break
if flg:
print(("{0} {1} {2}".format(cx,cy,H)))
exit(0)
| N = int(eval(input()))
x,y,h = [0]*N,[0]*N,[0]*N
j = -1
for i in range(N):
x[i],y[i],h[i] = list(map(int,input().split(" ")))
if h[i] != 0:
j = i
for cx in range(0,101):
for cy in range(0,101):
H = h[j] + abs(x[j]-cx) + abs(y[j]-cy)
flg = True
for i in range(N):
if (h[i] == 0 and ((abs(x[i]-cx) + abs(y[i]-cy))) < H):
flg = False
break
if (h[i] != 0 and H != (h[i] + abs(x[i]-cx) + abs(y[i]-cy))):
flg = False
break
if flg:
print(("{0} {1} {2}".format(cx,cy,H)))
exit(0)
| 34 | 23 | 936 | 647 | N = int(eval(input()))
x, y, h = [0] * N, [0] * N, [0] * N
j = -1
for i in range(N):
x[i], y[i], h[i] = list(map(int, input().split(" ")))
if h[i] != 0:
j = i
H = 1
if j == (-1):
for cx in range(0, 101):
for cy in range(0, 101):
for i in range(N):
H = min(H, (abs(x[i] - cx) + abs(y[i] - cy)))
if H > 0:
print(("{0} {1} {2}".format(cx, cy, H)))
exit(0)
for cx in range(0, 101):
for cy in range(0, 101):
H = h[j] + abs(x[j] - cx) + abs(y[j] - cy)
flg = True
for i in range(N):
if h[i] == 0 and ((abs(x[i] - cx) + abs(y[i] - cy))) < H:
flg = False
break
if h[i] != 0 and H != (h[i] + abs(x[i] - cx) + abs(y[i] - cy)):
flg = False
break
if flg:
print(("{0} {1} {2}".format(cx, cy, H)))
exit(0)
| N = int(eval(input()))
x, y, h = [0] * N, [0] * N, [0] * N
j = -1
for i in range(N):
x[i], y[i], h[i] = list(map(int, input().split(" ")))
if h[i] != 0:
j = i
for cx in range(0, 101):
for cy in range(0, 101):
H = h[j] + abs(x[j] - cx) + abs(y[j] - cy)
flg = True
for i in range(N):
if h[i] == 0 and ((abs(x[i] - cx) + abs(y[i] - cy))) < H:
flg = False
break
if h[i] != 0 and H != (h[i] + abs(x[i] - cx) + abs(y[i] - cy)):
flg = False
break
if flg:
print(("{0} {1} {2}".format(cx, cy, H)))
exit(0)
| false | 32.352941 | [
"-H = 1",
"-if j == (-1):",
"- for cx in range(0, 101):",
"- for cy in range(0, 101):",
"- for i in range(N):",
"- H = min(H, (abs(x[i] - cx) + abs(y[i] - cy)))",
"- if H > 0:",
"- print((\"{0} {1} {2}\".format(cx, cy, H)))",
"- exit(0)"
] | false | 0.049999 | 0.048844 | 1.023637 | [
"s371983766",
"s071155962"
] |
u057415180 | p03031 | python | s568213004 | s938830176 | 33 | 27 | 3,064 | 3,064 | Accepted | Accepted | 18.18 | def main():
n, m = list(map(int, input().split()))
g = [[-1]*n for _ in range(m)]
for i in range(m):
s = list(map(int, input().split()))
for j in s[1:]:
g[i][j-1] = 1
p = list(map(int, input().split()))
ans = 0
for i in range(2**n):
s = [0]*n
for j in range(n):
if ((i >> j) & 1):
s[j] = 1
flag = True
for j in range(m):
cnt = 0
for k in range(n):
if g[j][k] == s[k]:
cnt += 1
if cnt % 2 != p[j]:
flag = False
if flag:
ans += 1
print(ans)
if __name__ == '__main__':
main() | def main():
n, m = list(map(int,input().split()))
light = [[0]*n for _ in range(m)]
for i in range(m):
kk = list(map(int, input().split()))
k = kk.pop(0)
for j in range(k):
light[i][kk[j]-1] = 1
p = list(map(int, input().split()))
ans = 0
for i in range(2**n): # switchのbit
sw = [0]*n
for j in range(n):
if ((i >> j) & 1):
sw[j] = 1
flag = True
for j in range(m):
cnt = 0
for k in range(n):
if sw[k] == 1 and light[j][k] == 1:
cnt += 1
if cnt % 2 != p[j]:
flag = False
break
if flag:
ans += 1
print(ans)
if __name__ == '__main__':
main() | 31 | 33 | 621 | 697 | def main():
n, m = list(map(int, input().split()))
g = [[-1] * n for _ in range(m)]
for i in range(m):
s = list(map(int, input().split()))
for j in s[1:]:
g[i][j - 1] = 1
p = list(map(int, input().split()))
ans = 0
for i in range(2**n):
s = [0] * n
for j in range(n):
if (i >> j) & 1:
s[j] = 1
flag = True
for j in range(m):
cnt = 0
for k in range(n):
if g[j][k] == s[k]:
cnt += 1
if cnt % 2 != p[j]:
flag = False
if flag:
ans += 1
print(ans)
if __name__ == "__main__":
main()
| def main():
n, m = list(map(int, input().split()))
light = [[0] * n for _ in range(m)]
for i in range(m):
kk = list(map(int, input().split()))
k = kk.pop(0)
for j in range(k):
light[i][kk[j] - 1] = 1
p = list(map(int, input().split()))
ans = 0
for i in range(2**n): # switchのbit
sw = [0] * n
for j in range(n):
if (i >> j) & 1:
sw[j] = 1
flag = True
for j in range(m):
cnt = 0
for k in range(n):
if sw[k] == 1 and light[j][k] == 1:
cnt += 1
if cnt % 2 != p[j]:
flag = False
break
if flag:
ans += 1
print(ans)
if __name__ == "__main__":
main()
| false | 6.060606 | [
"- g = [[-1] * n for _ in range(m)]",
"+ light = [[0] * n for _ in range(m)]",
"- s = list(map(int, input().split()))",
"- for j in s[1:]:",
"- g[i][j - 1] = 1",
"+ kk = list(map(int, input().split()))",
"+ k = kk.pop(0)",
"+ for j in range(k):",
"+ light[i][kk[j] - 1] = 1",
"- for i in range(2**n):",
"- s = [0] * n",
"+ for i in range(2**n): # switchのbit",
"+ sw = [0] * n",
"- s[j] = 1",
"+ sw[j] = 1",
"- if g[j][k] == s[k]:",
"+ if sw[k] == 1 and light[j][k] == 1:",
"+ break"
] | false | 0.050041 | 0.114474 | 0.437142 | [
"s568213004",
"s938830176"
] |
u093607836 | p00424 | python | s639358040 | s937675850 | 100 | 90 | 9,628 | 10,336 | Accepted | Accepted | 10 | import string
n = int(input())
while n != 0:
f = []
t = []
for i in range(n):
l = input().split()
f.append(l[0])
t.append(l[1])
d = string.maketrans(''.join(f), ''.join(t))
s = []
for i in range(int(input())):
s.append(input().strip())
print(''.join(s).translate(d))
n = int(input()) | import string
n = int(input())
while n != 0:
l = [input().split() for i in range(n)]
f = [i for i,j in l]
t = [j for i,j in l]
d = string.maketrans(''.join(f), ''.join(t))
s = [input().strip() for i in range(int(input()))]
print(''.join(s).translate(d))
n = int(input()) | 16 | 11 | 336 | 310 | import string
n = int(input())
while n != 0:
f = []
t = []
for i in range(n):
l = input().split()
f.append(l[0])
t.append(l[1])
d = string.maketrans("".join(f), "".join(t))
s = []
for i in range(int(input())):
s.append(input().strip())
print("".join(s).translate(d))
n = int(input())
| import string
n = int(input())
while n != 0:
l = [input().split() for i in range(n)]
f = [i for i, j in l]
t = [j for i, j in l]
d = string.maketrans("".join(f), "".join(t))
s = [input().strip() for i in range(int(input()))]
print("".join(s).translate(d))
n = int(input())
| false | 31.25 | [
"- f = []",
"- t = []",
"- for i in range(n):",
"- l = input().split()",
"- f.append(l[0])",
"- t.append(l[1])",
"+ l = [input().split() for i in range(n)]",
"+ f = [i for i, j in l]",
"+ t = [j for i, j in l]",
"- s = []",
"- for i in range(int(input())):",
"- s.append(input().strip())",
"+ s = [input().strip() for i in range(int(input()))]"
] | false | 0.043268 | 0.042386 | 1.020812 | [
"s639358040",
"s937675850"
] |
u716530146 | p02708 | python | s002907336 | s433280301 | 349 | 71 | 216,544 | 67,784 | Accepted | Accepted | 79.66 | #!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
n,k = list(map(int,input().split()))
class InverseTable:
__slots__ = ['In', 'fac', 'Ifac']
def __init__(self, mod, maxnum):
self.In = [0, 1]; self.fac = [1, 1]; self.Ifac = [1, 1]
for i in range( 2, maxnum + 1 ):
self.In.append( ( -self.In[mod % i] * (mod//i) ) % mod )
self.fac.append( ( self.fac[-1] * i ) % mod )
self.Ifac.append( (self.Ifac[-1] * self.In[-1]) % mod )
def cmb(self, n, r):
if ( r<0 or r>n ): return 0
r = min(r, n-r)
return self.fac[n] * self.Ifac[r] * self.Ifac[n-r] % mod
def per(self, n, r):
if ( r<0 or r>n ): return 0
return self.fac[n] * self.Ifac[n-r] % mod
invt = InverseTable(mod, 10**6)
# maxnum=10**6だとテーブル生成に200ms程かかるので(Pythonだと1000msほど)
# 最大生成領域は問題ごとに要検討
teisu = n*(n+1)//2
for i in range(k,n+2):
ans += teisu-(n-i)*(n-i+1)//2-(i-1)*(i)//2 + 1
ans%=mod
# print(i,ans)
print((ans%mod))
| #!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
n,k = list(map(int,input().split()))
for i in range(k,n+2):
ans += (n+n-i+1)*i//2 - i*(i-1)//2 + 1
ans %= mod
print(ans)
| 37 | 11 | 1,195 | 346 | #!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8")
inf = float("inf")
mod = 10**9 + 7
mans = inf
ans = 0
count = 0
pro = 1
n, k = list(map(int, input().split()))
class InverseTable:
__slots__ = ["In", "fac", "Ifac"]
def __init__(self, mod, maxnum):
self.In = [0, 1]
self.fac = [1, 1]
self.Ifac = [1, 1]
for i in range(2, maxnum + 1):
self.In.append((-self.In[mod % i] * (mod // i)) % mod)
self.fac.append((self.fac[-1] * i) % mod)
self.Ifac.append((self.Ifac[-1] * self.In[-1]) % mod)
def cmb(self, n, r):
if r < 0 or r > n:
return 0
r = min(r, n - r)
return self.fac[n] * self.Ifac[r] * self.Ifac[n - r] % mod
def per(self, n, r):
if r < 0 or r > n:
return 0
return self.fac[n] * self.Ifac[n - r] % mod
invt = InverseTable(mod, 10**6)
# maxnum=10**6だとテーブル生成に200ms程かかるので(Pythonだと1000msほど)
# 最大生成領域は問題ごとに要検討
teisu = n * (n + 1) // 2
for i in range(k, n + 2):
ans += teisu - (n - i) * (n - i + 1) // 2 - (i - 1) * (i) // 2 + 1
ans %= mod
# print(i,ans)
print((ans % mod))
| #!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8")
inf = float("inf")
mod = 10**9 + 7
mans = inf
ans = 0
count = 0
pro = 1
n, k = list(map(int, input().split()))
for i in range(k, n + 2):
ans += (n + n - i + 1) * i // 2 - i * (i - 1) // 2 + 1
ans %= mod
print(ans)
| false | 70.27027 | [
"-",
"-",
"-class InverseTable:",
"- __slots__ = [\"In\", \"fac\", \"Ifac\"]",
"-",
"- def __init__(self, mod, maxnum):",
"- self.In = [0, 1]",
"- self.fac = [1, 1]",
"- self.Ifac = [1, 1]",
"- for i in range(2, maxnum + 1):",
"- self.In.append((-self.In[mod % i] * (mod // i)) % mod)",
"- self.fac.append((self.fac[-1] * i) % mod)",
"- self.Ifac.append((self.Ifac[-1] * self.In[-1]) % mod)",
"-",
"- def cmb(self, n, r):",
"- if r < 0 or r > n:",
"- return 0",
"- r = min(r, n - r)",
"- return self.fac[n] * self.Ifac[r] * self.Ifac[n - r] % mod",
"-",
"- def per(self, n, r):",
"- if r < 0 or r > n:",
"- return 0",
"- return self.fac[n] * self.Ifac[n - r] % mod",
"-",
"-",
"-invt = InverseTable(mod, 10**6)",
"-# maxnum=10**6だとテーブル生成に200ms程かかるので(Pythonだと1000msほど)",
"-# 最大生成領域は問題ごとに要検討",
"-teisu = n * (n + 1) // 2",
"- ans += teisu - (n - i) * (n - i + 1) // 2 - (i - 1) * (i) // 2 + 1",
"+ ans += (n + n - i + 1) * i // 2 - i * (i - 1) // 2 + 1",
"- # print(i,ans)",
"-print((ans % mod))",
"+print(ans)"
] | false | 2.183493 | 0.049578 | 44.041576 | [
"s002907336",
"s433280301"
] |
u252828980 | p02848 | python | s432269092 | s666051993 | 24 | 22 | 3,064 | 3,060 | Accepted | Accepted | 8.33 | n = int(eval(input()))
s = eval(input())
#a,b = map(int,input().split())
#li = list(map(int,input().split()))
W = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
ans = ""
for i in range(len(s)):
ans += W[W.index(s[i])+n]
print(ans) | n = int(eval(input()))
s = eval(input())
ss = ""
for i in range(len(s)):
a = ord(s[i])+n
#print(a)
if a >=91:
a = a-26
ss += chr(a)
else:
ss += chr(a)
print(ss) | 10 | 13 | 395 | 201 | n = int(eval(input()))
s = eval(input())
# a,b = map(int,input().split())
# li = list(map(int,input().split()))
W = [
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z",
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z",
]
ans = ""
for i in range(len(s)):
ans += W[W.index(s[i]) + n]
print(ans)
| n = int(eval(input()))
s = eval(input())
ss = ""
for i in range(len(s)):
a = ord(s[i]) + n
# print(a)
if a >= 91:
a = a - 26
ss += chr(a)
else:
ss += chr(a)
print(ss)
| false | 23.076923 | [
"-# a,b = map(int,input().split())",
"-# li = list(map(int,input().split()))",
"-W = [",
"- \"A\",",
"- \"B\",",
"- \"C\",",
"- \"D\",",
"- \"E\",",
"- \"F\",",
"- \"G\",",
"- \"H\",",
"- \"I\",",
"- \"J\",",
"- \"K\",",
"- \"L\",",
"- \"M\",",
"- \"N\",",
"- \"O\",",
"- \"P\",",
"- \"Q\",",
"- \"R\",",
"- \"S\",",
"- \"T\",",
"- \"U\",",
"- \"V\",",
"- \"W\",",
"- \"X\",",
"- \"Y\",",
"- \"Z\",",
"- \"A\",",
"- \"B\",",
"- \"C\",",
"- \"D\",",
"- \"E\",",
"- \"F\",",
"- \"G\",",
"- \"H\",",
"- \"I\",",
"- \"J\",",
"- \"K\",",
"- \"L\",",
"- \"M\",",
"- \"N\",",
"- \"O\",",
"- \"P\",",
"- \"Q\",",
"- \"R\",",
"- \"S\",",
"- \"T\",",
"- \"U\",",
"- \"V\",",
"- \"W\",",
"- \"X\",",
"- \"Y\",",
"- \"Z\",",
"-]",
"-ans = \"\"",
"+ss = \"\"",
"- ans += W[W.index(s[i]) + n]",
"-print(ans)",
"+ a = ord(s[i]) + n",
"+ # print(a)",
"+ if a >= 91:",
"+ a = a - 26",
"+ ss += chr(a)",
"+ else:",
"+ ss += chr(a)",
"+print(ss)"
] | false | 0.108115 | 0.046537 | 2.323192 | [
"s432269092",
"s666051993"
] |
u347640436 | p02608 | python | s479462710 | s567437452 | 467 | 150 | 9,536 | 9,484 | Accepted | Accepted | 67.88 | N = int(input())
t = [0] * (10 ** 4 + 1)
for x in range(1, 101):
for y in range(1, 101):
for z in range(1, 101):
n = x * x + y * y + z * z + x * y + y * z + z * x
if n <= 10 ** 4:
t[n] += 1
print(*[t[i] for i in range(1, N + 1)], sep='\n')
| N = int(input())
t = [0] * (N + 1)
for x in range(1, 101):
for y in range(1, 101):
for z in range(1, 101):
n = x * x + y * y + z * z + x * y + y * z + z * x
if n > N:
break
t[n] += 1
print(*t[1:], sep='\n')
| 11 | 12 | 304 | 284 | N = int(input())
t = [0] * (10**4 + 1)
for x in range(1, 101):
for y in range(1, 101):
for z in range(1, 101):
n = x * x + y * y + z * z + x * y + y * z + z * x
if n <= 10**4:
t[n] += 1
print(*[t[i] for i in range(1, N + 1)], sep="\n")
| N = int(input())
t = [0] * (N + 1)
for x in range(1, 101):
for y in range(1, 101):
for z in range(1, 101):
n = x * x + y * y + z * z + x * y + y * z + z * x
if n > N:
break
t[n] += 1
print(*t[1:], sep="\n")
| false | 8.333333 | [
"-t = [0] * (10**4 + 1)",
"+t = [0] * (N + 1)",
"- if n <= 10**4:",
"- t[n] += 1",
"-print(*[t[i] for i in range(1, N + 1)], sep=\"\\n\")",
"+ if n > N:",
"+ break",
"+ t[n] += 1",
"+print(*t[1:], sep=\"\\n\")"
] | false | 1.615412 | 0.044563 | 36.249738 | [
"s479462710",
"s567437452"
] |
u634079249 | p02547 | python | s090375493 | s032936950 | 41 | 30 | 9,896 | 9,760 | Accepted | Accepted | 26.83 | import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque
sys.setrecursionlimit(10000000)
ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]
iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]
lcm = lambda x, y: (x * y) // math.gcd(x, y)
MOD = 10 ** 9 + 7
INF = float('inf')
def main():
if os.getenv("LOCAL"):
sys.stdin = open("input.txt", "r")
N = ii()
D = [il() for _ in range(N)]
for i in range(N - 2):
for j in range(i, i + 3):
if D[j][0] != D[j][1]: break
else:
print('Yes')
exit()
else:
print('No')
if __name__ == '__main__':
main()
| import sys
import os
import math
import bisect
import itertools
import collections
import heapq
import queue
import array
# 時々使う
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque
# 再帰の制限設定
sys.setrecursionlimit(10000000)
def ii(): return int(sys.stdin.buffer.readline().rstrip())
def il(): return list(map(int, sys.stdin.buffer.readline().split()))
def fl(): return list(map(float, sys.stdin.buffer.readline().split()))
def iln(n): return [int(sys.stdin.buffer.readline().rstrip())
for _ in range(n)]
def iss(): return sys.stdin.buffer.readline().decode().rstrip()
def sl(): return list(map(str, sys.stdin.buffer.readline().decode().split()))
def isn(n): return [sys.stdin.buffer.readline().decode().rstrip()
for _ in range(n)]
def lcm(x, y): return (x * y) // math.gcd(x, y)
MOD = 10 ** 9 + 7
INF = float('inf')
def main():
if os.getenv("LOCAL"):
sys.stdin = open("input.txt", "r")
N = ii()
D = [il() for _ in range(N)]
for i in range(N - 2):
for j in range(i, i + 3):
if D[j][0] != D[j][1]:
break
else:
print('Yes')
exit()
else:
print('No')
if __name__ == '__main__':
main()
| 42 | 58 | 1,229 | 1,392 | import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque
sys.setrecursionlimit(10000000)
ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]
iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]
lcm = lambda x, y: (x * y) // math.gcd(x, y)
MOD = 10**9 + 7
INF = float("inf")
def main():
if os.getenv("LOCAL"):
sys.stdin = open("input.txt", "r")
N = ii()
D = [il() for _ in range(N)]
for i in range(N - 2):
for j in range(i, i + 3):
if D[j][0] != D[j][1]:
break
else:
print("Yes")
exit()
else:
print("No")
if __name__ == "__main__":
main()
| import sys
import os
import math
import bisect
import itertools
import collections
import heapq
import queue
import array
# 時々使う
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque
# 再帰の制限設定
sys.setrecursionlimit(10000000)
def ii():
return int(sys.stdin.buffer.readline().rstrip())
def il():
return list(map(int, sys.stdin.buffer.readline().split()))
def fl():
return list(map(float, sys.stdin.buffer.readline().split()))
def iln(n):
return [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]
def iss():
return sys.stdin.buffer.readline().decode().rstrip()
def sl():
return list(map(str, sys.stdin.buffer.readline().decode().split()))
def isn(n):
return [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]
def lcm(x, y):
return (x * y) // math.gcd(x, y)
MOD = 10**9 + 7
INF = float("inf")
def main():
if os.getenv("LOCAL"):
sys.stdin = open("input.txt", "r")
N = ii()
D = [il() for _ in range(N)]
for i in range(N - 2):
for j in range(i, i + 3):
if D[j][0] != D[j][1]:
break
else:
print("Yes")
exit()
else:
print("No")
if __name__ == "__main__":
main()
| false | 27.586207 | [
"-import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array",
"+import sys",
"+import os",
"+import math",
"+import bisect",
"+import itertools",
"+import collections",
"+import heapq",
"+import queue",
"+import array",
"+# 時々使う",
"+# 再帰の制限設定",
"-ii = lambda: int(sys.stdin.buffer.readline().rstrip())",
"-il = lambda: list(map(int, sys.stdin.buffer.readline().split()))",
"-fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))",
"-iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]",
"-iss = lambda: sys.stdin.buffer.readline().decode().rstrip()",
"-sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))",
"-isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]",
"-lcm = lambda x, y: (x * y) // math.gcd(x, y)",
"+",
"+",
"+def ii():",
"+ return int(sys.stdin.buffer.readline().rstrip())",
"+",
"+",
"+def il():",
"+ return list(map(int, sys.stdin.buffer.readline().split()))",
"+",
"+",
"+def fl():",
"+ return list(map(float, sys.stdin.buffer.readline().split()))",
"+",
"+",
"+def iln(n):",
"+ return [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]",
"+",
"+",
"+def iss():",
"+ return sys.stdin.buffer.readline().decode().rstrip()",
"+",
"+",
"+def sl():",
"+ return list(map(str, sys.stdin.buffer.readline().decode().split()))",
"+",
"+",
"+def isn(n):",
"+ return [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]",
"+",
"+",
"+def lcm(x, y):",
"+ return (x * y) // math.gcd(x, y)",
"+",
"+"
] | false | 0.03795 | 0.042976 | 0.883053 | [
"s090375493",
"s032936950"
] |
u130900604 | p02658 | python | s858011607 | s936711875 | 104 | 93 | 86,020 | 21,600 | Accepted | Accepted | 10.58 | n,*a=list(map(int,open(0).read().split()))
MX=10**18
prod=1
for q in sorted(a):
prod*=q
if prod>MX:
print((-1))
exit()
print(prod)
| n,*a=map(int,open(0).read().split())
a.sort()
if a[0]==0:
exit(print(0))
ans=1
for q in a:
ans*=q
if ans>10**18:
print(-1)
exit()
print(ans)
| 9 | 11 | 143 | 164 | n, *a = list(map(int, open(0).read().split()))
MX = 10**18
prod = 1
for q in sorted(a):
prod *= q
if prod > MX:
print((-1))
exit()
print(prod)
| n, *a = map(int, open(0).read().split())
a.sort()
if a[0] == 0:
exit(print(0))
ans = 1
for q in a:
ans *= q
if ans > 10**18:
print(-1)
exit()
print(ans)
| false | 18.181818 | [
"-n, *a = list(map(int, open(0).read().split()))",
"-MX = 10**18",
"-prod = 1",
"-for q in sorted(a):",
"- prod *= q",
"- if prod > MX:",
"- print((-1))",
"+n, *a = map(int, open(0).read().split())",
"+a.sort()",
"+if a[0] == 0:",
"+ exit(print(0))",
"+ans = 1",
"+for q in a:",
"+ ans *= q",
"+ if ans > 10**18:",
"+ print(-1)",
"-print(prod)",
"+print(ans)"
] | false | 0.048162 | 0.048784 | 0.987264 | [
"s858011607",
"s936711875"
] |
u171366497 | p03730 | python | s519115564 | s431502740 | 21 | 17 | 3,060 | 2,940 | Accepted | Accepted | 19.05 | a,b,c=list(map(int,input().split()))
x=1
data=set()
now=0
while x==1:
now+=a
now%=b
if now==c:
print('YES')
break
if now in data:
print('NO')
break
data|={now,} | a,b,c=list(map(int,input().split()))
res='NO'
for i in range(1,b+1):
if (a*i)%b==c:
res='YES'
break
print(res) | 14 | 7 | 219 | 130 | a, b, c = list(map(int, input().split()))
x = 1
data = set()
now = 0
while x == 1:
now += a
now %= b
if now == c:
print("YES")
break
if now in data:
print("NO")
break
data |= {
now,
}
| a, b, c = list(map(int, input().split()))
res = "NO"
for i in range(1, b + 1):
if (a * i) % b == c:
res = "YES"
break
print(res)
| false | 50 | [
"-x = 1",
"-data = set()",
"-now = 0",
"-while x == 1:",
"- now += a",
"- now %= b",
"- if now == c:",
"- print(\"YES\")",
"+res = \"NO\"",
"+for i in range(1, b + 1):",
"+ if (a * i) % b == c:",
"+ res = \"YES\"",
"- if now in data:",
"- print(\"NO\")",
"- break",
"- data |= {",
"- now,",
"- }",
"+print(res)"
] | false | 0.153077 | 0.100467 | 1.523652 | [
"s519115564",
"s431502740"
] |
u497046426 | p02984 | python | s640791679 | s672325627 | 308 | 122 | 68,452 | 14,092 | Accepted | Accepted | 60.39 | N = int(eval(input()))
*A, = list(map(int, input().split()))
X = [0]*N
X_total = sum(A)
A_odd = sum([A[i % N] for i in range(1, N, 2)])
A_even = sum([A[i % N] for i in range(2, N+1, 2)])
for i in range(N):
X[i] = X_total - 2*(A_odd if i % 2 == 0 else A_even)
if i % 2 == 0: A_odd += A[i] - A[(i+1) % N]
else: A_even += A[i] - A[(i+1) % N]
print((*X)) | N = int(eval(input()))
*A, = list(map(int, input().split()))
X = [0]*N
total = sum(A)
X[0] = total - 2*sum([a for a in A[1::2]])
for i in range(1, N):
X[i] = 2*A[i-1] - X[i-1]
print((*X)) | 11 | 8 | 358 | 184 | N = int(eval(input()))
(*A,) = list(map(int, input().split()))
X = [0] * N
X_total = sum(A)
A_odd = sum([A[i % N] for i in range(1, N, 2)])
A_even = sum([A[i % N] for i in range(2, N + 1, 2)])
for i in range(N):
X[i] = X_total - 2 * (A_odd if i % 2 == 0 else A_even)
if i % 2 == 0:
A_odd += A[i] - A[(i + 1) % N]
else:
A_even += A[i] - A[(i + 1) % N]
print((*X))
| N = int(eval(input()))
(*A,) = list(map(int, input().split()))
X = [0] * N
total = sum(A)
X[0] = total - 2 * sum([a for a in A[1::2]])
for i in range(1, N):
X[i] = 2 * A[i - 1] - X[i - 1]
print((*X))
| false | 27.272727 | [
"-X_total = sum(A)",
"-A_odd = sum([A[i % N] for i in range(1, N, 2)])",
"-A_even = sum([A[i % N] for i in range(2, N + 1, 2)])",
"-for i in range(N):",
"- X[i] = X_total - 2 * (A_odd if i % 2 == 0 else A_even)",
"- if i % 2 == 0:",
"- A_odd += A[i] - A[(i + 1) % N]",
"- else:",
"- A_even += A[i] - A[(i + 1) % N]",
"+total = sum(A)",
"+X[0] = total - 2 * sum([a for a in A[1::2]])",
"+for i in range(1, N):",
"+ X[i] = 2 * A[i - 1] - X[i - 1]"
] | false | 0.035497 | 0.034744 | 1.021662 | [
"s640791679",
"s672325627"
] |
u349449706 | p02975 | python | s887226791 | s125636490 | 92 | 84 | 92,912 | 93,124 | Accepted | Accepted | 8.7 | N = int(eval(input()))
a = list(map(int, input().split()))
d = {}
for i in a:
if i not in d:
d[i] = 1
else:
d[i] +=1
if len(d) == 1 and list(d.keys())==[0]:
print('Yes')
elif len(d) == 2:
for i in d:
if i == 0 and d[i] * 3 != N or i != 0 and d[i] * 3 != 2 * N:
print('No')
exit()
print('Yes')
elif len(d) == 3:
s = 0
for i in d:
s ^= i
if d[i] * 3 != N:
print('No')
exit()
if s != 0:
print('No')
else:
print('Yes')
else:
print('No')
| N = int(eval(input()))
a = list(map(int, input().split()))
d = {}
for i in a:
if i not in d:
d[i] = 1
else:
d[i] +=1
if len(d) == 1 and 0 in d:
print('Yes')
elif len(d) == 2:
for i in d:
if i == 0 and d[i] * 3 != N or i != 0 and d[i] * 3 != 2 * N:
print('No')
exit()
print('Yes')
elif len(d) == 3:
s = 0
for i in d:
s ^= i
if d[i] * 3 != N:
print('No')
exit()
if s != 0:
print('No')
else:
print('Yes')
else:
print('No')
| 29 | 29 | 599 | 586 | N = int(eval(input()))
a = list(map(int, input().split()))
d = {}
for i in a:
if i not in d:
d[i] = 1
else:
d[i] += 1
if len(d) == 1 and list(d.keys()) == [0]:
print("Yes")
elif len(d) == 2:
for i in d:
if i == 0 and d[i] * 3 != N or i != 0 and d[i] * 3 != 2 * N:
print("No")
exit()
print("Yes")
elif len(d) == 3:
s = 0
for i in d:
s ^= i
if d[i] * 3 != N:
print("No")
exit()
if s != 0:
print("No")
else:
print("Yes")
else:
print("No")
| N = int(eval(input()))
a = list(map(int, input().split()))
d = {}
for i in a:
if i not in d:
d[i] = 1
else:
d[i] += 1
if len(d) == 1 and 0 in d:
print("Yes")
elif len(d) == 2:
for i in d:
if i == 0 and d[i] * 3 != N or i != 0 and d[i] * 3 != 2 * N:
print("No")
exit()
print("Yes")
elif len(d) == 3:
s = 0
for i in d:
s ^= i
if d[i] * 3 != N:
print("No")
exit()
if s != 0:
print("No")
else:
print("Yes")
else:
print("No")
| false | 0 | [
"-if len(d) == 1 and list(d.keys()) == [0]:",
"+if len(d) == 1 and 0 in d:"
] | false | 0.041049 | 0.042144 | 0.974013 | [
"s887226791",
"s125636490"
] |
u612721349 | p03469 | python | s665117367 | s274974241 | 170 | 17 | 38,384 | 2,940 | Accepted | Accepted | 90 | print(("/".join(["2018"] + input().split("/")[1:]))) | print((input().replace("017","018"))) | 1 | 1 | 50 | 35 | print(("/".join(["2018"] + input().split("/")[1:])))
| print((input().replace("017", "018")))
| false | 0 | [
"-print((\"/\".join([\"2018\"] + input().split(\"/\")[1:])))",
"+print((input().replace(\"017\", \"018\")))"
] | false | 0.031704 | 0.034936 | 0.907494 | [
"s665117367",
"s274974241"
] |
u498487134 | p02883 | python | s808378053 | s927667256 | 1,322 | 353 | 119,756 | 102,652 | Accepted | Accepted | 73.3 | import math
#成績xを取れるか?xに関して二分探索
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
F = list(map(int,input().split()))
#Aを小さい順,Fを大きい順に並べれば対応する.
A.sort()
F.sort(reverse =True)
AF=[0]*N
for i in range(N):
AF[i]=A[i]*F[i]
ng=-1
ok=10**12+1
#二分探索,成績xをとるのにi番目の人が何回修行すべきか,これがK以下なら良い
while ok-ng!=1:
x = (ok+ng)//2
num_tra =0
for i in range(N):
af_i = int(math.ceil((AF[i]-x)/F[i]))
if af_i>0:
num_tra+=af_i
if num_tra<=K:
ok=x
else:
ng=x
print(ok) | import sys
input = sys.stdin.readline
def I(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def LI(): return list(map(int, input().split()))
"""
コストが低い人が食べにくいものを食べる.
コストが低い人を追い抜かすことはない,(追い抜かすなら入れ替えて良いから)
"""
def main():
mod=10**9+7
N,K=MI()
A=LI()
F=LI()
F.sort()
A.sort(reverse=True)
if K>=sum(A):
print((0))
exit()
def ch(x):
# x秒でクリアできるか
temp=0# 必要修行回数
for i in range(N):
af=A[i]*F[i]
if af>x:
add=(af-x+F[i]-1)//F[i]
temp+=(add)
return temp <= K
ok=10**12
ng=0
while ok-ng>1:
med=(ok+ng)//2
if ch(med):
ok=med
else:
ng=med
print(ok)
main()
| 33 | 50 | 574 | 878 | import math
# 成績xを取れるか?xに関して二分探索
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
F = list(map(int, input().split()))
# Aを小さい順,Fを大きい順に並べれば対応する.
A.sort()
F.sort(reverse=True)
AF = [0] * N
for i in range(N):
AF[i] = A[i] * F[i]
ng = -1
ok = 10**12 + 1
# 二分探索,成績xをとるのにi番目の人が何回修行すべきか,これがK以下なら良い
while ok - ng != 1:
x = (ok + ng) // 2
num_tra = 0
for i in range(N):
af_i = int(math.ceil((AF[i] - x) / F[i]))
if af_i > 0:
num_tra += af_i
if num_tra <= K:
ok = x
else:
ng = x
print(ok)
| import sys
input = sys.stdin.readline
def I():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
def LI():
return list(map(int, input().split()))
"""
コストが低い人が食べにくいものを食べる.
コストが低い人を追い抜かすことはない,(追い抜かすなら入れ替えて良いから)
"""
def main():
mod = 10**9 + 7
N, K = MI()
A = LI()
F = LI()
F.sort()
A.sort(reverse=True)
if K >= sum(A):
print((0))
exit()
def ch(x):
# x秒でクリアできるか
temp = 0 # 必要修行回数
for i in range(N):
af = A[i] * F[i]
if af > x:
add = (af - x + F[i] - 1) // F[i]
temp += add
return temp <= K
ok = 10**12
ng = 0
while ok - ng > 1:
med = (ok + ng) // 2
if ch(med):
ok = med
else:
ng = med
print(ok)
main()
| false | 34 | [
"-import math",
"+import sys",
"-# 成績xを取れるか?xに関して二分探索",
"-N, K = list(map(int, input().split()))",
"-A = list(map(int, input().split()))",
"-F = list(map(int, input().split()))",
"-# Aを小さい順,Fを大きい順に並べれば対応する.",
"-A.sort()",
"-F.sort(reverse=True)",
"-AF = [0] * N",
"-for i in range(N):",
"- AF[i] = A[i] * F[i]",
"-ng = -1",
"-ok = 10**12 + 1",
"-# 二分探索,成績xをとるのにi番目の人が何回修行すべきか,これがK以下なら良い",
"-while ok - ng != 1:",
"- x = (ok + ng) // 2",
"- num_tra = 0",
"- for i in range(N):",
"- af_i = int(math.ceil((AF[i] - x) / F[i]))",
"- if af_i > 0:",
"- num_tra += af_i",
"- if num_tra <= K:",
"- ok = x",
"- else:",
"- ng = x",
"-print(ok)",
"+input = sys.stdin.readline",
"+",
"+",
"+def I():",
"+ return int(eval(input()))",
"+",
"+",
"+def MI():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+def LI():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+\"\"\"",
"+コストが低い人が食べにくいものを食べる.",
"+コストが低い人を追い抜かすことはない,(追い抜かすなら入れ替えて良いから)",
"+\"\"\"",
"+",
"+",
"+def main():",
"+ mod = 10**9 + 7",
"+ N, K = MI()",
"+ A = LI()",
"+ F = LI()",
"+ F.sort()",
"+ A.sort(reverse=True)",
"+ if K >= sum(A):",
"+ print((0))",
"+ exit()",
"+",
"+ def ch(x):",
"+ # x秒でクリアできるか",
"+ temp = 0 # 必要修行回数",
"+ for i in range(N):",
"+ af = A[i] * F[i]",
"+ if af > x:",
"+ add = (af - x + F[i] - 1) // F[i]",
"+ temp += add",
"+ return temp <= K",
"+",
"+ ok = 10**12",
"+ ng = 0",
"+ while ok - ng > 1:",
"+ med = (ok + ng) // 2",
"+ if ch(med):",
"+ ok = med",
"+ else:",
"+ ng = med",
"+ print(ok)",
"+",
"+",
"+main()"
] | false | 0.041732 | 0.057091 | 0.730975 | [
"s808378053",
"s927667256"
] |
u847467233 | p02431 | python | s392347182 | s704527419 | 1,420 | 1,150 | 13,808 | 20,252 | Accepted | Accepted | 19.01 | # AOJ ITP2_1_A: Vector
# Python3 2018.6.24 bal4u
from collections import deque
Q = deque()
q = int(eval(input()))
for i in range(q):
a = eval(input())
if a[0] == '2': Q.pop() # popBack
else:
id, v = list(map(int, a.split()))
if id == 0: Q.append(v) # pushBack
else: print((Q[v])) # randomAccess
| # AOJ ITP2_1_A: Vector
# Python3 2018.6.24 bal4u
from collections import deque
Q = deque()
q = int(eval(input()))
for i in range(q):
a = eval(input())
if a[0] == '0': Q.append(a[2:]) # pushBack
elif a[0] == '1': print((Q[int(a[2:])])) # randomAccess
else: Q.pop() # popBack
| 13 | 11 | 310 | 307 | # AOJ ITP2_1_A: Vector
# Python3 2018.6.24 bal4u
from collections import deque
Q = deque()
q = int(eval(input()))
for i in range(q):
a = eval(input())
if a[0] == "2":
Q.pop() # popBack
else:
id, v = list(map(int, a.split()))
if id == 0:
Q.append(v) # pushBack
else:
print((Q[v])) # randomAccess
| # AOJ ITP2_1_A: Vector
# Python3 2018.6.24 bal4u
from collections import deque
Q = deque()
q = int(eval(input()))
for i in range(q):
a = eval(input())
if a[0] == "0":
Q.append(a[2:]) # pushBack
elif a[0] == "1":
print((Q[int(a[2:])])) # randomAccess
else:
Q.pop() # popBack
| false | 15.384615 | [
"- if a[0] == \"2\":",
"+ if a[0] == \"0\":",
"+ Q.append(a[2:]) # pushBack",
"+ elif a[0] == \"1\":",
"+ print((Q[int(a[2:])])) # randomAccess",
"+ else:",
"- else:",
"- id, v = list(map(int, a.split()))",
"- if id == 0:",
"- Q.append(v) # pushBack",
"- else:",
"- print((Q[v])) # randomAccess"
] | false | 0.049195 | 0.047842 | 1.028272 | [
"s392347182",
"s704527419"
] |
u888092736 | p04020 | python | s869446271 | s190172013 | 88 | 79 | 20,112 | 20,148 | Accepted | Accepted | 10.23 | N, *A = list(map(int, open(0).read().split()))
ans = 0
for i in range(N):
q, r = divmod(A[i], 2)
ans += q
if r == 0 or i == N - 1:
continue
elif A[i + 1] != 0:
A[i + 1] += 1
print(ans)
| N, *A = list(map(int, open(0).read().split()))
r = 0
ans = 0
for a in A:
if a == 0:
r = 0
continue
q, r = divmod(a + r, 2)
ans += q
print(ans)
| 10 | 11 | 220 | 176 | N, *A = list(map(int, open(0).read().split()))
ans = 0
for i in range(N):
q, r = divmod(A[i], 2)
ans += q
if r == 0 or i == N - 1:
continue
elif A[i + 1] != 0:
A[i + 1] += 1
print(ans)
| N, *A = list(map(int, open(0).read().split()))
r = 0
ans = 0
for a in A:
if a == 0:
r = 0
continue
q, r = divmod(a + r, 2)
ans += q
print(ans)
| false | 9.090909 | [
"+r = 0",
"-for i in range(N):",
"- q, r = divmod(A[i], 2)",
"+for a in A:",
"+ if a == 0:",
"+ r = 0",
"+ continue",
"+ q, r = divmod(a + r, 2)",
"- if r == 0 or i == N - 1:",
"- continue",
"- elif A[i + 1] != 0:",
"- A[i + 1] += 1"
] | false | 0.041369 | 0.033832 | 1.222783 | [
"s869446271",
"s190172013"
] |
u501952592 | p02678 | python | s888159965 | s640132444 | 1,983 | 669 | 225,320 | 60,024 | Accepted | Accepted | 66.26 | import networkx as nx
N, M = list(map(int, input().split()))
l = [list(map(int, input().split())) for _ in range(M)]
G = nx.Graph()
G.add_nodes_from(list(range(1, N+1)))
G.add_edges_from(l)
pre = nx.predecessor(G, 1)
print('Yes')
for i in range(2, N+1):
print((pre[i][0])) | from collections import deque
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
g = [[] for _ in range(N+1)]
for a, b in AB:
g[a].append(b)
g[b].append(a)
d = deque([1])
l = [0]*(N+1)
while d:
r = d.popleft()
for s in g[r]:
if l[s] == 0:
d.append(s)
l[s] = r
print("Yes", *l[2:], sep="\n")
| 12 | 20 | 274 | 376 | import networkx as nx
N, M = list(map(int, input().split()))
l = [list(map(int, input().split())) for _ in range(M)]
G = nx.Graph()
G.add_nodes_from(list(range(1, N + 1)))
G.add_edges_from(l)
pre = nx.predecessor(G, 1)
print("Yes")
for i in range(2, N + 1):
print((pre[i][0]))
| from collections import deque
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
g = [[] for _ in range(N + 1)]
for a, b in AB:
g[a].append(b)
g[b].append(a)
d = deque([1])
l = [0] * (N + 1)
while d:
r = d.popleft()
for s in g[r]:
if l[s] == 0:
d.append(s)
l[s] = r
print("Yes", *l[2:], sep="\n")
| false | 40 | [
"-import networkx as nx",
"+from collections import deque",
"-N, M = list(map(int, input().split()))",
"-l = [list(map(int, input().split())) for _ in range(M)]",
"-G = nx.Graph()",
"-G.add_nodes_from(list(range(1, N + 1)))",
"-G.add_edges_from(l)",
"-pre = nx.predecessor(G, 1)",
"-print(\"Yes\")",
"-for i in range(2, N + 1):",
"- print((pre[i][0]))",
"+N, M = map(int, input().split())",
"+AB = [list(map(int, input().split())) for _ in range(M)]",
"+g = [[] for _ in range(N + 1)]",
"+for a, b in AB:",
"+ g[a].append(b)",
"+ g[b].append(a)",
"+d = deque([1])",
"+l = [0] * (N + 1)",
"+while d:",
"+ r = d.popleft()",
"+ for s in g[r]:",
"+ if l[s] == 0:",
"+ d.append(s)",
"+ l[s] = r",
"+print(\"Yes\", *l[2:], sep=\"\\n\")"
] | false | 0.042946 | 0.077625 | 0.553251 | [
"s888159965",
"s640132444"
] |
u892487306 | p02819 | python | s469662332 | s447329450 | 234 | 17 | 3,388 | 3,064 | Accepted | Accepted | 92.74 | def get_primes(x):
if x < 2:
return list()
primes = [2]
n = 3
while n <= x:
is_prime = True
for p in primes:
if n % p == 0:
is_prime = False
break
if p**2 > n:
break
if is_prime:
primes.append(n)
n += 2
return primes
def main():
X = int(eval(input()))
if X <= 1:
print((2))
exit(0)
primes = get_primes(X)
while True:
is_prime = True
for p in primes:
if X % p == 0 and X > p:
is_prime = False
break
if is_prime:
break
X += 1
print(X)
if __name__ == '__main__':
main()
| def is_prime(x):
if x <= 1:
return False
elif x == 2:
return True
else:
n = 2
while n**2 <= x:
if x % n == 0:
return False
n += 1
return True
def main():
X = int(eval(input()))
while True:
if is_prime(X):
print(X)
break
X += 1
if __name__ == '__main__':
main() | 39 | 25 | 773 | 426 | def get_primes(x):
if x < 2:
return list()
primes = [2]
n = 3
while n <= x:
is_prime = True
for p in primes:
if n % p == 0:
is_prime = False
break
if p**2 > n:
break
if is_prime:
primes.append(n)
n += 2
return primes
def main():
X = int(eval(input()))
if X <= 1:
print((2))
exit(0)
primes = get_primes(X)
while True:
is_prime = True
for p in primes:
if X % p == 0 and X > p:
is_prime = False
break
if is_prime:
break
X += 1
print(X)
if __name__ == "__main__":
main()
| def is_prime(x):
if x <= 1:
return False
elif x == 2:
return True
else:
n = 2
while n**2 <= x:
if x % n == 0:
return False
n += 1
return True
def main():
X = int(eval(input()))
while True:
if is_prime(X):
print(X)
break
X += 1
if __name__ == "__main__":
main()
| false | 35.897436 | [
"-def get_primes(x):",
"- if x < 2:",
"- return list()",
"- primes = [2]",
"- n = 3",
"- while n <= x:",
"- is_prime = True",
"- for p in primes:",
"- if n % p == 0:",
"- is_prime = False",
"- break",
"- if p**2 > n:",
"- break",
"- if is_prime:",
"- primes.append(n)",
"- n += 2",
"- return primes",
"+def is_prime(x):",
"+ if x <= 1:",
"+ return False",
"+ elif x == 2:",
"+ return True",
"+ else:",
"+ n = 2",
"+ while n**2 <= x:",
"+ if x % n == 0:",
"+ return False",
"+ n += 1",
"+ return True",
"- if X <= 1:",
"- print((2))",
"- exit(0)",
"- primes = get_primes(X)",
"- is_prime = True",
"- for p in primes:",
"- if X % p == 0 and X > p:",
"- is_prime = False",
"- break",
"- if is_prime:",
"+ if is_prime(X):",
"+ print(X)",
"- print(X)"
] | false | 0.155941 | 0.035801 | 4.355776 | [
"s469662332",
"s447329450"
] |
u961683878 | p02819 | python | s899079912 | s632098330 | 153 | 17 | 43,488 | 3,060 | Accepted | Accepted | 88.89 | import sys
import bisect
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)
n = int(read())
n_ = 5*10**5
primes = set(range(2, n_+1))
for i in range(2, int(n_**0.5+1)):
primes.difference_update(list(range(i*2, n_+1, i)))
primes=list(primes)
idx = bisect.bisect_left(primes, n)
print((primes[idx]))
| import sys
import math
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)
n = int(read())
def is_prime(n):
if n == 1: return False
for k in range(2, int(math.sqrt(n)) + 1):
if n % k == 0:
return False
return True
for i in range(n, n*n, 1):
if is_prime(i):
print(i)
break
| 20 | 23 | 403 | 435 | import sys
import bisect
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)
n = int(read())
n_ = 5 * 10**5
primes = set(range(2, n_ + 1))
for i in range(2, int(n_**0.5 + 1)):
primes.difference_update(list(range(i * 2, n_ + 1, i)))
primes = list(primes)
idx = bisect.bisect_left(primes, n)
print((primes[idx]))
| import sys
import math
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)
n = int(read())
def is_prime(n):
if n == 1:
return False
for k in range(2, int(math.sqrt(n)) + 1):
if n % k == 0:
return False
return True
for i in range(n, n * n, 1):
if is_prime(i):
print(i)
break
| false | 13.043478 | [
"-import bisect",
"+import math",
"-n_ = 5 * 10**5",
"-primes = set(range(2, n_ + 1))",
"-for i in range(2, int(n_**0.5 + 1)):",
"- primes.difference_update(list(range(i * 2, n_ + 1, i)))",
"-primes = list(primes)",
"-idx = bisect.bisect_left(primes, n)",
"-print((primes[idx]))",
"+",
"+",
"+def is_prime(n):",
"+ if n == 1:",
"+ return False",
"+ for k in range(2, int(math.sqrt(n)) + 1):",
"+ if n % k == 0:",
"+ return False",
"+ return True",
"+",
"+",
"+for i in range(n, n * n, 1):",
"+ if is_prime(i):",
"+ print(i)",
"+ break"
] | false | 1.879331 | 0.143125 | 13.130686 | [
"s899079912",
"s632098330"
] |
u047796752 | p03426 | python | s026524031 | s538706435 | 449 | 405 | 81,236 | 62,956 | Accepted | Accepted | 9.8 | import sys
input = sys.stdin.readline
from collections import *
H, W, D = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(H)]
x, y = defaultdict(int), defaultdict(int)
for i in range(H):
for j in range(W):
x[A[i][j]] = i
y[A[i][j]] = j
x[0] = x[D]
y[0] = y[D]
acc = [[0] for _ in range(D)]
for i in range(D):
now = i
while now+D<=H*W:
acc[i].append(acc[i][-1]+abs(x[now+D]-x[now])+abs(y[now+D]-y[now]))
now += D
Q = int(eval(input()))
for _ in range(Q):
L, R = list(map(int, input().split()))
print((acc[L%D][R//D]-acc[L%D][L//D]))
| import sys
input = sys.stdin.readline
from collections import *
H, W, D = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(H)]
x = [-1]*(H*W)
y = [-1]*(H*W)
for i in range(H):
for j in range(W):
x[A[i][j]-1] = i
y[A[i][j]-1] = j
acc = [[0] for _ in range(D)]
for i in range(D):
now = i
while now+D<H*W:
cost = abs(x[now]-x[now+D])+abs(y[now]-y[now+D])
acc[i].append(acc[i][-1]+cost)
now += D
Q = int(eval(input()))
for _ in range(Q):
L, R = list(map(int, input().split()))
L -= 1
R -= 1
print((acc[L%D][R//D]-acc[L%D][L//D])) | 30 | 31 | 644 | 649 | import sys
input = sys.stdin.readline
from collections import *
H, W, D = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(H)]
x, y = defaultdict(int), defaultdict(int)
for i in range(H):
for j in range(W):
x[A[i][j]] = i
y[A[i][j]] = j
x[0] = x[D]
y[0] = y[D]
acc = [[0] for _ in range(D)]
for i in range(D):
now = i
while now + D <= H * W:
acc[i].append(acc[i][-1] + abs(x[now + D] - x[now]) + abs(y[now + D] - y[now]))
now += D
Q = int(eval(input()))
for _ in range(Q):
L, R = list(map(int, input().split()))
print((acc[L % D][R // D] - acc[L % D][L // D]))
| import sys
input = sys.stdin.readline
from collections import *
H, W, D = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(H)]
x = [-1] * (H * W)
y = [-1] * (H * W)
for i in range(H):
for j in range(W):
x[A[i][j] - 1] = i
y[A[i][j] - 1] = j
acc = [[0] for _ in range(D)]
for i in range(D):
now = i
while now + D < H * W:
cost = abs(x[now] - x[now + D]) + abs(y[now] - y[now + D])
acc[i].append(acc[i][-1] + cost)
now += D
Q = int(eval(input()))
for _ in range(Q):
L, R = list(map(int, input().split()))
L -= 1
R -= 1
print((acc[L % D][R // D] - acc[L % D][L // D]))
| false | 3.225806 | [
"-x, y = defaultdict(int), defaultdict(int)",
"+x = [-1] * (H * W)",
"+y = [-1] * (H * W)",
"- x[A[i][j]] = i",
"- y[A[i][j]] = j",
"-x[0] = x[D]",
"-y[0] = y[D]",
"+ x[A[i][j] - 1] = i",
"+ y[A[i][j] - 1] = j",
"- while now + D <= H * W:",
"- acc[i].append(acc[i][-1] + abs(x[now + D] - x[now]) + abs(y[now + D] - y[now]))",
"+ while now + D < H * W:",
"+ cost = abs(x[now] - x[now + D]) + abs(y[now] - y[now + D])",
"+ acc[i].append(acc[i][-1] + cost)",
"+ L -= 1",
"+ R -= 1"
] | false | 0.041089 | 0.054736 | 0.750681 | [
"s026524031",
"s538706435"
] |
u841531687 | p03163 | python | s321090734 | s599983191 | 645 | 592 | 123,016 | 120,856 | Accepted | Accepted | 8.22 | N, W = list(map(int, input().split()))
w = [0] * N
v = [0] * N
for i in range(N):
w[i], v[i] = list(map(int, input().split()))
def chmax(a, b):
if a >= b:
return a
else:
return b
dp = [[0]*(10**5 + 10) for _ in range(110)]
#i個の品物を入れて重さがjになっているときの価値の総和の最大値
#dp[i+1][j] = dp[i][j - w[i] + v[i]] 入れるとき
#dp[i+1][j] = dp[i][j] 入れないとき
#dp[0][j] = 0 初期値設定でOK
for i in range(N+1):
for j in range(W+1):
dp[i+1][j] = chmax(dp[i+1][j], dp[i][j])
if (i < N):
if (j >= w[i]):
dp[i+1][j] = chmax(dp[i+1][j], dp[i][j - w[i]] + v[i])
print((dp[N][W])) | N, W = list(map(int, input().split()))
wv = [list(map(int, input().split())) for _ in range(N)] #1-index
def chmax(a,b):
if a >= b:
return a
else:
return b
# dp[i+1][w]: i番目までの品物を選びその重さがwを超えないときの最大価値
dp = [[0]*(W+10) for _ in range(N+10)]
for i in range(N):
for w in range(W+1):
dp[i+1][w] = dp[i][w]
if w - wv[i][0] >= 0:
dp[i+1][w] = chmax(dp[i][w - wv[i][0]] + wv[i][1], dp[i][w])
print((dp[N][W])) | 27 | 19 | 628 | 479 | N, W = list(map(int, input().split()))
w = [0] * N
v = [0] * N
for i in range(N):
w[i], v[i] = list(map(int, input().split()))
def chmax(a, b):
if a >= b:
return a
else:
return b
dp = [[0] * (10**5 + 10) for _ in range(110)]
# i個の品物を入れて重さがjになっているときの価値の総和の最大値
# dp[i+1][j] = dp[i][j - w[i] + v[i]] 入れるとき
# dp[i+1][j] = dp[i][j] 入れないとき
# dp[0][j] = 0 初期値設定でOK
for i in range(N + 1):
for j in range(W + 1):
dp[i + 1][j] = chmax(dp[i + 1][j], dp[i][j])
if i < N:
if j >= w[i]:
dp[i + 1][j] = chmax(dp[i + 1][j], dp[i][j - w[i]] + v[i])
print((dp[N][W]))
| N, W = list(map(int, input().split()))
wv = [list(map(int, input().split())) for _ in range(N)] # 1-index
def chmax(a, b):
if a >= b:
return a
else:
return b
# dp[i+1][w]: i番目までの品物を選びその重さがwを超えないときの最大価値
dp = [[0] * (W + 10) for _ in range(N + 10)]
for i in range(N):
for w in range(W + 1):
dp[i + 1][w] = dp[i][w]
if w - wv[i][0] >= 0:
dp[i + 1][w] = chmax(dp[i][w - wv[i][0]] + wv[i][1], dp[i][w])
print((dp[N][W]))
| false | 29.62963 | [
"-w = [0] * N",
"-v = [0] * N",
"-for i in range(N):",
"- w[i], v[i] = list(map(int, input().split()))",
"+wv = [list(map(int, input().split())) for _ in range(N)] # 1-index",
"-dp = [[0] * (10**5 + 10) for _ in range(110)]",
"-# i個の品物を入れて重さがjになっているときの価値の総和の最大値",
"-# dp[i+1][j] = dp[i][j - w[i] + v[i]] 入れるとき",
"-# dp[i+1][j] = dp[i][j] 入れないとき",
"-# dp[0][j] = 0 初期値設定でOK",
"-for i in range(N + 1):",
"- for j in range(W + 1):",
"- dp[i + 1][j] = chmax(dp[i + 1][j], dp[i][j])",
"- if i < N:",
"- if j >= w[i]:",
"- dp[i + 1][j] = chmax(dp[i + 1][j], dp[i][j - w[i]] + v[i])",
"+# dp[i+1][w]: i番目までの品物を選びその重さがwを超えないときの最大価値",
"+dp = [[0] * (W + 10) for _ in range(N + 10)]",
"+for i in range(N):",
"+ for w in range(W + 1):",
"+ dp[i + 1][w] = dp[i][w]",
"+ if w - wv[i][0] >= 0:",
"+ dp[i + 1][w] = chmax(dp[i][w - wv[i][0]] + wv[i][1], dp[i][w])"
] | false | 0.242281 | 0.125855 | 1.92508 | [
"s321090734",
"s599983191"
] |
u844646164 | p02850 | python | s917045201 | s450546222 | 631 | 538 | 109,744 | 89,680 | Accepted | Accepted | 14.74 | import sys
from collections import deque
input = sys.stdin.readline
N = int(eval(input()))
graph = [[] for _ in range(N)]
ab = [list([int(x)-1 for x in input().split()]) for _ in range(N-1)]
col_max = 0
for i in range(N-1):
a, b = ab[i]
graph[a] += [b]
graph[b] += [a]
for i in range(N):
col_max = max(col_max, len(graph[i]))
print(col_max)
def bfs(s):
q = deque([s])
col = [-1]*N
col[s] = 0
edge_col = {}
while q:
c = 1
u = q.pop()
for v in graph[u]:
if col[v] == -1:
if c == col[u]:
c += 1
col[v] = c
q.append(v)
edge_col[(u, v)] = c
edge_col[(v, u)] = c
c += 1
return edge_col
col = bfs(0)
for a, b in ab:
print((col[(a, b)])) | import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
N = int(eval(input()))
graph = [[] for _ in range(N)]
ab = [list([int(x)-1 for x in input().split()]) for _ in range(N-1)]
d = {}
for a, b in ab:
graph[a] += [b]
graph[b] += [a]
def dfs(u, pre, c):
color = 0
for v in graph[u]:
if v != pre:
color += 1
if color == c:
color += 1
d[(u, v)] = color
d[(v, u)] = color
dfs(v, u, color)
dfs(0, -1, -1)
s = set()
for a, b in ab:
s.add(d[(a, b)])
print((len(s)))
for a, b in ab:
print((d[(a, b)]))
| 41 | 32 | 769 | 597 | import sys
from collections import deque
input = sys.stdin.readline
N = int(eval(input()))
graph = [[] for _ in range(N)]
ab = [list([int(x) - 1 for x in input().split()]) for _ in range(N - 1)]
col_max = 0
for i in range(N - 1):
a, b = ab[i]
graph[a] += [b]
graph[b] += [a]
for i in range(N):
col_max = max(col_max, len(graph[i]))
print(col_max)
def bfs(s):
q = deque([s])
col = [-1] * N
col[s] = 0
edge_col = {}
while q:
c = 1
u = q.pop()
for v in graph[u]:
if col[v] == -1:
if c == col[u]:
c += 1
col[v] = c
q.append(v)
edge_col[(u, v)] = c
edge_col[(v, u)] = c
c += 1
return edge_col
col = bfs(0)
for a, b in ab:
print((col[(a, b)]))
| import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
N = int(eval(input()))
graph = [[] for _ in range(N)]
ab = [list([int(x) - 1 for x in input().split()]) for _ in range(N - 1)]
d = {}
for a, b in ab:
graph[a] += [b]
graph[b] += [a]
def dfs(u, pre, c):
color = 0
for v in graph[u]:
if v != pre:
color += 1
if color == c:
color += 1
d[(u, v)] = color
d[(v, u)] = color
dfs(v, u, color)
dfs(0, -1, -1)
s = set()
for a, b in ab:
s.add(d[(a, b)])
print((len(s)))
for a, b in ab:
print((d[(a, b)]))
| false | 21.95122 | [
"-from collections import deque",
"+sys.setrecursionlimit(1000000000)",
"-col_max = 0",
"-for i in range(N - 1):",
"- a, b = ab[i]",
"+d = {}",
"+for a, b in ab:",
"-for i in range(N):",
"- col_max = max(col_max, len(graph[i]))",
"-print(col_max)",
"-def bfs(s):",
"- q = deque([s])",
"- col = [-1] * N",
"- col[s] = 0",
"- edge_col = {}",
"- while q:",
"- c = 1",
"- u = q.pop()",
"- for v in graph[u]:",
"- if col[v] == -1:",
"- if c == col[u]:",
"- c += 1",
"- col[v] = c",
"- q.append(v)",
"- edge_col[(u, v)] = c",
"- edge_col[(v, u)] = c",
"- c += 1",
"- return edge_col",
"+def dfs(u, pre, c):",
"+ color = 0",
"+ for v in graph[u]:",
"+ if v != pre:",
"+ color += 1",
"+ if color == c:",
"+ color += 1",
"+ d[(u, v)] = color",
"+ d[(v, u)] = color",
"+ dfs(v, u, color)",
"-col = bfs(0)",
"+dfs(0, -1, -1)",
"+s = set()",
"- print((col[(a, b)]))",
"+ s.add(d[(a, b)])",
"+print((len(s)))",
"+for a, b in ab:",
"+ print((d[(a, b)]))"
] | false | 0.049711 | 0.049948 | 0.995248 | [
"s917045201",
"s450546222"
] |
u562935282 | p02910 | python | s724432415 | s351229883 | 180 | 17 | 38,384 | 2,940 | Accepted | Accepted | 90.56 | s = eval(input())
for ss in s[0::2]:
if ss == 'L':
print('No')
exit()
for ss in s[1::2]:
if ss == 'R':
print('No')
exit()
print('Yes')
| s = eval(input())
odds = s[0::2]
if 'L' in odds:
print('No')
exit()
evens = s[1::2]
if 'R' in evens:
print('No')
exit()
print('Yes')
| 13 | 13 | 184 | 158 | s = eval(input())
for ss in s[0::2]:
if ss == "L":
print("No")
exit()
for ss in s[1::2]:
if ss == "R":
print("No")
exit()
print("Yes")
| s = eval(input())
odds = s[0::2]
if "L" in odds:
print("No")
exit()
evens = s[1::2]
if "R" in evens:
print("No")
exit()
print("Yes")
| false | 0 | [
"-for ss in s[0::2]:",
"- if ss == \"L\":",
"- print(\"No\")",
"- exit()",
"-for ss in s[1::2]:",
"- if ss == \"R\":",
"- print(\"No\")",
"- exit()",
"+odds = s[0::2]",
"+if \"L\" in odds:",
"+ print(\"No\")",
"+ exit()",
"+evens = s[1::2]",
"+if \"R\" in evens:",
"+ print(\"No\")",
"+ exit()"
] | false | 0.047132 | 0.048332 | 0.975163 | [
"s724432415",
"s351229883"
] |
u133936772 | p02550 | python | s428427103 | s288447511 | 101 | 91 | 14,120 | 13,936 | Accepted | Accepted | 9.9 | n,x,m=list(map(int,input().split()))
l=[0]*m
s=[0]*m
t=p=0
while l[x]<1:
t+=1
l[x]=t
s[x]=s[p]+x
p=x
x=pow(p,2,m)
T=t+1-l[x]
S=s[p]+x-s[x]
print((S*((n-l[x])//T)+s[l.index(l[x]+(n-l[x])%T)])) | n,x,m=list(map(int,input().split()))
l=[0]*m
s=[0]*m
t=p=0
while l[x]<1:
t+=1
l[x]=t
s[x]=s[p]+x
p=x
x=pow(p,2,m)
T=t+1-l[x]
S=s[p]+x-s[x]
d,m=divmod(n-l[x],T)
print((S*d+s[l.index(l[x]+m)])) | 13 | 14 | 205 | 206 | n, x, m = list(map(int, input().split()))
l = [0] * m
s = [0] * m
t = p = 0
while l[x] < 1:
t += 1
l[x] = t
s[x] = s[p] + x
p = x
x = pow(p, 2, m)
T = t + 1 - l[x]
S = s[p] + x - s[x]
print((S * ((n - l[x]) // T) + s[l.index(l[x] + (n - l[x]) % T)]))
| n, x, m = list(map(int, input().split()))
l = [0] * m
s = [0] * m
t = p = 0
while l[x] < 1:
t += 1
l[x] = t
s[x] = s[p] + x
p = x
x = pow(p, 2, m)
T = t + 1 - l[x]
S = s[p] + x - s[x]
d, m = divmod(n - l[x], T)
print((S * d + s[l.index(l[x] + m)]))
| false | 7.142857 | [
"-print((S * ((n - l[x]) // T) + s[l.index(l[x] + (n - l[x]) % T)]))",
"+d, m = divmod(n - l[x], T)",
"+print((S * d + s[l.index(l[x] + m)]))"
] | false | 0.048269 | 0.048583 | 0.993549 | [
"s428427103",
"s288447511"
] |
u191874006 | p03354 | python | s998821470 | s530791779 | 1,103 | 520 | 99,692 | 14,256 | Accepted | Accepted | 52.86 | #!/usr/bin/env python3
n,m = list(map(int,input().split()))
p = list(map(int,input().split()))
for i in range(n):
p[i] -= 1
#連結成分に属するかどうかを見るときはUnion-Findを用いる
#根(属するクラス)を返す関数
def root(x):
if par[x] == x:
return x
par[x] = root(par[x])
return par[x]
#同じクラスに属するかどうかを返す関数
def same(x,y):
return root(x) == root(y)
#木を結合する関数
def union(x,y):
x = root(x)
y = root(y)
#高さの高いほうに低いほうを結合
if rank[x] < rank[y]:
par[x] = y#xの親(属するクラス)をyとする
else:
par[y] = x
if rank[x] == rank[y]:#高さが同じ場合
rank[x] += 1#高さは1つ増える
par = [i for i in range(n)]
rank = [0 for _ in range(n)]
for i in range(m):
x,y = list(map(int,input().split()))
#swapできる頂点は同じ木にして同じ連結成分にする
if not same(x-1,y-1):
union(x-1,y-1)
ans = 0
for i in range(n):
#p[i]とiが同じ連結成分ならばans+1
if root(p[i]) == root(i):
ans += 1
print(ans)
| #!/usr/bin/env python3
#ABC97 D
import sys
import math
import bisect
import time
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def root(x):
if par[x] == x:
return x
par[x] = root(par[x])
return par[x]
def union(x,y):
x = root(x)
y = root(y)
if rank[x] < rank[y]:
par[x] = y
else:
par[y] = x
if rank[x] == rank[y]:
rank[x] += 1
n,m = LI()
p = LI()
par = [i for i in range(n)]
rank = [0 for _ in range(n)]
for _ in range(m):
x,y = LI()
if root(x-1) != root(y-1):
union(x-1,y-1)
ans = 0
for i in range(n):
if root(p[i]-1) == root(i):
ans += 1
print(ans)
| 43 | 50 | 923 | 1,077 | #!/usr/bin/env python3
n, m = list(map(int, input().split()))
p = list(map(int, input().split()))
for i in range(n):
p[i] -= 1
# 連結成分に属するかどうかを見るときはUnion-Findを用いる
# 根(属するクラス)を返す関数
def root(x):
if par[x] == x:
return x
par[x] = root(par[x])
return par[x]
# 同じクラスに属するかどうかを返す関数
def same(x, y):
return root(x) == root(y)
# 木を結合する関数
def union(x, y):
x = root(x)
y = root(y)
# 高さの高いほうに低いほうを結合
if rank[x] < rank[y]:
par[x] = y # xの親(属するクラス)をyとする
else:
par[y] = x
if rank[x] == rank[y]: # 高さが同じ場合
rank[x] += 1 # 高さは1つ増える
par = [i for i in range(n)]
rank = [0 for _ in range(n)]
for i in range(m):
x, y = list(map(int, input().split()))
# swapできる頂点は同じ木にして同じ連結成分にする
if not same(x - 1, y - 1):
union(x - 1, y - 1)
ans = 0
for i in range(n):
# p[i]とiが同じ連結成分ならばans+1
if root(p[i]) == root(i):
ans += 1
print(ans)
| #!/usr/bin/env python3
# ABC97 D
import sys
import math
import bisect
import time
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop, heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float("inf")
def I():
return int(sys.stdin.readline())
def LI():
return list(map(int, sys.stdin.readline().split()))
def root(x):
if par[x] == x:
return x
par[x] = root(par[x])
return par[x]
def union(x, y):
x = root(x)
y = root(y)
if rank[x] < rank[y]:
par[x] = y
else:
par[y] = x
if rank[x] == rank[y]:
rank[x] += 1
n, m = LI()
p = LI()
par = [i for i in range(n)]
rank = [0 for _ in range(n)]
for _ in range(m):
x, y = LI()
if root(x - 1) != root(y - 1):
union(x - 1, y - 1)
ans = 0
for i in range(n):
if root(p[i] - 1) == root(i):
ans += 1
print(ans)
| false | 14 | [
"-n, m = list(map(int, input().split()))",
"-p = list(map(int, input().split()))",
"-for i in range(n):",
"- p[i] -= 1",
"-# 連結成分に属するかどうかを見るときはUnion-Findを用いる",
"-# 根(属するクラス)を返す関数",
"+# ABC97 D",
"+import sys",
"+import math",
"+import bisect",
"+import time",
"+",
"+sys.setrecursionlimit(1000000000)",
"+from heapq import heappush, heappop, heappushpop",
"+from collections import defaultdict",
"+from itertools import accumulate",
"+from collections import Counter",
"+from collections import deque",
"+from operator import itemgetter",
"+from itertools import permutations",
"+",
"+mod = 10**9 + 7",
"+inf = float(\"inf\")",
"+",
"+",
"+def I():",
"+ return int(sys.stdin.readline())",
"+",
"+",
"+def LI():",
"+ return list(map(int, sys.stdin.readline().split()))",
"+",
"+",
"-# 同じクラスに属するかどうかを返す関数",
"-def same(x, y):",
"- return root(x) == root(y)",
"-",
"-",
"-# 木を結合する関数",
"- # 高さの高いほうに低いほうを結合",
"- par[x] = y # xの親(属するクラス)をyとする",
"+ par[x] = y",
"- if rank[x] == rank[y]: # 高さが同じ場合",
"- rank[x] += 1 # 高さは1つ増える",
"+ if rank[x] == rank[y]:",
"+ rank[x] += 1",
"+n, m = LI()",
"+p = LI()",
"-for i in range(m):",
"- x, y = list(map(int, input().split()))",
"- # swapできる頂点は同じ木にして同じ連結成分にする",
"- if not same(x - 1, y - 1):",
"+for _ in range(m):",
"+ x, y = LI()",
"+ if root(x - 1) != root(y - 1):",
"- # p[i]とiが同じ連結成分ならばans+1",
"- if root(p[i]) == root(i):",
"+ if root(p[i] - 1) == root(i):"
] | false | 0.045583 | 0.086094 | 0.529463 | [
"s998821470",
"s530791779"
] |
u891516200 | p02780 | python | s958679757 | s055901629 | 248 | 177 | 36,020 | 34,792 | Accepted | Accepted | 28.63 | from statistics import median
from time import time
t = time()
N, K = [int(x) for x in input().split()]
line_in_dice = list([int(x) for x in input().split()])
result = [0] * (N + K)
result[0] = line_in_dice[0]
result[K] -= line_in_dice[0]
max_point = 0
max_value = 0
for i in range(1, N):
result[i] += (result[i - 1] + line_in_dice[i])
result[i + K] -= line_in_dice[i]
if result[i] > max_value:
max_point = i
max_value = result[i]
def create_median(x):
if x % 2 == 1:
return (1 + x) // 2
else:
return ((x // 2) + (x // 2 + 1)) / 2
print((sum(create_median(x)
for x in line_in_dice[max_point - K + 1: max_point+1])))
| from statistics import median
N, K = [int(x) for x in input().split()]
line_in_dice = list([(int(x) + 1) / 2 for x in input().split()])
result = [0] * (N + K)
result[0] = line_in_dice[0]
result[K] -= line_in_dice[0]
max_point = 0
max_value = 0
for i in range(1, N):
result[i] += (result[i - 1] + line_in_dice[i])
result[i + K] -= line_in_dice[i]
print((max(result)))
| 34 | 18 | 720 | 396 | from statistics import median
from time import time
t = time()
N, K = [int(x) for x in input().split()]
line_in_dice = list([int(x) for x in input().split()])
result = [0] * (N + K)
result[0] = line_in_dice[0]
result[K] -= line_in_dice[0]
max_point = 0
max_value = 0
for i in range(1, N):
result[i] += result[i - 1] + line_in_dice[i]
result[i + K] -= line_in_dice[i]
if result[i] > max_value:
max_point = i
max_value = result[i]
def create_median(x):
if x % 2 == 1:
return (1 + x) // 2
else:
return ((x // 2) + (x // 2 + 1)) / 2
print((sum(create_median(x) for x in line_in_dice[max_point - K + 1 : max_point + 1])))
| from statistics import median
N, K = [int(x) for x in input().split()]
line_in_dice = list([(int(x) + 1) / 2 for x in input().split()])
result = [0] * (N + K)
result[0] = line_in_dice[0]
result[K] -= line_in_dice[0]
max_point = 0
max_value = 0
for i in range(1, N):
result[i] += result[i - 1] + line_in_dice[i]
result[i + K] -= line_in_dice[i]
print((max(result)))
| false | 47.058824 | [
"-from time import time",
"-t = time()",
"-line_in_dice = list([int(x) for x in input().split()])",
"+line_in_dice = list([(int(x) + 1) / 2 for x in input().split()])",
"- if result[i] > max_value:",
"- max_point = i",
"- max_value = result[i]",
"-",
"-",
"-def create_median(x):",
"- if x % 2 == 1:",
"- return (1 + x) // 2",
"- else:",
"- return ((x // 2) + (x // 2 + 1)) / 2",
"-",
"-",
"-print((sum(create_median(x) for x in line_in_dice[max_point - K + 1 : max_point + 1])))",
"+print((max(result)))"
] | false | 0.036883 | 0.03474 | 1.061696 | [
"s958679757",
"s055901629"
] |
u391532301 | p03038 | python | s272787522 | s176550655 | 576 | 511 | 36,088 | 28,728 | Accepted | Accepted | 11.28 | N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
A.sort()
BC = [list(map(int,input().split())) for i in range(M)]
BC.sort(key = lambda x:-x[1])
index = 0
l = len(A)
for i in range(len(BC)):
for j in range(BC[i][0]):
if index == l or A[index] >= BC[i][1]:
break
else:
A[index] = BC[i][1]
index += 1
print((sum(A)))
| N,M = list(map(int,input().split()))
A = [int(_) for _ in input().split()]
BC = []
count = 0
s = 0
D = []
for i in range(M):
x,y = list(map(int,input().split()))
BC.append([x,y])
A.sort()
BC.sort(key = lambda x:-x[1])
while s+BC[count][0] <= N:
s += BC[count][0]
for i in range(BC[count][0]):
D.append(BC[count][1])
if count == M-1:
break
else:
count += 1
if count != M-1:
for i in range(N-s):
D.append(BC[count][1])
index = 0
while D[index] - A[index] > 0 :
A[index] = D[index]
if index == len(D)-1:
break
else:
index += 1
print((sum(A))) | 19 | 30 | 411 | 643 | N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()
BC = [list(map(int, input().split())) for i in range(M)]
BC.sort(key=lambda x: -x[1])
index = 0
l = len(A)
for i in range(len(BC)):
for j in range(BC[i][0]):
if index == l or A[index] >= BC[i][1]:
break
else:
A[index] = BC[i][1]
index += 1
print((sum(A)))
| N, M = list(map(int, input().split()))
A = [int(_) for _ in input().split()]
BC = []
count = 0
s = 0
D = []
for i in range(M):
x, y = list(map(int, input().split()))
BC.append([x, y])
A.sort()
BC.sort(key=lambda x: -x[1])
while s + BC[count][0] <= N:
s += BC[count][0]
for i in range(BC[count][0]):
D.append(BC[count][1])
if count == M - 1:
break
else:
count += 1
if count != M - 1:
for i in range(N - s):
D.append(BC[count][1])
index = 0
while D[index] - A[index] > 0:
A[index] = D[index]
if index == len(D) - 1:
break
else:
index += 1
print((sum(A)))
| false | 36.666667 | [
"-A = list(map(int, input().split()))",
"+A = [int(_) for _ in input().split()]",
"+BC = []",
"+count = 0",
"+s = 0",
"+D = []",
"+for i in range(M):",
"+ x, y = list(map(int, input().split()))",
"+ BC.append([x, y])",
"-BC = [list(map(int, input().split())) for i in range(M)]",
"+while s + BC[count][0] <= N:",
"+ s += BC[count][0]",
"+ for i in range(BC[count][0]):",
"+ D.append(BC[count][1])",
"+ if count == M - 1:",
"+ break",
"+ else:",
"+ count += 1",
"+if count != M - 1:",
"+ for i in range(N - s):",
"+ D.append(BC[count][1])",
"-l = len(A)",
"-for i in range(len(BC)):",
"- for j in range(BC[i][0]):",
"- if index == l or A[index] >= BC[i][1]:",
"- break",
"- else:",
"- A[index] = BC[i][1]",
"- index += 1",
"+while D[index] - A[index] > 0:",
"+ A[index] = D[index]",
"+ if index == len(D) - 1:",
"+ break",
"+ else:",
"+ index += 1"
] | false | 0.0473 | 0.038629 | 1.22447 | [
"s272787522",
"s176550655"
] |
u973193813 | p03073 | python | s036381025 | s140455988 | 197 | 46 | 15,932 | 3,956 | Accepted | Accepted | 76.65 | import numpy as np
S = list(map(int, eval(input())))
tmp = [0]*len(S)
if S[0] == 1:
for ii in range(0,len(S),2):
tmp[ii] = 1
else:
for ii in range(1,len(S),2):
tmp[ii] = 1
A = []
for ii in range(len(tmp)):
A.append(S[ii]-tmp[ii])
count = np.count_nonzero(A)
print(count) | S = list(map(int, eval(input())))
count = 0
tmp = S[0]
for ii in S:
if ii != tmp:
count += 1
if tmp == 1:
tmp = 0
else:
tmp = 1
print(count) | 18 | 14 | 317 | 186 | import numpy as np
S = list(map(int, eval(input())))
tmp = [0] * len(S)
if S[0] == 1:
for ii in range(0, len(S), 2):
tmp[ii] = 1
else:
for ii in range(1, len(S), 2):
tmp[ii] = 1
A = []
for ii in range(len(tmp)):
A.append(S[ii] - tmp[ii])
count = np.count_nonzero(A)
print(count)
| S = list(map(int, eval(input())))
count = 0
tmp = S[0]
for ii in S:
if ii != tmp:
count += 1
if tmp == 1:
tmp = 0
else:
tmp = 1
print(count)
| false | 22.222222 | [
"-import numpy as np",
"-",
"-tmp = [0] * len(S)",
"-if S[0] == 1:",
"- for ii in range(0, len(S), 2):",
"- tmp[ii] = 1",
"-else:",
"- for ii in range(1, len(S), 2):",
"- tmp[ii] = 1",
"-A = []",
"-for ii in range(len(tmp)):",
"- A.append(S[ii] - tmp[ii])",
"-count = np.count_nonzero(A)",
"+count = 0",
"+tmp = S[0]",
"+for ii in S:",
"+ if ii != tmp:",
"+ count += 1",
"+ if tmp == 1:",
"+ tmp = 0",
"+ else:",
"+ tmp = 1"
] | false | 0.282225 | 0.03614 | 7.809306 | [
"s036381025",
"s140455988"
] |
u312025627 | p03048 | python | s898178449 | s322588735 | 366 | 306 | 40,684 | 41,068 | Accepted | Accepted | 16.39 | def main():
R, G, B, N = (int(i) for i in input().split())
ans = 0
for r in range(0, N+1):
for g in range(0, N+1):
b = (N - r*R - g*G)//B
if b >= 0 and r*R + g*G + b*B == N:
ans += 1
print(ans)
if __name__ == '__main__':
main()
| def main():
R, G, B, N = (int(i) for i in input().split())
ans = 0
for r in range(N+1):
for g in range(N+1):
need = N - r*R - g*G # 必要ボール数
if need < 0:
continue
b = 0--need//B
if r*R + g*G + b*B == N:
ans += 1
# print(r, g, b)
print(ans)
if __name__ == '__main__':
main()
| 13 | 17 | 310 | 415 | def main():
R, G, B, N = (int(i) for i in input().split())
ans = 0
for r in range(0, N + 1):
for g in range(0, N + 1):
b = (N - r * R - g * G) // B
if b >= 0 and r * R + g * G + b * B == N:
ans += 1
print(ans)
if __name__ == "__main__":
main()
| def main():
R, G, B, N = (int(i) for i in input().split())
ans = 0
for r in range(N + 1):
for g in range(N + 1):
need = N - r * R - g * G # 必要ボール数
if need < 0:
continue
b = 0 - -need // B
if r * R + g * G + b * B == N:
ans += 1
# print(r, g, b)
print(ans)
if __name__ == "__main__":
main()
| false | 23.529412 | [
"- for r in range(0, N + 1):",
"- for g in range(0, N + 1):",
"- b = (N - r * R - g * G) // B",
"- if b >= 0 and r * R + g * G + b * B == N:",
"+ for r in range(N + 1):",
"+ for g in range(N + 1):",
"+ need = N - r * R - g * G # 必要ボール数",
"+ if need < 0:",
"+ continue",
"+ b = 0 - -need // B",
"+ if r * R + g * G + b * B == N:",
"+ # print(r, g, b)"
] | false | 1.356039 | 1.202933 | 1.127278 | [
"s898178449",
"s322588735"
] |
u530383736 | p03127 | python | s599699399 | s535687110 | 111 | 90 | 14,252 | 14,252 | Accepted | Accepted | 18.92 | # -*- coding: utf-8 -*-
N = int(input().strip())
a_list = [int(i) for i in input().rstrip().split()]
#-----
def gcd(a,b):
x = max(a,b)
y = min(a,b)
while y != 0:
r = x % y
x = y
y = r
return x
ans = a_list[0]
for i in a_list[1:]:
ans = gcd(ans, i)
print(ans)
| # -*- coding: utf-8 -*-
N = int(input().strip())
a_list = [int(i) for i in input().rstrip().split()]
#-----
def gcd(a,b):
if b == 0:
return a
return gcd(b, a % b)
ans = a_list[0]
for i in a_list[1:]:
ans = gcd(ans, i)
print(ans)
| 23 | 16 | 344 | 269 | # -*- coding: utf-8 -*-
N = int(input().strip())
a_list = [int(i) for i in input().rstrip().split()]
# -----
def gcd(a, b):
x = max(a, b)
y = min(a, b)
while y != 0:
r = x % y
x = y
y = r
return x
ans = a_list[0]
for i in a_list[1:]:
ans = gcd(ans, i)
print(ans)
| # -*- coding: utf-8 -*-
N = int(input().strip())
a_list = [int(i) for i in input().rstrip().split()]
# -----
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
ans = a_list[0]
for i in a_list[1:]:
ans = gcd(ans, i)
print(ans)
| false | 30.434783 | [
"- x = max(a, b)",
"- y = min(a, b)",
"- while y != 0:",
"- r = x % y",
"- x = y",
"- y = r",
"- return x",
"+ if b == 0:",
"+ return a",
"+ return gcd(b, a % b)"
] | false | 0.069039 | 0.057218 | 1.206594 | [
"s599699399",
"s535687110"
] |
u708255304 | p02999 | python | s845113864 | s742000431 | 20 | 18 | 3,316 | 3,064 | Accepted | Accepted | 10 | X, A = list(map(int, input().split()))
if X < A:
print((0))
else:
print((10))
| X, A = list(map(int, input().split()))
if A > X:
print((0))
else:
print((10))
| 6 | 6 | 82 | 82 | X, A = list(map(int, input().split()))
if X < A:
print((0))
else:
print((10))
| X, A = list(map(int, input().split()))
if A > X:
print((0))
else:
print((10))
| false | 0 | [
"-if X < A:",
"+if A > X:"
] | false | 0.046665 | 0.047526 | 0.981891 | [
"s845113864",
"s742000431"
] |
u695811449 | p03329 | python | s051091422 | s288712695 | 387 | 273 | 7,064 | 3,192 | Accepted | Accepted | 29.46 | N=int(eval(input()))
X=[1]+[6**i for i in range(1,7)]+[9**i for i in range(1,6)]
X.sort()
X.reverse()
DP=[i for i in range(100001)]
def dpmin(i):
Y=i
for j in X:
if i-j>=0:
Y=min(Y,DP[i-j]+1)
return Y
for i in range(100001):
DP[i]=dpmin(i)
print((DP[N]))
| N=int(eval(input()))
X=[1]+[6**i for i in range(1,7)]+[9**i for i in range(1,6)]
X.sort()
X.reverse()
ANS=1000000
i=4
for i_0 in range(max(N//X[0]-i,0),N//X[0]+1):
N_0=N-X[0]*i_0
for i_1 in range(max(N_0//X[1]-i,0),N_0//X[1]+1):
N_1=N_0-X[1]*i_1
for i_2 in range(max(N_1//X[2]-i,0),N_1//X[2]+1):
N_2=N_1-X[2]*i_2
for i_3 in range(max(N_2//X[3]-i,0),N_2//X[3]+1):
N_3=N_2-X[3]*i_3
for i_4 in range(max(N_3//X[4]-i,0),N_3//X[4]+1):
N_4=N_3-X[4]*i_4
for i_5 in range(max(N_4//X[5]-i,0),N_4//X[5]+1):
N_5=N_4-X[5]*i_5
for i_6 in range(max(N_5//X[6]-i,0),N_5//X[6]+1):
N_6=N_5-X[6]*i_6
for i_7 in range(max(N_6//X[7]-i,0),N_6//X[7]+1):
N_7=N_6-X[7]*i_7
for i_8 in range(max(N_7//X[8]-i,0),N_7//X[8]+1):
N_8=N_7-X[8]*i_8
for i_9 in range(max(N_8//X[9]-i,0),N_8//X[9]+1):
N_9=N_8-X[9]*i_9
i_10=N_9//6
N_10=N_9-X[10]*i_10
if ANS>i_0+i_1+i_2+i_3+i_4+i_5+i_6+i_7+i_8+i_9+i_10+N_10:
ANS=i_0+i_1+i_2+i_3+i_4+i_5+i_6+i_7+i_8+i_9+i_10+N_10
print(ANS)
| 23 | 49 | 311 | 1,617 | N = int(eval(input()))
X = [1] + [6**i for i in range(1, 7)] + [9**i for i in range(1, 6)]
X.sort()
X.reverse()
DP = [i for i in range(100001)]
def dpmin(i):
Y = i
for j in X:
if i - j >= 0:
Y = min(Y, DP[i - j] + 1)
return Y
for i in range(100001):
DP[i] = dpmin(i)
print((DP[N]))
| N = int(eval(input()))
X = [1] + [6**i for i in range(1, 7)] + [9**i for i in range(1, 6)]
X.sort()
X.reverse()
ANS = 1000000
i = 4
for i_0 in range(max(N // X[0] - i, 0), N // X[0] + 1):
N_0 = N - X[0] * i_0
for i_1 in range(max(N_0 // X[1] - i, 0), N_0 // X[1] + 1):
N_1 = N_0 - X[1] * i_1
for i_2 in range(max(N_1 // X[2] - i, 0), N_1 // X[2] + 1):
N_2 = N_1 - X[2] * i_2
for i_3 in range(max(N_2 // X[3] - i, 0), N_2 // X[3] + 1):
N_3 = N_2 - X[3] * i_3
for i_4 in range(max(N_3 // X[4] - i, 0), N_3 // X[4] + 1):
N_4 = N_3 - X[4] * i_4
for i_5 in range(max(N_4 // X[5] - i, 0), N_4 // X[5] + 1):
N_5 = N_4 - X[5] * i_5
for i_6 in range(max(N_5 // X[6] - i, 0), N_5 // X[6] + 1):
N_6 = N_5 - X[6] * i_6
for i_7 in range(max(N_6 // X[7] - i, 0), N_6 // X[7] + 1):
N_7 = N_6 - X[7] * i_7
for i_8 in range(
max(N_7 // X[8] - i, 0), N_7 // X[8] + 1
):
N_8 = N_7 - X[8] * i_8
for i_9 in range(
max(N_8 // X[9] - i, 0), N_8 // X[9] + 1
):
N_9 = N_8 - X[9] * i_9
i_10 = N_9 // 6
N_10 = N_9 - X[10] * i_10
if (
ANS
> i_0
+ i_1
+ i_2
+ i_3
+ i_4
+ i_5
+ i_6
+ i_7
+ i_8
+ i_9
+ i_10
+ N_10
):
ANS = (
i_0
+ i_1
+ i_2
+ i_3
+ i_4
+ i_5
+ i_6
+ i_7
+ i_8
+ i_9
+ i_10
+ N_10
)
print(ANS)
| false | 53.061224 | [
"-DP = [i for i in range(100001)]",
"-",
"-",
"-def dpmin(i):",
"- Y = i",
"- for j in X:",
"- if i - j >= 0:",
"- Y = min(Y, DP[i - j] + 1)",
"- return Y",
"-",
"-",
"-for i in range(100001):",
"- DP[i] = dpmin(i)",
"-print((DP[N]))",
"+ANS = 1000000",
"+i = 4",
"+for i_0 in range(max(N // X[0] - i, 0), N // X[0] + 1):",
"+ N_0 = N - X[0] * i_0",
"+ for i_1 in range(max(N_0 // X[1] - i, 0), N_0 // X[1] + 1):",
"+ N_1 = N_0 - X[1] * i_1",
"+ for i_2 in range(max(N_1 // X[2] - i, 0), N_1 // X[2] + 1):",
"+ N_2 = N_1 - X[2] * i_2",
"+ for i_3 in range(max(N_2 // X[3] - i, 0), N_2 // X[3] + 1):",
"+ N_3 = N_2 - X[3] * i_3",
"+ for i_4 in range(max(N_3 // X[4] - i, 0), N_3 // X[4] + 1):",
"+ N_4 = N_3 - X[4] * i_4",
"+ for i_5 in range(max(N_4 // X[5] - i, 0), N_4 // X[5] + 1):",
"+ N_5 = N_4 - X[5] * i_5",
"+ for i_6 in range(max(N_5 // X[6] - i, 0), N_5 // X[6] + 1):",
"+ N_6 = N_5 - X[6] * i_6",
"+ for i_7 in range(max(N_6 // X[7] - i, 0), N_6 // X[7] + 1):",
"+ N_7 = N_6 - X[7] * i_7",
"+ for i_8 in range(",
"+ max(N_7 // X[8] - i, 0), N_7 // X[8] + 1",
"+ ):",
"+ N_8 = N_7 - X[8] * i_8",
"+ for i_9 in range(",
"+ max(N_8 // X[9] - i, 0), N_8 // X[9] + 1",
"+ ):",
"+ N_9 = N_8 - X[9] * i_9",
"+ i_10 = N_9 // 6",
"+ N_10 = N_9 - X[10] * i_10",
"+ if (",
"+ ANS",
"+ > i_0",
"+ + i_1",
"+ + i_2",
"+ + i_3",
"+ + i_4",
"+ + i_5",
"+ + i_6",
"+ + i_7",
"+ + i_8",
"+ + i_9",
"+ + i_10",
"+ + N_10",
"+ ):",
"+ ANS = (",
"+ i_0",
"+ + i_1",
"+ + i_2",
"+ + i_3",
"+ + i_4",
"+ + i_5",
"+ + i_6",
"+ + i_7",
"+ + i_8",
"+ + i_9",
"+ + i_10",
"+ + N_10",
"+ )",
"+print(ANS)"
] | false | 1.906303 | 0.102146 | 18.662551 | [
"s051091422",
"s288712695"
] |
u172147273 | p02819 | python | s758256300 | s225328059 | 39 | 18 | 2,940 | 3,060 | Accepted | Accepted | 53.85 | import math
x=int(eval(input()))
flag=True
if x==2:
print(x)
else:
while flag:
i=2
f=True
while i<x and f:
if x%i==0:
f=False
i+=1
if f==True:
print(x)
flag=False
else:
x+=1
| import math
x=int(eval(input()))
flag=True
if x==2:
print(x)
else:
while flag:
i=2
f=True
while i<math.sqrt(x) and f:
if x%i==0:
f=False
i+=1
if f==True:
print(x)
flag=False
else:
x+=1
| 27 | 27 | 327 | 338 | import math
x = int(eval(input()))
flag = True
if x == 2:
print(x)
else:
while flag:
i = 2
f = True
while i < x and f:
if x % i == 0:
f = False
i += 1
if f == True:
print(x)
flag = False
else:
x += 1
| import math
x = int(eval(input()))
flag = True
if x == 2:
print(x)
else:
while flag:
i = 2
f = True
while i < math.sqrt(x) and f:
if x % i == 0:
f = False
i += 1
if f == True:
print(x)
flag = False
else:
x += 1
| false | 0 | [
"- while i < x and f:",
"+ while i < math.sqrt(x) and f:"
] | false | 0.046848 | 0.041144 | 1.138644 | [
"s758256300",
"s225328059"
] |
u600402037 | p02715 | python | s358468108 | s352997120 | 457 | 375 | 84,216 | 70,128 | Accepted | Accepted | 17.94 | # coding: utf-8
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def make_divisors(n): # nの約数を列挙
divisors = []
for i in range(1, int(n**0.5)+1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n//i)
divisors.sort()
return divisors
# 最大公約数が1から順番に数える
MOD = 10 ** 9 + 7
N, K = lr()
answer = 0
reset = [0] * (K+1)
for i in range(1, K+1):
num = K // i
cmb = pow(num, N, MOD)
arr = make_divisors(i)
x = i
for a in arr[:-1]:
x -= reset[a]
reset[i] = x
answer += x * cmb
print((answer % MOD))
| # coding: utf-8
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
MOD = 10 ** 9 + 7
# gcdがNから順に数える、resetを用意、約数をそれぞれ引く
def make_divisors(n): # nの約数を列挙
divisors = []
for i in range(1, int(n**0.5)+1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n//i)
divisors.sort()
return divisors
N, K = lr()
answer = 0
reset = [0] * (K+1)
for x in range(K, 0, -1):
#gcdがx
nums = K // x
add = pow(nums, N, MOD)
add -= reset[x]
answer += add * x
answer %= MOD
divs = make_divisors(x)
for d in divs:
reset[d] += add
print((answer%MOD))
| 33 | 35 | 707 | 750 | # coding: utf-8
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def make_divisors(n): # nの約数を列挙
divisors = []
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n // i)
divisors.sort()
return divisors
# 最大公約数が1から順番に数える
MOD = 10**9 + 7
N, K = lr()
answer = 0
reset = [0] * (K + 1)
for i in range(1, K + 1):
num = K // i
cmb = pow(num, N, MOD)
arr = make_divisors(i)
x = i
for a in arr[:-1]:
x -= reset[a]
reset[i] = x
answer += x * cmb
print((answer % MOD))
| # coding: utf-8
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
MOD = 10**9 + 7
# gcdがNから順に数える、resetを用意、約数をそれぞれ引く
def make_divisors(n): # nの約数を列挙
divisors = []
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n // i)
divisors.sort()
return divisors
N, K = lr()
answer = 0
reset = [0] * (K + 1)
for x in range(K, 0, -1):
# gcdがx
nums = K // x
add = pow(nums, N, MOD)
add -= reset[x]
answer += add * x
answer %= MOD
divs = make_divisors(x)
for d in divs:
reset[d] += add
print((answer % MOD))
| false | 5.714286 | [
"-",
"-",
"+MOD = 10**9 + 7",
"+# gcdがNから順に数える、resetを用意、約数をそれぞれ引く",
"-# 最大公約数が1から順番に数える",
"-MOD = 10**9 + 7",
"-for i in range(1, K + 1):",
"- num = K // i",
"- cmb = pow(num, N, MOD)",
"- arr = make_divisors(i)",
"- x = i",
"- for a in arr[:-1]:",
"- x -= reset[a]",
"- reset[i] = x",
"- answer += x * cmb",
"+for x in range(K, 0, -1):",
"+ # gcdがx",
"+ nums = K // x",
"+ add = pow(nums, N, MOD)",
"+ add -= reset[x]",
"+ answer += add * x",
"+ answer %= MOD",
"+ divs = make_divisors(x)",
"+ for d in divs:",
"+ reset[d] += add"
] | false | 0.263929 | 0.260023 | 1.015023 | [
"s358468108",
"s352997120"
] |
u999750647 | p02641 | python | s192657374 | s251974332 | 103 | 22 | 27,160 | 9,184 | Accepted | Accepted | 78.64 | import numpy as np
x,n = list(map(int,input().split()))
p = list(map(int,input().split()))
q = []
for i in range(-101,102):
q.append(i)
for i in range(n):
q.remove(p[i-1])
def getNearestValue(list, num):
# リスト要素と対象値の差分を計算し最小値のインデックスを取得
idx = np.abs(np.asarray(list) - num).argmin()
return list[idx]
print((getNearestValue(q, x))) | import sys
X, N = list(map(int, input().split()))
x = list(map(int, input().split()))
for i in range(101):
if X-i not in x:
print((X-i))
sys.exit()
elif X+i not in x:
print((X+i))
sys.exit() | 17 | 11 | 361 | 211 | import numpy as np
x, n = list(map(int, input().split()))
p = list(map(int, input().split()))
q = []
for i in range(-101, 102):
q.append(i)
for i in range(n):
q.remove(p[i - 1])
def getNearestValue(list, num):
# リスト要素と対象値の差分を計算し最小値のインデックスを取得
idx = np.abs(np.asarray(list) - num).argmin()
return list[idx]
print((getNearestValue(q, x)))
| import sys
X, N = list(map(int, input().split()))
x = list(map(int, input().split()))
for i in range(101):
if X - i not in x:
print((X - i))
sys.exit()
elif X + i not in x:
print((X + i))
sys.exit()
| false | 35.294118 | [
"-import numpy as np",
"+import sys",
"-x, n = list(map(int, input().split()))",
"-p = list(map(int, input().split()))",
"-q = []",
"-for i in range(-101, 102):",
"- q.append(i)",
"-for i in range(n):",
"- q.remove(p[i - 1])",
"-",
"-",
"-def getNearestValue(list, num):",
"- # リスト要素と対象値の差分を計算し最小値のインデックスを取得",
"- idx = np.abs(np.asarray(list) - num).argmin()",
"- return list[idx]",
"-",
"-",
"-print((getNearestValue(q, x)))",
"+X, N = list(map(int, input().split()))",
"+x = list(map(int, input().split()))",
"+for i in range(101):",
"+ if X - i not in x:",
"+ print((X - i))",
"+ sys.exit()",
"+ elif X + i not in x:",
"+ print((X + i))",
"+ sys.exit()"
] | false | 1.059508 | 0.044214 | 23.963347 | [
"s192657374",
"s251974332"
] |
u811817592 | p02756 | python | s113286058 | s048636034 | 731 | 449 | 4,596 | 4,596 | Accepted | Accepted | 38.58 | # -*- coding: utf-8 -*-
S = str(eval(input()))
Q = int(eval(input()))
rev_flag = 1
head_str = ""
tail_str = ""
for _ in range(Q):
query = list(map(str, input().split()))
if query[0] == "1":
rev_flag *= -1
else:
h_or_t_flag = 1 if query[1] == "1" else -1
h_or_t_flag *= rev_flag
if h_or_t_flag == 1:
head_str += query[2]
else:
tail_str += query[2]
ans = head_str[::-1] + S + tail_str
print((ans if rev_flag == 1 else ans[::-1])) | # -*- coding: utf-8 -*-
S = str(eval(input()))
Q = int(eval(input()))
rev_flag = 1
head_str = ""
tail_str = ""
for _ in range(Q):
query = str(eval(input())) # contains spaces
if query[0] == "1":
rev_flag *= -1
else:
h_or_t_flag = 1 if query[2] == "1" else -1
h_or_t_flag *= rev_flag
if h_or_t_flag == 1:
head_str += query[4]
else:
tail_str += query[4]
ans = head_str[::-1] + S + tail_str
print((ans if rev_flag == 1 else ans[::-1])) | 22 | 22 | 521 | 520 | # -*- coding: utf-8 -*-
S = str(eval(input()))
Q = int(eval(input()))
rev_flag = 1
head_str = ""
tail_str = ""
for _ in range(Q):
query = list(map(str, input().split()))
if query[0] == "1":
rev_flag *= -1
else:
h_or_t_flag = 1 if query[1] == "1" else -1
h_or_t_flag *= rev_flag
if h_or_t_flag == 1:
head_str += query[2]
else:
tail_str += query[2]
ans = head_str[::-1] + S + tail_str
print((ans if rev_flag == 1 else ans[::-1]))
| # -*- coding: utf-8 -*-
S = str(eval(input()))
Q = int(eval(input()))
rev_flag = 1
head_str = ""
tail_str = ""
for _ in range(Q):
query = str(eval(input())) # contains spaces
if query[0] == "1":
rev_flag *= -1
else:
h_or_t_flag = 1 if query[2] == "1" else -1
h_or_t_flag *= rev_flag
if h_or_t_flag == 1:
head_str += query[4]
else:
tail_str += query[4]
ans = head_str[::-1] + S + tail_str
print((ans if rev_flag == 1 else ans[::-1]))
| false | 0 | [
"- query = list(map(str, input().split()))",
"+ query = str(eval(input())) # contains spaces",
"- h_or_t_flag = 1 if query[1] == \"1\" else -1",
"+ h_or_t_flag = 1 if query[2] == \"1\" else -1",
"- head_str += query[2]",
"+ head_str += query[4]",
"- tail_str += query[2]",
"+ tail_str += query[4]"
] | false | 0.046315 | 0.035257 | 1.313634 | [
"s113286058",
"s048636034"
] |
u888092736 | p02597 | python | s474708086 | s711125728 | 107 | 55 | 9,764 | 9,636 | Accepted | Accepted | 48.6 | from collections import Counter
N = int(eval(input()))
C = eval(input())
C_cntr = Counter(C)
all_R_cnt = 0
all_W_cnt = 0
R_W_cnt = 0
for i in range(N):
if C[i] == "W":
all_R_cnt += 1
elif C[i] == "R":
all_W_cnt += 1
if i < C_cntr.get("R", 0) and C[i] == "W":
R_W_cnt += 1
print((min(all_R_cnt, all_W_cnt, R_W_cnt)))
| from collections import Counter
N = int(eval(input()))
C = eval(input())
C_cntr = Counter(C)
ans = 0
for i in range(C_cntr["R"]):
if C[i] == "W":
ans += 1
print(ans)
| 19 | 13 | 360 | 182 | from collections import Counter
N = int(eval(input()))
C = eval(input())
C_cntr = Counter(C)
all_R_cnt = 0
all_W_cnt = 0
R_W_cnt = 0
for i in range(N):
if C[i] == "W":
all_R_cnt += 1
elif C[i] == "R":
all_W_cnt += 1
if i < C_cntr.get("R", 0) and C[i] == "W":
R_W_cnt += 1
print((min(all_R_cnt, all_W_cnt, R_W_cnt)))
| from collections import Counter
N = int(eval(input()))
C = eval(input())
C_cntr = Counter(C)
ans = 0
for i in range(C_cntr["R"]):
if C[i] == "W":
ans += 1
print(ans)
| false | 31.578947 | [
"-all_R_cnt = 0",
"-all_W_cnt = 0",
"-R_W_cnt = 0",
"-for i in range(N):",
"+ans = 0",
"+for i in range(C_cntr[\"R\"]):",
"- all_R_cnt += 1",
"- elif C[i] == \"R\":",
"- all_W_cnt += 1",
"- if i < C_cntr.get(\"R\", 0) and C[i] == \"W\":",
"- R_W_cnt += 1",
"-print((min(all_R_cnt, all_W_cnt, R_W_cnt)))",
"+ ans += 1",
"+print(ans)"
] | false | 0.034812 | 0.035635 | 0.97688 | [
"s474708086",
"s711125728"
] |
u397496203 | p03611 | python | s276605590 | s514364203 | 142 | 116 | 37,688 | 84,568 | Accepted | Accepted | 18.31 | import numpy as np
N = int(eval(input()))
A = np.array(input().split(), dtype = np.int32)
counter = np.bincount(A)
if len(counter) <= 2:
answer = counter.sum()
else:
answer = (counter[2:] + counter[1:-1] + counter[:-2]).max()
print(answer) | from collections import Counter
n = int(eval(input()))
A = [int(i) for i in input().split()]
counts = Counter(A)
ans = 0
for k, v in list(counts.items()):
tmp = v
if k + 1 in list(counts.keys()):
tmp += counts[k + 1]
if k - 1 in list(counts.keys()):
tmp += counts[k - 1]
ans = max(tmp, ans)
print(ans)
| 10 | 16 | 248 | 328 | import numpy as np
N = int(eval(input()))
A = np.array(input().split(), dtype=np.int32)
counter = np.bincount(A)
if len(counter) <= 2:
answer = counter.sum()
else:
answer = (counter[2:] + counter[1:-1] + counter[:-2]).max()
print(answer)
| from collections import Counter
n = int(eval(input()))
A = [int(i) for i in input().split()]
counts = Counter(A)
ans = 0
for k, v in list(counts.items()):
tmp = v
if k + 1 in list(counts.keys()):
tmp += counts[k + 1]
if k - 1 in list(counts.keys()):
tmp += counts[k - 1]
ans = max(tmp, ans)
print(ans)
| false | 37.5 | [
"-import numpy as np",
"+from collections import Counter",
"-N = int(eval(input()))",
"-A = np.array(input().split(), dtype=np.int32)",
"-counter = np.bincount(A)",
"-if len(counter) <= 2:",
"- answer = counter.sum()",
"-else:",
"- answer = (counter[2:] + counter[1:-1] + counter[:-2]).max()",
"-print(answer)",
"+n = int(eval(input()))",
"+A = [int(i) for i in input().split()]",
"+counts = Counter(A)",
"+ans = 0",
"+for k, v in list(counts.items()):",
"+ tmp = v",
"+ if k + 1 in list(counts.keys()):",
"+ tmp += counts[k + 1]",
"+ if k - 1 in list(counts.keys()):",
"+ tmp += counts[k - 1]",
"+ ans = max(tmp, ans)",
"+print(ans)"
] | false | 0.172959 | 0.074436 | 2.3236 | [
"s276605590",
"s514364203"
] |
u075304271 | p02888 | python | s447937686 | s891895690 | 978 | 528 | 10,684 | 10,576 | Accepted | Accepted | 46.01 | import math
import collections
import fractions
import itertools
import functools
import operator
import bisect
def solve():
n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
res = 0
for i in range(n):
for j in range(i+1, n):
k = bisect.bisect_left(l, l[i]+l[j])
res += max(k-(j+1), 0)
print(res)
return 0
if __name__ == "__main__":
solve() | import math
import collections
import fractions
import itertools
import functools
import operator
import bisect
def solve():
n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
res = 0
for i in range(n):
k = i
for j in range(i+1, n):
while(k < n and l[k] < l[i]+l[j]):
k += 1
res += k - (j+1)
print(res)
return 0
if __name__ == "__main__":
solve() | 22 | 24 | 439 | 470 | import math
import collections
import fractions
import itertools
import functools
import operator
import bisect
def solve():
n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
res = 0
for i in range(n):
for j in range(i + 1, n):
k = bisect.bisect_left(l, l[i] + l[j])
res += max(k - (j + 1), 0)
print(res)
return 0
if __name__ == "__main__":
solve()
| import math
import collections
import fractions
import itertools
import functools
import operator
import bisect
def solve():
n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
res = 0
for i in range(n):
k = i
for j in range(i + 1, n):
while k < n and l[k] < l[i] + l[j]:
k += 1
res += k - (j + 1)
print(res)
return 0
if __name__ == "__main__":
solve()
| false | 8.333333 | [
"+ k = i",
"- k = bisect.bisect_left(l, l[i] + l[j])",
"- res += max(k - (j + 1), 0)",
"+ while k < n and l[k] < l[i] + l[j]:",
"+ k += 1",
"+ res += k - (j + 1)"
] | false | 0.124938 | 0.044907 | 2.782132 | [
"s447937686",
"s891895690"
] |
u588341295 | p03965 | python | s752424220 | s610410912 | 67 | 26 | 5,324 | 3,564 | Accepted | Accepted | 61.19 | # -*- coding: utf-8 -*-
import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits
def input(): return sys.stdin.readline().strip()
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7
S = eval(input())
N = len(S)
T = 'gp' * (N//2) + 'g' * (N%2)
cnt = 0
for i in range(N):
if S[i] == 'g' and T[i] == 'p':
cnt += 1
elif S[i] == 'p' and T[i] == 'g':
cnt -= 1
print(cnt)
| # -*- coding: utf-8 -*-
import sys
from collections import Counter
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7
S = eval(input())
C = Counter(S)
ans = (C['g'] - C['p']) // 2
print(ans)
| 33 | 26 | 987 | 802 | # -*- coding: utf-8 -*-
import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits
def input():
return sys.stdin.readline().strip()
def INT():
return int(eval(input()))
def MAP():
return list(map(int, input().split()))
def LIST():
return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
INF = float("inf")
MOD = 10**9 + 7
S = eval(input())
N = len(S)
T = "gp" * (N // 2) + "g" * (N % 2)
cnt = 0
for i in range(N):
if S[i] == "g" and T[i] == "p":
cnt += 1
elif S[i] == "p" and T[i] == "g":
cnt -= 1
print(cnt)
| # -*- coding: utf-8 -*-
import sys
from collections import Counter
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [[c] * b for i in range(a)]
def list3d(a, b, c, d):
return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e):
return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1):
return int(-(-x // y))
def INT():
return int(eval(input()))
def MAP():
return list(map(int, input().split()))
def LIST(N=None):
return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes():
print("Yes")
def No():
print("No")
def YES():
print("YES")
def NO():
print("NO")
sys.setrecursionlimit(10**9)
INF = 10**18
MOD = 10**9 + 7
S = eval(input())
C = Counter(S)
ans = (C["g"] - C["p"]) // 2
print(ans)
| false | 21.212121 | [
"-import sys, re",
"-from collections import deque, defaultdict, Counter",
"-from math import sqrt, hypot, factorial, pi, sin, cos, radians",
"-from heapq import heappop, heappush, heapify, heappushpop",
"-from bisect import bisect_left, bisect_right",
"-from itertools import permutations, combinations, product",
"-from operator import itemgetter, mul",
"-from copy import deepcopy",
"-from functools import reduce, partial",
"-from fractions import Fraction",
"-from string import ascii_lowercase, ascii_uppercase, digits",
"+import sys",
"+from collections import Counter",
"+",
"+",
"+def list2d(a, b, c):",
"+ return [[c] * b for i in range(a)]",
"+",
"+",
"+def list3d(a, b, c, d):",
"+ return [[[d] * c for j in range(b)] for i in range(a)]",
"+",
"+",
"+def list4d(a, b, c, d, e):",
"+ return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]",
"+",
"+",
"+def ceil(x, y=1):",
"+ return int(-(-x // y))",
"-def LIST():",
"- return list(map(int, input().split()))",
"+def LIST(N=None):",
"+ return list(MAP()) if N is None else [INT() for i in range(N)]",
"+",
"+",
"+def Yes():",
"+ print(\"Yes\")",
"+",
"+",
"+def No():",
"+ print(\"No\")",
"+",
"+",
"+def YES():",
"+ print(\"YES\")",
"+",
"+",
"+def NO():",
"+ print(\"NO\")",
"-INF = float(\"inf\")",
"+INF = 10**18",
"-N = len(S)",
"-T = \"gp\" * (N // 2) + \"g\" * (N % 2)",
"-cnt = 0",
"-for i in range(N):",
"- if S[i] == \"g\" and T[i] == \"p\":",
"- cnt += 1",
"- elif S[i] == \"p\" and T[i] == \"g\":",
"- cnt -= 1",
"-print(cnt)",
"+C = Counter(S)",
"+ans = (C[\"g\"] - C[\"p\"]) // 2",
"+print(ans)"
] | false | 0.037994 | 0.03848 | 0.987381 | [
"s752424220",
"s610410912"
] |
u503227287 | p03478 | python | s451512461 | s286481643 | 207 | 180 | 42,092 | 39,536 | Accepted | Accepted | 13.04 | from sys import stdin
if __name__ == "__main__":
_in = [_.rstrip() for _ in stdin.readlines()]
N, A, B = list(map(int,_in[0].split(' '))) # type:list(int)
# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
cnt = 0
for n in range(N+1):
_sum = sum(list(map(int,list(str(n)))))
if A <= _sum <= B:
cnt += n
## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
print(cnt)
| from sys import stdin
def find_sum_of_digits(n, base=10):
_sum = 0
while n>0:
_sum += n%base
n //= base
return _sum
if __name__ == "__main__":
_in = [_.rstrip() for _ in stdin.readlines()]
N, A, B = list(map(int,_in[0].split(' '))) # type:list(int)
# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
cnt = 0
for n in range(1,N+1):
_sum = find_sum_of_digits(n)
if A <= _sum <= B:
cnt += n
## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
print(cnt)
| 14 | 22 | 444 | 567 | from sys import stdin
if __name__ == "__main__":
_in = [_.rstrip() for _ in stdin.readlines()]
N, A, B = list(map(int, _in[0].split(" "))) # type:list(int)
# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
cnt = 0
for n in range(N + 1):
_sum = sum(list(map(int, list(str(n)))))
if A <= _sum <= B:
cnt += n
## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
print(cnt)
| from sys import stdin
def find_sum_of_digits(n, base=10):
_sum = 0
while n > 0:
_sum += n % base
n //= base
return _sum
if __name__ == "__main__":
_in = [_.rstrip() for _ in stdin.readlines()]
N, A, B = list(map(int, _in[0].split(" "))) # type:list(int)
# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
cnt = 0
for n in range(1, N + 1):
_sum = find_sum_of_digits(n)
if A <= _sum <= B:
cnt += n
## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
print(cnt)
| false | 36.363636 | [
"+",
"+",
"+def find_sum_of_digits(n, base=10):",
"+ _sum = 0",
"+ while n > 0:",
"+ _sum += n % base",
"+ n //= base",
"+ return _sum",
"+",
"- for n in range(N + 1):",
"- _sum = sum(list(map(int, list(str(n)))))",
"+ for n in range(1, N + 1):",
"+ _sum = find_sum_of_digits(n)"
] | false | 0.047319 | 0.132186 | 0.357971 | [
"s451512461",
"s286481643"
] |
u185896732 | p02981 | python | s986931026 | s301202687 | 184 | 168 | 38,384 | 38,384 | Accepted | Accepted | 8.7 | n,a,b=list(map(int,input().split()))
print((min(n*a,b))) | n,a,b=list(map(int,input().split()))
print((min(a*n,b))) | 2 | 2 | 49 | 49 | n, a, b = list(map(int, input().split()))
print((min(n * a, b)))
| n, a, b = list(map(int, input().split()))
print((min(a * n, b)))
| false | 0 | [
"-print((min(n * a, b)))",
"+print((min(a * n, b)))"
] | false | 0.008059 | 0.040675 | 0.19813 | [
"s986931026",
"s301202687"
] |
u089230684 | p03962 | python | s656881885 | s765683014 | 18 | 16 | 3,064 | 2,940 | Accepted | Accepted | 11.11 | l=list(map(int,input().split()))
ls=[]
for i in l:
ls.append(i)
k=set(ls)
print((len(k))) | a,b,c=input().split()
if a==b==c:
print("1")
elif a==b or b==c or c==a:
print("2")
else:
print("3") | 6 | 8 | 91 | 119 | l = list(map(int, input().split()))
ls = []
for i in l:
ls.append(i)
k = set(ls)
print((len(k)))
| a, b, c = input().split()
if a == b == c:
print("1")
elif a == b or b == c or c == a:
print("2")
else:
print("3")
| false | 25 | [
"-l = list(map(int, input().split()))",
"-ls = []",
"-for i in l:",
"- ls.append(i)",
"-k = set(ls)",
"-print((len(k)))",
"+a, b, c = input().split()",
"+if a == b == c:",
"+ print(\"1\")",
"+elif a == b or b == c or c == a:",
"+ print(\"2\")",
"+else:",
"+ print(\"3\")"
] | false | 0.035432 | 0.036186 | 0.979168 | [
"s656881885",
"s765683014"
] |
u307622233 | p02686 | python | s661680257 | s135004977 | 1,794 | 1,042 | 171,232 | 234,948 | Accepted | Accepted | 41.92 | def count_scan(s):
max_min = 0
compare = 0
for c in s:
if c == '(':
compare += 1
elif c == ')':
compare -= 1
max_min = min(max_min, compare)
return min(max_min, compare), compare
def key(lst):
m, c = lst
if c > 0:
return 1, m
else:
return -1, c - m
def main():
n = int(eval(input()))
lst = [eval(input()) for _ in range(n)]
txt = 'No'
ans = 0
for max_min, c in sorted([count_scan(s) for s in lst],
reverse=True,
key=key):
if max_min + ans < 0:
break
ans += c
else:
if ans == 0:
txt = 'Yes'
print(txt)
if __name__ == '__main__':
main()
| import sys
input = sys.stdin.readline
# up_list = []
# down_list = []
def count_scan(s):
max_min = 0
compare = 0
for c in s:
if c == '(':
compare += 1
elif c == ')':
compare -= 1
max_min = min(max_min, compare)
return min(max_min, compare), compare
def key(lst):
m, c = lst
if c > 0:
return 1, m
else:
return -1, c - m
def main():
n = int(eval(input()))
lst = [eval(input()) for _ in range(n)]
# up_list.sort(key=lambda x: x[1], reverse=True)
# down_list.sort(key=lambda x: x[1], reverse=False)
txt = 'No'
ans = 0
# print(lst)
# print(sorted([count_scan(lst) for i in lst],
# reverse=True,
# key=key))
for max_min, c in sorted([count_scan(s) for s in lst],
reverse=True,
key=key):
# print(f"{max_min = }, {c = }, {ans = }")
if max_min + ans < 0:
break
ans += c
else:
if ans == 0:
txt = 'Yes'
print(txt)
if __name__ == '__main__':
main() | 42 | 55 | 816 | 1,181 | def count_scan(s):
max_min = 0
compare = 0
for c in s:
if c == "(":
compare += 1
elif c == ")":
compare -= 1
max_min = min(max_min, compare)
return min(max_min, compare), compare
def key(lst):
m, c = lst
if c > 0:
return 1, m
else:
return -1, c - m
def main():
n = int(eval(input()))
lst = [eval(input()) for _ in range(n)]
txt = "No"
ans = 0
for max_min, c in sorted([count_scan(s) for s in lst], reverse=True, key=key):
if max_min + ans < 0:
break
ans += c
else:
if ans == 0:
txt = "Yes"
print(txt)
if __name__ == "__main__":
main()
| import sys
input = sys.stdin.readline
# up_list = []
# down_list = []
def count_scan(s):
max_min = 0
compare = 0
for c in s:
if c == "(":
compare += 1
elif c == ")":
compare -= 1
max_min = min(max_min, compare)
return min(max_min, compare), compare
def key(lst):
m, c = lst
if c > 0:
return 1, m
else:
return -1, c - m
def main():
n = int(eval(input()))
lst = [eval(input()) for _ in range(n)]
# up_list.sort(key=lambda x: x[1], reverse=True)
# down_list.sort(key=lambda x: x[1], reverse=False)
txt = "No"
ans = 0
# print(lst)
# print(sorted([count_scan(lst) for i in lst],
# reverse=True,
# key=key))
for max_min, c in sorted([count_scan(s) for s in lst], reverse=True, key=key):
# print(f"{max_min = }, {c = }, {ans = }")
if max_min + ans < 0:
break
ans += c
else:
if ans == 0:
txt = "Yes"
print(txt)
if __name__ == "__main__":
main()
| false | 23.636364 | [
"+import sys",
"+",
"+input = sys.stdin.readline",
"+# up_list = []",
"+# down_list = []",
"+ # up_list.sort(key=lambda x: x[1], reverse=True)",
"+ # down_list.sort(key=lambda x: x[1], reverse=False)",
"+ # print(lst)",
"+ # print(sorted([count_scan(lst) for i in lst],",
"+ # reverse=True,",
"+ # key=key))",
"+ # print(f\"{max_min = }, {c = }, {ans = }\")"
] | false | 0.078055 | 0.036535 | 2.136442 | [
"s661680257",
"s135004977"
] |
u111652094 | p02707 | python | s641853908 | s120540847 | 265 | 157 | 32,356 | 32,232 | Accepted | Accepted | 40.75 |
N=int(eval(input()))
A=list(map(int,input().split()))
A.sort()
if A[0]==0:
A.remove(0)
l=len(A)
k=0
ans=1
m=max(A)
for i in range(l-1):
if A[i+1]>A[i]:
k=A[i]
print(ans)
while A[i+1]!=k+1:
k=k+1
print((0))
ans=1
else:
ans=ans+1
if A[l-1]==A[l-2]:
print(ans)
else:
print(ans)
for j in range(m+1,N+1):
print((0))
| N=int(eval(input()))
A=list(map(int,input().split()))
L=[0]*N
for i in A:
L[i-1]+=1
for i in range(N):
print((L[i])) | 33 | 12 | 436 | 132 | N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
if A[0] == 0:
A.remove(0)
l = len(A)
k = 0
ans = 1
m = max(A)
for i in range(l - 1):
if A[i + 1] > A[i]:
k = A[i]
print(ans)
while A[i + 1] != k + 1:
k = k + 1
print((0))
ans = 1
else:
ans = ans + 1
if A[l - 1] == A[l - 2]:
print(ans)
else:
print(ans)
for j in range(m + 1, N + 1):
print((0))
| N = int(eval(input()))
A = list(map(int, input().split()))
L = [0] * N
for i in A:
L[i - 1] += 1
for i in range(N):
print((L[i]))
| false | 63.636364 | [
"-A.sort()",
"-if A[0] == 0:",
"- A.remove(0)",
"-l = len(A)",
"-k = 0",
"-ans = 1",
"-m = max(A)",
"-for i in range(l - 1):",
"- if A[i + 1] > A[i]:",
"- k = A[i]",
"- print(ans)",
"- while A[i + 1] != k + 1:",
"- k = k + 1",
"- print((0))",
"- ans = 1",
"- else:",
"- ans = ans + 1",
"-if A[l - 1] == A[l - 2]:",
"- print(ans)",
"-else:",
"- print(ans)",
"-for j in range(m + 1, N + 1):",
"- print((0))",
"+L = [0] * N",
"+for i in A:",
"+ L[i - 1] += 1",
"+for i in range(N):",
"+ print((L[i]))"
] | false | 0.07869 | 0.115953 | 0.678634 | [
"s641853908",
"s120540847"
] |
u183509493 | p03048 | python | s044594614 | s986951461 | 1,980 | 970 | 2,940 | 2,940 | Accepted | Accepted | 51.01 | a,b,c,n=list(map(int,input().split()))
ans=0
for x in range((n+a)//a):
for y in range((n+b-a*x)//b):
z=n-a*x-b*y
if z>=0 and z%c==0:
ans+=1
print(ans)
| a,b,c,n=list(map(int,input().split()))
ans=0
for x in range(0,n+1,a):
for y in range(x,n+1,b):
if (n-y)%c==0:
ans+=1
print(ans)
| 8 | 7 | 168 | 140 | a, b, c, n = list(map(int, input().split()))
ans = 0
for x in range((n + a) // a):
for y in range((n + b - a * x) // b):
z = n - a * x - b * y
if z >= 0 and z % c == 0:
ans += 1
print(ans)
| a, b, c, n = list(map(int, input().split()))
ans = 0
for x in range(0, n + 1, a):
for y in range(x, n + 1, b):
if (n - y) % c == 0:
ans += 1
print(ans)
| false | 12.5 | [
"-for x in range((n + a) // a):",
"- for y in range((n + b - a * x) // b):",
"- z = n - a * x - b * y",
"- if z >= 0 and z % c == 0:",
"+for x in range(0, n + 1, a):",
"+ for y in range(x, n + 1, b):",
"+ if (n - y) % c == 0:"
] | false | 0.104114 | 0.0677 | 1.537882 | [
"s044594614",
"s986951461"
] |
u488401358 | p03291 | python | s383578633 | s083172796 | 293 | 72 | 52,464 | 67,580 | Accepted | Accepted | 75.43 | def main():
S=eval(input())
N=len(S)
abccounter=0
abcounter=0
acounter=0
for i in range(0,N):
if S[i]=='A':
acounter+=1
elif S[i]=='B':
abcounter+=acounter
elif S[i]=='C':
abccounter+=abcounter
hbccounter=0
hbcounter=0
hcounter=0
for i in range(0,N):
if S[i]=='?':
hcounter+=1
elif S[i]=='B':
hbcounter+=hcounter
elif S[i]=='C':
hbccounter+=hbcounter
ahccounter=0
ahcounter=0
acounter=0
for i in range(0,N):
if S[i]=='A':
acounter+=1
elif S[i]=='?':
ahcounter+=acounter
elif S[i]=='C':
ahccounter+=ahcounter
abhcounter=0
abcounter=0
acounter=0
for i in range(0,N):
if S[i]=='A':
acounter+=1
elif S[i]=='B':
abcounter+=acounter
elif S[i]=='?':
abhcounter+=abcounter
ahhcounter=0
ahcounter=0
acounter=0
for i in range(0,N):
if S[i]=='A':
acounter+=1
elif S[i]=='?':
ahhcounter+=ahcounter
ahcounter+=acounter
hbhcounter=0
hbcounter=0
hcounter=0
for i in range(0,N):
if S[i]=='B':
hbcounter+=hcounter
elif S[i]=='?':
hbhcounter+=hbcounter
hcounter+=1
hhccounter=0
hhcounter=0
hcounter=0
for i in range(0,N):
if S[i]=='C':
hhccounter+=hhcounter
elif S[i]=='?':
hhcounter+=hcounter
hcounter+=1
Q=hcounter
if Q>=3:
ans=abccounter*3**Q+(hbccounter+ahccounter+abhcounter)*3**(Q-1)+(ahhcounter+hbhcounter+hhccounter)*3**(Q-2)+(Q*(Q-1)*(Q-2)//6)*3**(Q-3)
elif Q==2:
ans=abccounter*3**Q+(hbccounter+ahccounter+abhcounter)*3**(Q-1)+(ahhcounter+hbhcounter+hhccounter)*3**(Q-2)
elif Q==1:
ans=abccounter*3**Q+(hbccounter+ahccounter+abhcounter)*3**(Q-1)
else:
ans=abccounter*3**Q
print((ans%(10**9+7)))
if __name__ == '__main__':
main()
| s = input().lower()
n = len(s)
dp_a = 0
dp_ab = 0
dp_abc = 0
hatena = 1
mod = 10**9 + 7
for i in range(n):
if s[i]=="a":
dp_a = (dp_a + hatena) % mod
elif s[i]=="b":
dp_ab = (dp_a + dp_ab) % mod
elif s[i]=="c":
dp_abc = (dp_ab + dp_abc) % mod
else:
dp_abc = (dp_ab + 3 * dp_abc) % mod
dp_ab = (3 * dp_ab + dp_a) % mod
dp_a = (3 * dp_a + hatena) % mod
hatena = (hatena * 3) % mod
print(dp_abc)
| 82 | 24 | 2,170 | 492 | def main():
S = eval(input())
N = len(S)
abccounter = 0
abcounter = 0
acounter = 0
for i in range(0, N):
if S[i] == "A":
acounter += 1
elif S[i] == "B":
abcounter += acounter
elif S[i] == "C":
abccounter += abcounter
hbccounter = 0
hbcounter = 0
hcounter = 0
for i in range(0, N):
if S[i] == "?":
hcounter += 1
elif S[i] == "B":
hbcounter += hcounter
elif S[i] == "C":
hbccounter += hbcounter
ahccounter = 0
ahcounter = 0
acounter = 0
for i in range(0, N):
if S[i] == "A":
acounter += 1
elif S[i] == "?":
ahcounter += acounter
elif S[i] == "C":
ahccounter += ahcounter
abhcounter = 0
abcounter = 0
acounter = 0
for i in range(0, N):
if S[i] == "A":
acounter += 1
elif S[i] == "B":
abcounter += acounter
elif S[i] == "?":
abhcounter += abcounter
ahhcounter = 0
ahcounter = 0
acounter = 0
for i in range(0, N):
if S[i] == "A":
acounter += 1
elif S[i] == "?":
ahhcounter += ahcounter
ahcounter += acounter
hbhcounter = 0
hbcounter = 0
hcounter = 0
for i in range(0, N):
if S[i] == "B":
hbcounter += hcounter
elif S[i] == "?":
hbhcounter += hbcounter
hcounter += 1
hhccounter = 0
hhcounter = 0
hcounter = 0
for i in range(0, N):
if S[i] == "C":
hhccounter += hhcounter
elif S[i] == "?":
hhcounter += hcounter
hcounter += 1
Q = hcounter
if Q >= 3:
ans = (
abccounter * 3**Q
+ (hbccounter + ahccounter + abhcounter) * 3 ** (Q - 1)
+ (ahhcounter + hbhcounter + hhccounter) * 3 ** (Q - 2)
+ (Q * (Q - 1) * (Q - 2) // 6) * 3 ** (Q - 3)
)
elif Q == 2:
ans = (
abccounter * 3**Q
+ (hbccounter + ahccounter + abhcounter) * 3 ** (Q - 1)
+ (ahhcounter + hbhcounter + hhccounter) * 3 ** (Q - 2)
)
elif Q == 1:
ans = abccounter * 3**Q + (hbccounter + ahccounter + abhcounter) * 3 ** (
Q - 1
)
else:
ans = abccounter * 3**Q
print((ans % (10**9 + 7)))
if __name__ == "__main__":
main()
| s = input().lower()
n = len(s)
dp_a = 0
dp_ab = 0
dp_abc = 0
hatena = 1
mod = 10**9 + 7
for i in range(n):
if s[i] == "a":
dp_a = (dp_a + hatena) % mod
elif s[i] == "b":
dp_ab = (dp_a + dp_ab) % mod
elif s[i] == "c":
dp_abc = (dp_ab + dp_abc) % mod
else:
dp_abc = (dp_ab + 3 * dp_abc) % mod
dp_ab = (3 * dp_ab + dp_a) % mod
dp_a = (3 * dp_a + hatena) % mod
hatena = (hatena * 3) % mod
print(dp_abc)
| false | 70.731707 | [
"-def main():",
"- S = eval(input())",
"- N = len(S)",
"- abccounter = 0",
"- abcounter = 0",
"- acounter = 0",
"- for i in range(0, N):",
"- if S[i] == \"A\":",
"- acounter += 1",
"- elif S[i] == \"B\":",
"- abcounter += acounter",
"- elif S[i] == \"C\":",
"- abccounter += abcounter",
"- hbccounter = 0",
"- hbcounter = 0",
"- hcounter = 0",
"- for i in range(0, N):",
"- if S[i] == \"?\":",
"- hcounter += 1",
"- elif S[i] == \"B\":",
"- hbcounter += hcounter",
"- elif S[i] == \"C\":",
"- hbccounter += hbcounter",
"- ahccounter = 0",
"- ahcounter = 0",
"- acounter = 0",
"- for i in range(0, N):",
"- if S[i] == \"A\":",
"- acounter += 1",
"- elif S[i] == \"?\":",
"- ahcounter += acounter",
"- elif S[i] == \"C\":",
"- ahccounter += ahcounter",
"- abhcounter = 0",
"- abcounter = 0",
"- acounter = 0",
"- for i in range(0, N):",
"- if S[i] == \"A\":",
"- acounter += 1",
"- elif S[i] == \"B\":",
"- abcounter += acounter",
"- elif S[i] == \"?\":",
"- abhcounter += abcounter",
"- ahhcounter = 0",
"- ahcounter = 0",
"- acounter = 0",
"- for i in range(0, N):",
"- if S[i] == \"A\":",
"- acounter += 1",
"- elif S[i] == \"?\":",
"- ahhcounter += ahcounter",
"- ahcounter += acounter",
"- hbhcounter = 0",
"- hbcounter = 0",
"- hcounter = 0",
"- for i in range(0, N):",
"- if S[i] == \"B\":",
"- hbcounter += hcounter",
"- elif S[i] == \"?\":",
"- hbhcounter += hbcounter",
"- hcounter += 1",
"- hhccounter = 0",
"- hhcounter = 0",
"- hcounter = 0",
"- for i in range(0, N):",
"- if S[i] == \"C\":",
"- hhccounter += hhcounter",
"- elif S[i] == \"?\":",
"- hhcounter += hcounter",
"- hcounter += 1",
"- Q = hcounter",
"- if Q >= 3:",
"- ans = (",
"- abccounter * 3**Q",
"- + (hbccounter + ahccounter + abhcounter) * 3 ** (Q - 1)",
"- + (ahhcounter + hbhcounter + hhccounter) * 3 ** (Q - 2)",
"- + (Q * (Q - 1) * (Q - 2) // 6) * 3 ** (Q - 3)",
"- )",
"- elif Q == 2:",
"- ans = (",
"- abccounter * 3**Q",
"- + (hbccounter + ahccounter + abhcounter) * 3 ** (Q - 1)",
"- + (ahhcounter + hbhcounter + hhccounter) * 3 ** (Q - 2)",
"- )",
"- elif Q == 1:",
"- ans = abccounter * 3**Q + (hbccounter + ahccounter + abhcounter) * 3 ** (",
"- Q - 1",
"- )",
"+s = input().lower()",
"+n = len(s)",
"+dp_a = 0",
"+dp_ab = 0",
"+dp_abc = 0",
"+hatena = 1",
"+mod = 10**9 + 7",
"+for i in range(n):",
"+ if s[i] == \"a\":",
"+ dp_a = (dp_a + hatena) % mod",
"+ elif s[i] == \"b\":",
"+ dp_ab = (dp_a + dp_ab) % mod",
"+ elif s[i] == \"c\":",
"+ dp_abc = (dp_ab + dp_abc) % mod",
"- ans = abccounter * 3**Q",
"- print((ans % (10**9 + 7)))",
"-",
"-",
"-if __name__ == \"__main__\":",
"- main()",
"+ dp_abc = (dp_ab + 3 * dp_abc) % mod",
"+ dp_ab = (3 * dp_ab + dp_a) % mod",
"+ dp_a = (3 * dp_a + hatena) % mod",
"+ hatena = (hatena * 3) % mod",
"+print(dp_abc)"
] | false | 0.043831 | 0.036342 | 1.206088 | [
"s383578633",
"s083172796"
] |
u366959492 | p03220 | python | s914334909 | s503997602 | 20 | 18 | 3,188 | 3,060 | Accepted | Accepted | 10 | n=int(eval(input()))
t,a=list(map(int,input().split()))
h=list(map(int,input().split()))
x=-61
c=[]
if h[0]==81234:
print((3))
exit()
for i in range(n):
T=t-h[i]*0.006
if abs(a-T)<abs(a-x):
c.append(i)
x=T
print((c[-1]+1))
| n = int(eval(input()))
t,a = list(map(int,input().split()))
H = [abs(a-(t-int(x)*0.006)) for x in input().split()]
print((H.index(min(H))+1))
| 14 | 4 | 252 | 131 | n = int(eval(input()))
t, a = list(map(int, input().split()))
h = list(map(int, input().split()))
x = -61
c = []
if h[0] == 81234:
print((3))
exit()
for i in range(n):
T = t - h[i] * 0.006
if abs(a - T) < abs(a - x):
c.append(i)
x = T
print((c[-1] + 1))
| n = int(eval(input()))
t, a = list(map(int, input().split()))
H = [abs(a - (t - int(x) * 0.006)) for x in input().split()]
print((H.index(min(H)) + 1))
| false | 71.428571 | [
"-h = list(map(int, input().split()))",
"-x = -61",
"-c = []",
"-if h[0] == 81234:",
"- print((3))",
"- exit()",
"-for i in range(n):",
"- T = t - h[i] * 0.006",
"- if abs(a - T) < abs(a - x):",
"- c.append(i)",
"- x = T",
"-print((c[-1] + 1))",
"+H = [abs(a - (t - int(x) * 0.006)) for x in input().split()]",
"+print((H.index(min(H)) + 1))"
] | false | 0.041093 | 0.04291 | 0.95765 | [
"s914334909",
"s503997602"
] |
u372144784 | p02788 | python | s363590082 | s370056450 | 1,848 | 1,660 | 111,880 | 96,088 | Accepted | Accepted | 10.17 | import math,bisect
n,d,a = list(map(int,input().split()))
lst1 = [list(map(int,input().split())) for i in range(n)]
lst1.sort()
#解法2 - imos法
"""
単純に座標に対してimos法を行うと、座標の制約は10**9なので間に合わない。
process1
そこで、各モンスターに対して、そのモンスターを左端で攻撃を行った際、右側の巻き込めるモンスターのインデックスを
保存するリストを作る。
process2
これにより、imosのテーブルはn+1個で答えを求めることができる。
また、imosの累積和は順次求めていく感じになる。
"""
x = []
for i in lst1:
x.append(i[0])
#process1
index = 0
reach = []
for i in range(n):
index = bisect.bisect_right(x,lst1[i][0]+2*d)
reach.append(index)
#process2
ans = 0
imos = [0]*(n+1) #その座標に効いている魔法の回数(ダメージ量ではない)
for i in range(n):
if imos[i]*a < lst1[i][1]: #ダメージが足りないなら
need = math.ceil((lst1[i][1]-imos[i]*a)/a)
imos[i] += need
imos[reach[i]] -= need #届かなくなったとこでマイナス
ans += need
imos[i+1] += imos[i] #累積和を逐一とる
print(ans) | import math
from collections import deque
n,d,a = list(map(int,input().split()))
lst1 = [list(map(int,input().split())) for i in range(n)]
lst1.sort()
#解法1 - 貪欲法
"""
キューを使った貪欲法で間に合わせる。
que = [[ダメージ量,そのダメージがどこまで使えるか],...]
とすることにより、高速にダメージ管理をすることができる。
"""
que = deque()
ans = 0
dmg = 0
for i in range(n):
while que:
lim = que.popleft()
if lst1[i][0] > lim[1]:
dmg -= lim[0]
else:
que.appendleft(lim)
break
if lst1[i][1] > dmg:
need = math.ceil((lst1[i][1]-dmg)/a)
ans += need
dmg += need*a
que.append([need*a,lst1[i][0]+2*d])
print(ans)
| 39 | 33 | 852 | 670 | import math, bisect
n, d, a = list(map(int, input().split()))
lst1 = [list(map(int, input().split())) for i in range(n)]
lst1.sort()
# 解法2 - imos法
"""
単純に座標に対してimos法を行うと、座標の制約は10**9なので間に合わない。
process1
そこで、各モンスターに対して、そのモンスターを左端で攻撃を行った際、右側の巻き込めるモンスターのインデックスを
保存するリストを作る。
process2
これにより、imosのテーブルはn+1個で答えを求めることができる。
また、imosの累積和は順次求めていく感じになる。
"""
x = []
for i in lst1:
x.append(i[0])
# process1
index = 0
reach = []
for i in range(n):
index = bisect.bisect_right(x, lst1[i][0] + 2 * d)
reach.append(index)
# process2
ans = 0
imos = [0] * (n + 1) # その座標に効いている魔法の回数(ダメージ量ではない)
for i in range(n):
if imos[i] * a < lst1[i][1]: # ダメージが足りないなら
need = math.ceil((lst1[i][1] - imos[i] * a) / a)
imos[i] += need
imos[reach[i]] -= need # 届かなくなったとこでマイナス
ans += need
imos[i + 1] += imos[i] # 累積和を逐一とる
print(ans)
| import math
from collections import deque
n, d, a = list(map(int, input().split()))
lst1 = [list(map(int, input().split())) for i in range(n)]
lst1.sort()
# 解法1 - 貪欲法
"""
キューを使った貪欲法で間に合わせる。
que = [[ダメージ量,そのダメージがどこまで使えるか],...]
とすることにより、高速にダメージ管理をすることができる。
"""
que = deque()
ans = 0
dmg = 0
for i in range(n):
while que:
lim = que.popleft()
if lst1[i][0] > lim[1]:
dmg -= lim[0]
else:
que.appendleft(lim)
break
if lst1[i][1] > dmg:
need = math.ceil((lst1[i][1] - dmg) / a)
ans += need
dmg += need * a
que.append([need * a, lst1[i][0] + 2 * d])
print(ans)
| false | 15.384615 | [
"-import math, bisect",
"+import math",
"+from collections import deque",
"-# 解法2 - imos法",
"+# 解法1 - 貪欲法",
"-単純に座標に対してimos法を行うと、座標の制約は10**9なので間に合わない。",
"-process1",
"-そこで、各モンスターに対して、そのモンスターを左端で攻撃を行った際、右側の巻き込めるモンスターのインデックスを",
"-保存するリストを作る。",
"-process2",
"-これにより、imosのテーブルはn+1個で答えを求めることができる。",
"-また、imosの累積和は順次求めていく感じになる。",
"+キューを使った貪欲法で間に合わせる。",
"+que = [[ダメージ量,そのダメージがどこまで使えるか],...]",
"+とすることにより、高速にダメージ管理をすることができる。",
"-x = []",
"-for i in lst1:",
"- x.append(i[0])",
"-# process1",
"-index = 0",
"-reach = []",
"+que = deque()",
"+ans = 0",
"+dmg = 0",
"- index = bisect.bisect_right(x, lst1[i][0] + 2 * d)",
"- reach.append(index)",
"-# process2",
"-ans = 0",
"-imos = [0] * (n + 1) # その座標に効いている魔法の回数(ダメージ量ではない)",
"-for i in range(n):",
"- if imos[i] * a < lst1[i][1]: # ダメージが足りないなら",
"- need = math.ceil((lst1[i][1] - imos[i] * a) / a)",
"- imos[i] += need",
"- imos[reach[i]] -= need # 届かなくなったとこでマイナス",
"+ while que:",
"+ lim = que.popleft()",
"+ if lst1[i][0] > lim[1]:",
"+ dmg -= lim[0]",
"+ else:",
"+ que.appendleft(lim)",
"+ break",
"+ if lst1[i][1] > dmg:",
"+ need = math.ceil((lst1[i][1] - dmg) / a)",
"- imos[i + 1] += imos[i] # 累積和を逐一とる",
"+ dmg += need * a",
"+ que.append([need * a, lst1[i][0] + 2 * d])"
] | false | 0.101638 | 0.041815 | 2.430634 | [
"s363590082",
"s370056450"
] |
u729133443 | p03672 | python | s987642854 | s940435360 | 20 | 17 | 3,188 | 2,940 | Accepted | Accepted | 15 | import re;print((len(re.match(r"(.+)\1",input()[:-1]).group()))) | s=input()[:-1];print((max(i*2for i in range(99)if s[:i]==s[i:i*2]))) | 1 | 1 | 62 | 66 | import re
print((len(re.match(r"(.+)\1", input()[:-1]).group())))
| s = input()[:-1]
print((max(i * 2 for i in range(99) if s[:i] == s[i : i * 2])))
| false | 0 | [
"-import re",
"-",
"-print((len(re.match(r\"(.+)\\1\", input()[:-1]).group())))",
"+s = input()[:-1]",
"+print((max(i * 2 for i in range(99) if s[:i] == s[i : i * 2])))"
] | false | 0.075933 | 0.063215 | 1.201189 | [
"s987642854",
"s940435360"
] |
u127499732 | p02948 | python | s272206067 | s171805332 | 207 | 184 | 25,496 | 26,264 | Accepted | Accepted | 11.11 | def main():
import heapq
n, m, *ab = list(map(int, open(0).read().split()))
l = [[] for _ in range(m + 1)]
for i, j in zip(*[iter(ab)] * 2):
if i <= m:
heapq.heappush(l[i], -j)
ans = 0
h = []
for i in range(1, m + 1):
for j in l[i]:
heapq.heappush(h, j)
if len(h) > 0:
x = heapq.heappop(h)
ans += x
print((-ans))
if __name__ == '__main__':
main()
| def main():
from heapq import heappush as sushi
from heapq import heappop as tempra
n, m, *ab = list(map(int, open(0).read().split()))
l = [[] for _ in range(m + 1)]
for i, j in zip(*[iter(ab)] * 2):
if i <= m:
l[i].append(-j)
w = []
h = []
for i in range(1, m + 1):
for j in l[i]:
sushi(h, j)
if len(h) > 0:
x = tempra(h)
w.append(x)
print((-sum(w)))
if __name__ == '__main__':
main()
| 22 | 23 | 476 | 516 | def main():
import heapq
n, m, *ab = list(map(int, open(0).read().split()))
l = [[] for _ in range(m + 1)]
for i, j in zip(*[iter(ab)] * 2):
if i <= m:
heapq.heappush(l[i], -j)
ans = 0
h = []
for i in range(1, m + 1):
for j in l[i]:
heapq.heappush(h, j)
if len(h) > 0:
x = heapq.heappop(h)
ans += x
print((-ans))
if __name__ == "__main__":
main()
| def main():
from heapq import heappush as sushi
from heapq import heappop as tempra
n, m, *ab = list(map(int, open(0).read().split()))
l = [[] for _ in range(m + 1)]
for i, j in zip(*[iter(ab)] * 2):
if i <= m:
l[i].append(-j)
w = []
h = []
for i in range(1, m + 1):
for j in l[i]:
sushi(h, j)
if len(h) > 0:
x = tempra(h)
w.append(x)
print((-sum(w)))
if __name__ == "__main__":
main()
| false | 4.347826 | [
"- import heapq",
"+ from heapq import heappush as sushi",
"+ from heapq import heappop as tempra",
"- heapq.heappush(l[i], -j)",
"- ans = 0",
"+ l[i].append(-j)",
"+ w = []",
"- heapq.heappush(h, j)",
"+ sushi(h, j)",
"- x = heapq.heappop(h)",
"- ans += x",
"- print((-ans))",
"+ x = tempra(h)",
"+ w.append(x)",
"+ print((-sum(w)))"
] | false | 0.059321 | 0.058587 | 1.012527 | [
"s272206067",
"s171805332"
] |
u498487134 | p02804 | python | s873019936 | s272235486 | 271 | 156 | 72,868 | 104,660 | Accepted | Accepted | 42.44 | import sys
input = sys.stdin.readline
N,K=list(map(int,input().split()))
A = list(map(int, input().split()))
A.sort()
def cmb(n, r, mod):
if (r < 0) or (n < r):
return 0
r = min(r, n - r)
return (fact[n] * factinv[r] * factinv[n-r])%mod
mod=10**9 + 7
fact=[1,1]
factinv=[1,1]
inv=[0,1]
for i in range(2, N + 1):
fact.append((fact[-1] * i) % mod)
inv.append((-inv[mod % i] * (mod // i)) % mod)
factinv.append((factinv[-1] * inv[-1]) % mod)
ans=0
for i in range(N-K+1):
ans+=(A[-i-1]-A[i])*cmb(N-i-1,K-1,mod)
ans%=mod
print(ans) | import sys
input = sys.stdin.readline
def I(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def LI(): return list(map(int, input().split()))
def main():
mod=10**9+7
N,K=MI()
A=LI()
A.sort()
#0~Nまで逆元などを事前計算
def cmb(n, r, mod):
if (r < 0) or (n < r):
return 0
r = min(r, n - r)
return (fact[n] * factinv[r] * factinv[n-r])%mod
fact=[1,1]
factinv=[1,1]
inv=[0,1]
for i in range(2, N + 1):
fact.append((fact[-1] * i) % mod)
inv.append((-inv[mod % i] * (mod // i)) % mod)
factinv.append((factinv[-1] * inv[-1]) % mod)
def calc(ii,a):
# ii番目が最大となる時,それの寄与は?
# 0~ii-1のii個からK-1個えらぶ
temp=cmb(ii,K-1,mod)
return (temp*a)%mod
ans=0
for i in range(N):
ans+=calc(i,A[i])
for i in range(N):
A[i]*=-1
A.sort()
for i in range(N):
ans+=calc(i,A[i])
print((ans%mod))
main()
| 27 | 53 | 591 | 1,078 | import sys
input = sys.stdin.readline
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()
def cmb(n, r, mod):
if (r < 0) or (n < r):
return 0
r = min(r, n - r)
return (fact[n] * factinv[r] * factinv[n - r]) % mod
mod = 10**9 + 7
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
for i in range(2, N + 1):
fact.append((fact[-1] * i) % mod)
inv.append((-inv[mod % i] * (mod // i)) % mod)
factinv.append((factinv[-1] * inv[-1]) % mod)
ans = 0
for i in range(N - K + 1):
ans += (A[-i - 1] - A[i]) * cmb(N - i - 1, K - 1, mod)
ans %= mod
print(ans)
| import sys
input = sys.stdin.readline
def I():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
def LI():
return list(map(int, input().split()))
def main():
mod = 10**9 + 7
N, K = MI()
A = LI()
A.sort()
# 0~Nまで逆元などを事前計算
def cmb(n, r, mod):
if (r < 0) or (n < r):
return 0
r = min(r, n - r)
return (fact[n] * factinv[r] * factinv[n - r]) % mod
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
for i in range(2, N + 1):
fact.append((fact[-1] * i) % mod)
inv.append((-inv[mod % i] * (mod // i)) % mod)
factinv.append((factinv[-1] * inv[-1]) % mod)
def calc(ii, a):
# ii番目が最大となる時,それの寄与は?
# 0~ii-1のii個からK-1個えらぶ
temp = cmb(ii, K - 1, mod)
return (temp * a) % mod
ans = 0
for i in range(N):
ans += calc(i, A[i])
for i in range(N):
A[i] *= -1
A.sort()
for i in range(N):
ans += calc(i, A[i])
print((ans % mod))
main()
| false | 49.056604 | [
"-N, K = list(map(int, input().split()))",
"-A = list(map(int, input().split()))",
"-A.sort()",
"-def cmb(n, r, mod):",
"- if (r < 0) or (n < r):",
"- return 0",
"- r = min(r, n - r)",
"- return (fact[n] * factinv[r] * factinv[n - r]) % mod",
"+def I():",
"+ return int(eval(input()))",
"-mod = 10**9 + 7",
"-fact = [1, 1]",
"-factinv = [1, 1]",
"-inv = [0, 1]",
"-for i in range(2, N + 1):",
"- fact.append((fact[-1] * i) % mod)",
"- inv.append((-inv[mod % i] * (mod // i)) % mod)",
"- factinv.append((factinv[-1] * inv[-1]) % mod)",
"-ans = 0",
"-for i in range(N - K + 1):",
"- ans += (A[-i - 1] - A[i]) * cmb(N - i - 1, K - 1, mod)",
"- ans %= mod",
"-print(ans)",
"+def MI():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+def LI():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+def main():",
"+ mod = 10**9 + 7",
"+ N, K = MI()",
"+ A = LI()",
"+ A.sort()",
"+ # 0~Nまで逆元などを事前計算",
"+ def cmb(n, r, mod):",
"+ if (r < 0) or (n < r):",
"+ return 0",
"+ r = min(r, n - r)",
"+ return (fact[n] * factinv[r] * factinv[n - r]) % mod",
"+",
"+ fact = [1, 1]",
"+ factinv = [1, 1]",
"+ inv = [0, 1]",
"+ for i in range(2, N + 1):",
"+ fact.append((fact[-1] * i) % mod)",
"+ inv.append((-inv[mod % i] * (mod // i)) % mod)",
"+ factinv.append((factinv[-1] * inv[-1]) % mod)",
"+",
"+ def calc(ii, a):",
"+ # ii番目が最大となる時,それの寄与は?",
"+ # 0~ii-1のii個からK-1個えらぶ",
"+ temp = cmb(ii, K - 1, mod)",
"+ return (temp * a) % mod",
"+",
"+ ans = 0",
"+ for i in range(N):",
"+ ans += calc(i, A[i])",
"+ for i in range(N):",
"+ A[i] *= -1",
"+ A.sort()",
"+ for i in range(N):",
"+ ans += calc(i, A[i])",
"+ print((ans % mod))",
"+",
"+",
"+main()"
] | false | 0.061263 | 0.061877 | 0.990083 | [
"s873019936",
"s272235486"
] |
u706929073 | p03221 | python | s576216912 | s299884846 | 1,046 | 929 | 62,240 | 52,924 | Accepted | Accepted | 11.19 | (n, m) = list(map(int, input().split()))
cities = []
for _ in range(m):
cities.append(list(map(int, input().split())))
city_dict = {}
for i, city in enumerate(cities):
if not city[0] in city_dict:
city_dict[city[0]] = []
city_dict[city[0]].append([i, city[1], ""])
ans = []
for key, value in list(city_dict.items()):
value.sort(key=lambda x: x[1])
for i, v in enumerate(value):
v[2] = "{}{}".format(str(key).zfill(6), str(i+1).zfill(6))
ans.extend(value)
ans.sort(key=lambda x:x[0])
for a in ans:
print((a[2])) | (n, m) = list(map(int, input().split()))
cities = {}
for i in range(m):
(pref, year) = list(map(int, input().split()))
if not pref in list(cities.keys()):
cities[pref] = []
cities[pref].append((i, year))
def get_id(pref, index):
return "{}{}".format(str(pref).zfill(6), str(index).zfill(6))
ids = []
for key, values in list(cities.items()):
values.sort(key=lambda x: x[1])
for i, value in enumerate(values):
ids.append((value[0], get_id(key, i + 1)))
ids.sort(key=lambda x: x[0])
for id in ids:
print((id[1]))
| 20 | 21 | 561 | 552 | (n, m) = list(map(int, input().split()))
cities = []
for _ in range(m):
cities.append(list(map(int, input().split())))
city_dict = {}
for i, city in enumerate(cities):
if not city[0] in city_dict:
city_dict[city[0]] = []
city_dict[city[0]].append([i, city[1], ""])
ans = []
for key, value in list(city_dict.items()):
value.sort(key=lambda x: x[1])
for i, v in enumerate(value):
v[2] = "{}{}".format(str(key).zfill(6), str(i + 1).zfill(6))
ans.extend(value)
ans.sort(key=lambda x: x[0])
for a in ans:
print((a[2]))
| (n, m) = list(map(int, input().split()))
cities = {}
for i in range(m):
(pref, year) = list(map(int, input().split()))
if not pref in list(cities.keys()):
cities[pref] = []
cities[pref].append((i, year))
def get_id(pref, index):
return "{}{}".format(str(pref).zfill(6), str(index).zfill(6))
ids = []
for key, values in list(cities.items()):
values.sort(key=lambda x: x[1])
for i, value in enumerate(values):
ids.append((value[0], get_id(key, i + 1)))
ids.sort(key=lambda x: x[0])
for id in ids:
print((id[1]))
| false | 4.761905 | [
"-cities = []",
"-for _ in range(m):",
"- cities.append(list(map(int, input().split())))",
"-city_dict = {}",
"-for i, city in enumerate(cities):",
"- if not city[0] in city_dict:",
"- city_dict[city[0]] = []",
"- city_dict[city[0]].append([i, city[1], \"\"])",
"-ans = []",
"-for key, value in list(city_dict.items()):",
"- value.sort(key=lambda x: x[1])",
"- for i, v in enumerate(value):",
"- v[2] = \"{}{}\".format(str(key).zfill(6), str(i + 1).zfill(6))",
"- ans.extend(value)",
"-ans.sort(key=lambda x: x[0])",
"-for a in ans:",
"- print((a[2]))",
"+cities = {}",
"+for i in range(m):",
"+ (pref, year) = list(map(int, input().split()))",
"+ if not pref in list(cities.keys()):",
"+ cities[pref] = []",
"+ cities[pref].append((i, year))",
"+",
"+",
"+def get_id(pref, index):",
"+ return \"{}{}\".format(str(pref).zfill(6), str(index).zfill(6))",
"+",
"+",
"+ids = []",
"+for key, values in list(cities.items()):",
"+ values.sort(key=lambda x: x[1])",
"+ for i, value in enumerate(values):",
"+ ids.append((value[0], get_id(key, i + 1)))",
"+ids.sort(key=lambda x: x[0])",
"+for id in ids:",
"+ print((id[1]))"
] | false | 0.045837 | 0.045612 | 1.004921 | [
"s576216912",
"s299884846"
] |
u844646164 | p03479 | python | s006530973 | s584378704 | 172 | 34 | 38,384 | 9,180 | Accepted | Accepted | 80.23 | x, y = list(map(int, input().split()))
ans = 1
while x <= y:
x *= 2
if x > y:
break
ans += 1
print(ans) | X, Y = list(map(int, input().split()))
ans = 1
while X <= Y:
X *= 2
if X > Y:
break
ans += 1
print(ans) | 9 | 9 | 128 | 126 | x, y = list(map(int, input().split()))
ans = 1
while x <= y:
x *= 2
if x > y:
break
ans += 1
print(ans)
| X, Y = list(map(int, input().split()))
ans = 1
while X <= Y:
X *= 2
if X > Y:
break
ans += 1
print(ans)
| false | 0 | [
"-x, y = list(map(int, input().split()))",
"+X, Y = list(map(int, input().split()))",
"-while x <= y:",
"- x *= 2",
"- if x > y:",
"+while X <= Y:",
"+ X *= 2",
"+ if X > Y:"
] | false | 0.038133 | 0.038522 | 0.989888 | [
"s006530973",
"s584378704"
] |
u973840923 | p03252 | python | s174832455 | s570250737 | 61 | 41 | 3,632 | 4,144 | Accepted | Accepted | 32.79 | word1 = eval(input())
word2 = eval(input())
def cnt_element(x):
dict = {}
for i in x:
if i not in dict:
dict[i] = 1
else:
dict[i] += 1
return sorted([x for x in list(dict.values())],reverse=True)
if cnt_element(word1) == cnt_element(word2):
print('Yes')
else:
print('No') | from collections import Counter
S = eval(input())
T = eval(input())
s = list(Counter(S).values())
t = list(Counter(T).values())
s.sort(reverse=True)
t.sort(reverse=True)
for i,j in zip(s,t):
if i != j:
print('No')
break
else:
print('Yes') | 16 | 16 | 331 | 268 | word1 = eval(input())
word2 = eval(input())
def cnt_element(x):
dict = {}
for i in x:
if i not in dict:
dict[i] = 1
else:
dict[i] += 1
return sorted([x for x in list(dict.values())], reverse=True)
if cnt_element(word1) == cnt_element(word2):
print("Yes")
else:
print("No")
| from collections import Counter
S = eval(input())
T = eval(input())
s = list(Counter(S).values())
t = list(Counter(T).values())
s.sort(reverse=True)
t.sort(reverse=True)
for i, j in zip(s, t):
if i != j:
print("No")
break
else:
print("Yes")
| false | 0 | [
"-word1 = eval(input())",
"-word2 = eval(input())",
"+from collections import Counter",
"-",
"-def cnt_element(x):",
"- dict = {}",
"- for i in x:",
"- if i not in dict:",
"- dict[i] = 1",
"- else:",
"- dict[i] += 1",
"- return sorted([x for x in list(dict.values())], reverse=True)",
"-",
"-",
"-if cnt_element(word1) == cnt_element(word2):",
"+S = eval(input())",
"+T = eval(input())",
"+s = list(Counter(S).values())",
"+t = list(Counter(T).values())",
"+s.sort(reverse=True)",
"+t.sort(reverse=True)",
"+for i, j in zip(s, t):",
"+ if i != j:",
"+ print(\"No\")",
"+ break",
"+else:",
"-else:",
"- print(\"No\")"
] | false | 0.036365 | 0.036778 | 0.988789 | [
"s174832455",
"s570250737"
] |
u189487046 | p02688 | python | s528496796 | s694606999 | 24 | 22 | 9,184 | 9,112 | Accepted | Accepted | 8.33 | N, K = list(map(int, input().split()))
sunuke = [0]*N
for _ in range(K):
d = int(eval(input()))
A = list(map(int, input().split()))
for a in A:
sunuke[a-1] += 1
ans = 0
for i in range(N):
if sunuke[i-1] == 0:
ans += 1
print(ans)
| import sys
sys.setrecursionlimit(10 ** 6)
def input():
return sys.stdin.readline()[:-1]
N, K = list(map(int, input().split()))
A = [0]*N
for _ in range(K):
d = int(eval(input()))
tmp = list(map(int, input().split()))
for a in tmp:
A[a-1] += 1
print((A.count(0)))
| 13 | 17 | 262 | 294 | N, K = list(map(int, input().split()))
sunuke = [0] * N
for _ in range(K):
d = int(eval(input()))
A = list(map(int, input().split()))
for a in A:
sunuke[a - 1] += 1
ans = 0
for i in range(N):
if sunuke[i - 1] == 0:
ans += 1
print(ans)
| import sys
sys.setrecursionlimit(10**6)
def input():
return sys.stdin.readline()[:-1]
N, K = list(map(int, input().split()))
A = [0] * N
for _ in range(K):
d = int(eval(input()))
tmp = list(map(int, input().split()))
for a in tmp:
A[a - 1] += 1
print((A.count(0)))
| false | 23.529412 | [
"+import sys",
"+",
"+sys.setrecursionlimit(10**6)",
"+",
"+",
"+def input():",
"+ return sys.stdin.readline()[:-1]",
"+",
"+",
"-sunuke = [0] * N",
"+A = [0] * N",
"- A = list(map(int, input().split()))",
"- for a in A:",
"- sunuke[a - 1] += 1",
"-ans = 0",
"-for i in range(N):",
"- if sunuke[i - 1] == 0:",
"- ans += 1",
"-print(ans)",
"+ tmp = list(map(int, input().split()))",
"+ for a in tmp:",
"+ A[a - 1] += 1",
"+print((A.count(0)))"
] | false | 0.037323 | 0.042437 | 0.879508 | [
"s528496796",
"s694606999"
] |
u057109575 | p02901 | python | s807476743 | s269026733 | 304 | 206 | 46,040 | 108,600 | Accepted | Accepted | 32.24 | N, M = list(map(int, input().split()))
AB = []
C = []
for _ in range(M):
AB.append(list(map(int, input().split())))
C.append(list(map(int, input().split())))
INF = 10 ** 9 + 7
dp = [INF] * (2 ** N)
dp[0] = 0
for i, ((a, b), c) in enumerate(zip(AB, C)):
num = int("".join(["01"[int(i + 1 in c)] for i in range(N)]), 2)
for j in range(2 ** N):
dp[j | num] = min(dp[j | num], dp[j] + a)
print((dp[-1] if dp[-1] < INF else -1))
| N, M = list(map(int, input().split()))
X = []
Y = []
for _ in range(M):
X.append(list(map(int, input().split())))
tmp = 0
for i in list(map(int, input().split())):
tmp += 2 ** (i - 1)
Y.append(tmp)
inf = 10 ** 9 + 7
dp = [[inf] * (2 ** N) for _ in range(M + 1)]
dp[0][0] = 0
for i in range(M):
for j in range(2 ** N):
dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
dp[i + 1][j | Y[i]] = min(dp[i + 1][j | Y[i]],
dp[i][j] + X[i][0])
ans = min(dp[i][-1] for i in range(M + 1))
print((ans if ans < inf else -1))
| 17 | 23 | 459 | 605 | N, M = list(map(int, input().split()))
AB = []
C = []
for _ in range(M):
AB.append(list(map(int, input().split())))
C.append(list(map(int, input().split())))
INF = 10**9 + 7
dp = [INF] * (2**N)
dp[0] = 0
for i, ((a, b), c) in enumerate(zip(AB, C)):
num = int("".join(["01"[int(i + 1 in c)] for i in range(N)]), 2)
for j in range(2**N):
dp[j | num] = min(dp[j | num], dp[j] + a)
print((dp[-1] if dp[-1] < INF else -1))
| N, M = list(map(int, input().split()))
X = []
Y = []
for _ in range(M):
X.append(list(map(int, input().split())))
tmp = 0
for i in list(map(int, input().split())):
tmp += 2 ** (i - 1)
Y.append(tmp)
inf = 10**9 + 7
dp = [[inf] * (2**N) for _ in range(M + 1)]
dp[0][0] = 0
for i in range(M):
for j in range(2**N):
dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
dp[i + 1][j | Y[i]] = min(dp[i + 1][j | Y[i]], dp[i][j] + X[i][0])
ans = min(dp[i][-1] for i in range(M + 1))
print((ans if ans < inf else -1))
| false | 26.086957 | [
"-AB = []",
"-C = []",
"+X = []",
"+Y = []",
"- AB.append(list(map(int, input().split())))",
"- C.append(list(map(int, input().split())))",
"-INF = 10**9 + 7",
"-dp = [INF] * (2**N)",
"-dp[0] = 0",
"-for i, ((a, b), c) in enumerate(zip(AB, C)):",
"- num = int(\"\".join([\"01\"[int(i + 1 in c)] for i in range(N)]), 2)",
"+ X.append(list(map(int, input().split())))",
"+ tmp = 0",
"+ for i in list(map(int, input().split())):",
"+ tmp += 2 ** (i - 1)",
"+ Y.append(tmp)",
"+inf = 10**9 + 7",
"+dp = [[inf] * (2**N) for _ in range(M + 1)]",
"+dp[0][0] = 0",
"+for i in range(M):",
"- dp[j | num] = min(dp[j | num], dp[j] + a)",
"-print((dp[-1] if dp[-1] < INF else -1))",
"+ dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])",
"+ dp[i + 1][j | Y[i]] = min(dp[i + 1][j | Y[i]], dp[i][j] + X[i][0])",
"+ans = min(dp[i][-1] for i in range(M + 1))",
"+print((ans if ans < inf else -1))"
] | false | 0.034336 | 0.044842 | 0.765723 | [
"s807476743",
"s269026733"
] |
u089230684 | p03697 | python | s300174200 | s777603461 | 17 | 10 | 2,940 | 2,568 | Accepted | Accepted | 41.18 | A, B = [int(x) for x in input().split(" ")]
ans = A + B
print(("error" if ans >= 10 else ans)) | l = list(map(int, input().split()))
ans = l[0] + l[1]
if ans >= 10:
print("error")
else:
print(ans)
| 5 | 10 | 98 | 124 | A, B = [int(x) for x in input().split(" ")]
ans = A + B
print(("error" if ans >= 10 else ans))
| l = list(map(int, input().split()))
ans = l[0] + l[1]
if ans >= 10:
print("error")
else:
print(ans)
| false | 50 | [
"-A, B = [int(x) for x in input().split(\" \")]",
"-ans = A + B",
"-print((\"error\" if ans >= 10 else ans))",
"+l = list(map(int, input().split()))",
"+ans = l[0] + l[1]",
"+if ans >= 10:",
"+ print(\"error\")",
"+else:",
"+ print(ans)"
] | false | 0.036582 | 0.056168 | 0.651285 | [
"s300174200",
"s777603461"
] |
u506689504 | p02689 | python | s770281959 | s231144364 | 431 | 211 | 31,612 | 25,956 | Accepted | Accepted | 51.04 | N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
adj = {i:[] for i in range(N)}
for _ in range(M):
A, B = list(map(int, input().split()))
adj[A-1].append(H[B-1])
adj[B-1].append(H[A-1])
cnt = 0
for v in range(N):
if not adj[v]:
cnt += 1
continue
if H[v] > max(adj[v]):
cnt += 1
print(cnt) | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, M = list(map(int, readline().split()))
H = [0] + list(map(int, readline().split()))
A = [0]*(N+1)
m = list(map(int, read().split()))
for a,b in zip(m,m):
for _ in range(2):
A[a] = max(A[a], H[b])
a,b = b,a
print((sum(x>y for x,y in zip(H, A)))) | 18 | 17 | 333 | 374 | N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
adj = {i: [] for i in range(N)}
for _ in range(M):
A, B = list(map(int, input().split()))
adj[A - 1].append(H[B - 1])
adj[B - 1].append(H[A - 1])
cnt = 0
for v in range(N):
if not adj[v]:
cnt += 1
continue
if H[v] > max(adj[v]):
cnt += 1
print(cnt)
| import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, M = list(map(int, readline().split()))
H = [0] + list(map(int, readline().split()))
A = [0] * (N + 1)
m = list(map(int, read().split()))
for a, b in zip(m, m):
for _ in range(2):
A[a] = max(A[a], H[b])
a, b = b, a
print((sum(x > y for x, y in zip(H, A))))
| false | 5.555556 | [
"-N, M = list(map(int, input().split()))",
"-H = list(map(int, input().split()))",
"-adj = {i: [] for i in range(N)}",
"-for _ in range(M):",
"- A, B = list(map(int, input().split()))",
"- adj[A - 1].append(H[B - 1])",
"- adj[B - 1].append(H[A - 1])",
"-cnt = 0",
"-for v in range(N):",
"- if not adj[v]:",
"- cnt += 1",
"- continue",
"- if H[v] > max(adj[v]):",
"- cnt += 1",
"-print(cnt)",
"+import sys",
"+",
"+read = sys.stdin.buffer.read",
"+readline = sys.stdin.buffer.readline",
"+readlines = sys.stdin.buffer.readlines",
"+N, M = list(map(int, readline().split()))",
"+H = [0] + list(map(int, readline().split()))",
"+A = [0] * (N + 1)",
"+m = list(map(int, read().split()))",
"+for a, b in zip(m, m):",
"+ for _ in range(2):",
"+ A[a] = max(A[a], H[b])",
"+ a, b = b, a",
"+print((sum(x > y for x, y in zip(H, A))))"
] | false | 0.061097 | 0.08629 | 0.70804 | [
"s770281959",
"s231144364"
] |
u634079249 | p03206 | python | s843991979 | s734469601 | 19 | 17 | 2,940 | 3,064 | Accepted | Accepted | 10.53 | import sys
import os
def main():
if os.getenv("LOCAL"):
sys.stdin = open("input.txt", "r")
D = int(sys.stdin.readline().rstrip())
print(('Christmas' + ' Eve'*(25-D)))
if __name__ == '__main__':
main()
| import sys
import os
ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]
iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]
def main():
if os.getenv("LOCAL"):
sys.stdin = open("input.txt", "r")
D = ii()
print(('Christmas' + ' Eve'*(25-D)))
if __name__ == '__main__':
main()
| 15 | 23 | 243 | 703 | import sys
import os
def main():
if os.getenv("LOCAL"):
sys.stdin = open("input.txt", "r")
D = int(sys.stdin.readline().rstrip())
print(("Christmas" + " Eve" * (25 - D)))
if __name__ == "__main__":
main()
| import sys
import os
ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]
iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]
def main():
if os.getenv("LOCAL"):
sys.stdin = open("input.txt", "r")
D = ii()
print(("Christmas" + " Eve" * (25 - D)))
if __name__ == "__main__":
main()
| false | 34.782609 | [
"+",
"+ii = lambda: int(sys.stdin.buffer.readline().rstrip())",
"+il = lambda: list(map(int, sys.stdin.buffer.readline().split()))",
"+fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))",
"+iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]",
"+iss = lambda: sys.stdin.buffer.readline().decode().rstrip()",
"+sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))",
"+isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]",
"- D = int(sys.stdin.readline().rstrip())",
"+ D = ii()"
] | false | 0.04141 | 0.043698 | 0.94763 | [
"s843991979",
"s734469601"
] |
u442030035 | p03319 | python | s440563106 | s126308746 | 25 | 18 | 10,420 | 4,724 | Accepted | Accepted | 28 | N, K = list(map(int, input().split()))
A = input().split()
count = 0
if N == K:
print((1))
else:
count += 1
rem = N-K
add = 1 if (N-K)%(K-1) else 0
count += (N-K)//(K-1) + add
print(count) | N, K = list(map(int, input().split()))
A = eval(input())
add = 1 if (N-1)%(K-1) else 0
print(((N-1)//(K-1) + add)) | 11 | 4 | 214 | 103 | N, K = list(map(int, input().split()))
A = input().split()
count = 0
if N == K:
print((1))
else:
count += 1
rem = N - K
add = 1 if (N - K) % (K - 1) else 0
count += (N - K) // (K - 1) + add
print(count)
| N, K = list(map(int, input().split()))
A = eval(input())
add = 1 if (N - 1) % (K - 1) else 0
print(((N - 1) // (K - 1) + add))
| false | 63.636364 | [
"-A = input().split()",
"-count = 0",
"-if N == K:",
"- print((1))",
"-else:",
"- count += 1",
"- rem = N - K",
"- add = 1 if (N - K) % (K - 1) else 0",
"- count += (N - K) // (K - 1) + add",
"- print(count)",
"+A = eval(input())",
"+add = 1 if (N - 1) % (K - 1) else 0",
"+print(((N - 1) // (K - 1) + add))"
] | false | 0.041572 | 0.035155 | 1.182526 | [
"s440563106",
"s126308746"
] |
u058781705 | p03294 | python | s664971334 | s989145607 | 322 | 62 | 79,916 | 64,808 | Accepted | Accepted | 80.75 | N = int(eval(input()))
As = list(map(int, input().split()))
print((sum(As)-len(As)))
| _ = eval(input())
As = list(map(int, input().split()))
print((sum(As)-len(As)))
| 4 | 4 | 81 | 76 | N = int(eval(input()))
As = list(map(int, input().split()))
print((sum(As) - len(As)))
| _ = eval(input())
As = list(map(int, input().split()))
print((sum(As) - len(As)))
| false | 0 | [
"-N = int(eval(input()))",
"+_ = eval(input())"
] | false | 0.040177 | 0.030991 | 1.296432 | [
"s664971334",
"s989145607"
] |
u129978636 | p03835 | python | s691437392 | s059091006 | 1,268 | 1,035 | 3,060 | 2,940 | Accepted | Accepted | 18.38 | k,s=list(map(int,input().split()))
count=0
for x in range(k+1):
for y in range(k+1):
if(0<=s-x-y<=k):
count+=1
else:continue
print(count) | k,s=list(map(int,input().split()))
print((sum(0<=s-x-y<=k for x in range(k+1) for y in range(k+1)))) | 8 | 2 | 170 | 93 | k, s = list(map(int, input().split()))
count = 0
for x in range(k + 1):
for y in range(k + 1):
if 0 <= s - x - y <= k:
count += 1
else:
continue
print(count)
| k, s = list(map(int, input().split()))
print((sum(0 <= s - x - y <= k for x in range(k + 1) for y in range(k + 1))))
| false | 75 | [
"-count = 0",
"-for x in range(k + 1):",
"- for y in range(k + 1):",
"- if 0 <= s - x - y <= k:",
"- count += 1",
"- else:",
"- continue",
"-print(count)",
"+print((sum(0 <= s - x - y <= k for x in range(k + 1) for y in range(k + 1))))"
] | false | 0.036253 | 0.042133 | 0.860444 | [
"s691437392",
"s059091006"
] |
u875291233 | p03356 | python | s902200590 | s652495923 | 800 | 710 | 13,812 | 15,860 | Accepted | Accepted | 11.25 | class UnionFind:
def __init__(self, size):
self.parent = [-1 for i in range(size)]#非負なら親ノード,負ならグループの要素数
def root(self, x):
if self.parent[x] < 0:
return x
else:
self.parent[x] = self.root(self.parent[x]) #xをxの根に直接つなぐ
return self.parent[x]
def union(self, x, y):
x = self.root(x)
y = self.root(y)
if x == y:
return False
if self.parent[x] < self.parent[y]: #xの要素数がyの要素数より「小さい」とき
x,y=y,x
self.parent[x] += self.parent[y] #xの要素数を更新
self.parent[y] = x #yをxにつなぐ
return True
def same(self, x, y):
return self.root(x) == self.root(y)
n,m = list(map(int,input().split()))
p = list([int(x)-1 for x in input().split()])
uf = UnionFind(n)
for i in range(m):
x,y=list(map(int,input().split()))
uf.union(x-1,y-1)
ans = 0
for i in range(n):
if uf.same(i,p[i]):
ans += 1
print(ans) | class UnionFind:
def __init__(self, size):
self.parent = [-1 for i in range(size)]#非負なら親ノード,負ならグループの要素数
def root(self, x): #root(i): $i$の根ノードを返す.
if self.parent[x] < 0:
return x
else:
self.parent[x] = self.root(self.parent[x]) #xをxの根に直接つなぐ
return self.parent[x]
def union(self, x, y): #union(i,j): $i$のいるグループと$j$のいるグループをまとめる
x = self.root(x)
y = self.root(y)
if x == y:
return False
if self.parent[x] > self.parent[y]: #xの要素数がyの要素数より「小さい」とき
x,y=y,x
self.parent[x] += self.parent[y] #xの要素数を更新
self.parent[y] = x #yをxにつなぐ
return True
def same(self, x, y): #same(i,j): $i$と$j$ が同じグループにあるならTrue,違うならFalse
return self.root(x) == self.root(y)
def size(self,x): #size(i): $i$のいるグループの要素数を返す
return -self.parent[self.root(x)]
#>>>>>>>>>>>>>>EhdCutHere>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
n,m = list(map(int,input().split()))
p = list([int(x)-1 for x in input().split()])
uf = UnionFind(n)
for i in range(m):
x,y=list(map(int,input().split()))
uf.union(x-1,y-1)
ans = 0
for i in range(n):
if uf.same(i,p[i]):
ans += 1
print(ans)
#print([uf.root(i) for i in range(n)])
#print([uf.parent[i] for i in range(n)])
#print([uf.size(i) for i in range(n)])
| 42 | 47 | 1,005 | 1,416 | class UnionFind:
def __init__(self, size):
self.parent = [-1 for i in range(size)] # 非負なら親ノード,負ならグループの要素数
def root(self, x):
if self.parent[x] < 0:
return x
else:
self.parent[x] = self.root(self.parent[x]) # xをxの根に直接つなぐ
return self.parent[x]
def union(self, x, y):
x = self.root(x)
y = self.root(y)
if x == y:
return False
if self.parent[x] < self.parent[y]: # xの要素数がyの要素数より「小さい」とき
x, y = y, x
self.parent[x] += self.parent[y] # xの要素数を更新
self.parent[y] = x # yをxにつなぐ
return True
def same(self, x, y):
return self.root(x) == self.root(y)
n, m = list(map(int, input().split()))
p = list([int(x) - 1 for x in input().split()])
uf = UnionFind(n)
for i in range(m):
x, y = list(map(int, input().split()))
uf.union(x - 1, y - 1)
ans = 0
for i in range(n):
if uf.same(i, p[i]):
ans += 1
print(ans)
| class UnionFind:
def __init__(self, size):
self.parent = [-1 for i in range(size)] # 非負なら親ノード,負ならグループの要素数
def root(self, x): # root(i): $i$の根ノードを返す.
if self.parent[x] < 0:
return x
else:
self.parent[x] = self.root(self.parent[x]) # xをxの根に直接つなぐ
return self.parent[x]
def union(self, x, y): # union(i,j): $i$のいるグループと$j$のいるグループをまとめる
x = self.root(x)
y = self.root(y)
if x == y:
return False
if self.parent[x] > self.parent[y]: # xの要素数がyの要素数より「小さい」とき
x, y = y, x
self.parent[x] += self.parent[y] # xの要素数を更新
self.parent[y] = x # yをxにつなぐ
return True
def same(self, x, y): # same(i,j): $i$と$j$ が同じグループにあるならTrue,違うならFalse
return self.root(x) == self.root(y)
def size(self, x): # size(i): $i$のいるグループの要素数を返す
return -self.parent[self.root(x)]
# >>>>>>>>>>>>>>EhdCutHere>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
n, m = list(map(int, input().split()))
p = list([int(x) - 1 for x in input().split()])
uf = UnionFind(n)
for i in range(m):
x, y = list(map(int, input().split()))
uf.union(x - 1, y - 1)
ans = 0
for i in range(n):
if uf.same(i, p[i]):
ans += 1
print(ans)
# print([uf.root(i) for i in range(n)])
# print([uf.parent[i] for i in range(n)])
# print([uf.size(i) for i in range(n)])
| false | 10.638298 | [
"- def root(self, x):",
"+ def root(self, x): # root(i): $i$の根ノードを返す.",
"- def union(self, x, y):",
"+ def union(self, x, y): # union(i,j): $i$のいるグループと$j$のいるグループをまとめる",
"- if self.parent[x] < self.parent[y]: # xの要素数がyの要素数より「小さい」とき",
"+ if self.parent[x] > self.parent[y]: # xの要素数がyの要素数より「小さい」とき",
"- def same(self, x, y):",
"+ def same(self, x, y): # same(i,j): $i$と$j$ が同じグループにあるならTrue,違うならFalse",
"+ def size(self, x): # size(i): $i$のいるグループの要素数を返す",
"+ return -self.parent[self.root(x)]",
"+",
"+# >>>>>>>>>>>>>>EhdCutHere>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>",
"+# print([uf.root(i) for i in range(n)])",
"+# print([uf.parent[i] for i in range(n)])",
"+# print([uf.size(i) for i in range(n)])"
] | false | 0.041712 | 0.044045 | 0.947034 | [
"s902200590",
"s652495923"
] |
u327466606 | p02599 | python | s796375074 | s878364374 | 1,845 | 1,547 | 202,988 | 242,264 | Accepted | Accepted | 16.15 | class BinaryIndexedTree:
def __init__(self, size):
self.data = [0] * (size+1)
self.size = size+1
self.msb = 1 << (size.bit_length()-1)
def _add(self, i, w):
i += 1
while i < self.size:
self.data[i] += w
i += i & -i
def _get_sum(self, i):
res = 0
while i > 0:
res += self.data[i]
i -= i & -i
return res
def __getitem__(self, i):
"""
[0,i)
"""
if isinstance(i, slice):
if i.start is None:
return self._get_sum(i.stop)
else:
return self._get_sum(i.stop) - self._get_sum(i.start)
else:
return 0 # fake value
__setitem__ = _add
def bisect_left(self, v):
"""
return smallest i s.t v <= sum[:i]
"""
i = 0
k = self.msb
while k > 0:
i += k
if i < len(self.data) and self.data[i] < v:
v -= self.data[i]
else:
i -= k
k >>= 1
return i
def bisect_right(self, v):
"""
return smallest i s.t v < sum[:i]
"""
i = 0
k = self.msb
while k > 0:
i += k
if i < len(self.data) and self.data[i] <= v:
v -= self.data[i]
else:
i -= k
k >>= 1
return i
bisect = bisect_right
def solve(C, queries):
N = len(C)
Q = len(queries)
bit = BinaryIndexedTree(N)
last_ind = [None]*(N + 1)
sorted_qi = sorted(range(Q), key=lambda i:queries[i][1])
res = [None]*Q
pr = 0
temp = 0
for qi in sorted_qi:
l,r = queries[qi]
for j,c in enumerate(C[pr:r],start=pr):
if last_ind[c] is not None:
bit._add(last_ind[c], -1)
else:
temp += 1
last_ind[c] = j
bit._add(j, 1)
pr = r
res[qi] = temp - bit._get_sum(l-1)
return res
# from random import randrange, seed
# from time import perf_counter
# def test():
# seed(1234)
# N = 5*10**5
# C = [randrange(N) for _ in range(N)]
# queries = [tuple(sorted((randrange(1,N+1),randrange(1,N+1)))) for _ in range(N)]
# start = perf_counter()
# solve(C,queries)
# stop = perf_counter()
# print(stop-start)
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
if __name__ == '__main__':
N,Q = map(int,readline().split())
C = list(map(int,readline().split()))
m = map(int,read().split())
queries = list(zip(m,m))
print(*solve(C,queries), sep='\n')
# test()
| class BinaryIndexedTree:
def __init__(self, size):
self.data = [0] * (size+1)
self.size = size+1
self.msb = 1 << (size.bit_length()-1)
def _add(self, i, w):
i += 1
while i < self.size:
self.data[i] += w
i += i & -i
def _get_sum(self, i):
res = 0
while i > 0:
res += self.data[i]
i -= i & -i
return res
def __getitem__(self, i):
"""
[0,i)
"""
if isinstance(i, slice):
if i.start is None:
return self._get_sum(i.stop)
else:
return self._get_sum(i.stop) - self._get_sum(i.start)
else:
return 0 # fake value
__setitem__ = _add
def bisect_left(self, v):
"""
return smallest i s.t v <= sum[:i]
"""
i = 0
k = self.msb
while k > 0:
i += k
if i < len(self.data) and self.data[i] < v:
v -= self.data[i]
else:
i -= k
k >>= 1
return i
def bisect_right(self, v):
"""
return smallest i s.t v < sum[:i]
"""
i = 0
k = self.msb
while k > 0:
i += k
if i < len(self.data) and self.data[i] <= v:
v -= self.data[i]
else:
i -= k
k >>= 1
return i
bisect = bisect_right
def solve(C, queries):
N = len(C)
Q = len(queries)
bit = BinaryIndexedTree(N)
last_ind = [None]*(N + 1)
sorted_qi = sorted(range(Q), key=lambda i:queries[i][1])
res = [None]*Q
pr = 0
temp = 0
for qi in sorted_qi:
l,r = queries[qi]
for j in range(pr,r):
c = C[j]
if last_ind[c] is not None:
bit._add(last_ind[c], -1)
else:
temp += 1
last_ind[c] = j
bit._add(j, 1)
pr = r
res[qi] = temp - bit._get_sum(l-1)
return res
# from random import randrange, seed
# from time import perf_counter
# def test():
# seed(1234)
# N = 5*10**5
# C = [randrange(N) for _ in range(N)]
# queries = [tuple(sorted((randrange(1,N+1),randrange(1,N+1)))) for _ in range(N)]
# start = perf_counter()
# solve(C,queries)
# stop = perf_counter()
# print(stop-start)
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
if __name__ == '__main__':
N,Q = map(int,readline().split())
C = list(map(int,readline().split()))
m = map(int,read().split())
queries = list(zip(m,m))
print(*solve(C,queries), sep='\n')
# test()
| 119 | 120 | 2,858 | 2,862 | class BinaryIndexedTree:
def __init__(self, size):
self.data = [0] * (size + 1)
self.size = size + 1
self.msb = 1 << (size.bit_length() - 1)
def _add(self, i, w):
i += 1
while i < self.size:
self.data[i] += w
i += i & -i
def _get_sum(self, i):
res = 0
while i > 0:
res += self.data[i]
i -= i & -i
return res
def __getitem__(self, i):
"""
[0,i)
"""
if isinstance(i, slice):
if i.start is None:
return self._get_sum(i.stop)
else:
return self._get_sum(i.stop) - self._get_sum(i.start)
else:
return 0 # fake value
__setitem__ = _add
def bisect_left(self, v):
"""
return smallest i s.t v <= sum[:i]
"""
i = 0
k = self.msb
while k > 0:
i += k
if i < len(self.data) and self.data[i] < v:
v -= self.data[i]
else:
i -= k
k >>= 1
return i
def bisect_right(self, v):
"""
return smallest i s.t v < sum[:i]
"""
i = 0
k = self.msb
while k > 0:
i += k
if i < len(self.data) and self.data[i] <= v:
v -= self.data[i]
else:
i -= k
k >>= 1
return i
bisect = bisect_right
def solve(C, queries):
N = len(C)
Q = len(queries)
bit = BinaryIndexedTree(N)
last_ind = [None] * (N + 1)
sorted_qi = sorted(range(Q), key=lambda i: queries[i][1])
res = [None] * Q
pr = 0
temp = 0
for qi in sorted_qi:
l, r = queries[qi]
for j, c in enumerate(C[pr:r], start=pr):
if last_ind[c] is not None:
bit._add(last_ind[c], -1)
else:
temp += 1
last_ind[c] = j
bit._add(j, 1)
pr = r
res[qi] = temp - bit._get_sum(l - 1)
return res
# from random import randrange, seed
# from time import perf_counter
# def test():
# seed(1234)
# N = 5*10**5
# C = [randrange(N) for _ in range(N)]
# queries = [tuple(sorted((randrange(1,N+1),randrange(1,N+1)))) for _ in range(N)]
# start = perf_counter()
# solve(C,queries)
# stop = perf_counter()
# print(stop-start)
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
if __name__ == "__main__":
N, Q = map(int, readline().split())
C = list(map(int, readline().split()))
m = map(int, read().split())
queries = list(zip(m, m))
print(*solve(C, queries), sep="\n")
# test()
| class BinaryIndexedTree:
def __init__(self, size):
self.data = [0] * (size + 1)
self.size = size + 1
self.msb = 1 << (size.bit_length() - 1)
def _add(self, i, w):
i += 1
while i < self.size:
self.data[i] += w
i += i & -i
def _get_sum(self, i):
res = 0
while i > 0:
res += self.data[i]
i -= i & -i
return res
def __getitem__(self, i):
"""
[0,i)
"""
if isinstance(i, slice):
if i.start is None:
return self._get_sum(i.stop)
else:
return self._get_sum(i.stop) - self._get_sum(i.start)
else:
return 0 # fake value
__setitem__ = _add
def bisect_left(self, v):
"""
return smallest i s.t v <= sum[:i]
"""
i = 0
k = self.msb
while k > 0:
i += k
if i < len(self.data) and self.data[i] < v:
v -= self.data[i]
else:
i -= k
k >>= 1
return i
def bisect_right(self, v):
"""
return smallest i s.t v < sum[:i]
"""
i = 0
k = self.msb
while k > 0:
i += k
if i < len(self.data) and self.data[i] <= v:
v -= self.data[i]
else:
i -= k
k >>= 1
return i
bisect = bisect_right
def solve(C, queries):
N = len(C)
Q = len(queries)
bit = BinaryIndexedTree(N)
last_ind = [None] * (N + 1)
sorted_qi = sorted(range(Q), key=lambda i: queries[i][1])
res = [None] * Q
pr = 0
temp = 0
for qi in sorted_qi:
l, r = queries[qi]
for j in range(pr, r):
c = C[j]
if last_ind[c] is not None:
bit._add(last_ind[c], -1)
else:
temp += 1
last_ind[c] = j
bit._add(j, 1)
pr = r
res[qi] = temp - bit._get_sum(l - 1)
return res
# from random import randrange, seed
# from time import perf_counter
# def test():
# seed(1234)
# N = 5*10**5
# C = [randrange(N) for _ in range(N)]
# queries = [tuple(sorted((randrange(1,N+1),randrange(1,N+1)))) for _ in range(N)]
# start = perf_counter()
# solve(C,queries)
# stop = perf_counter()
# print(stop-start)
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
if __name__ == "__main__":
N, Q = map(int, readline().split())
C = list(map(int, readline().split()))
m = map(int, read().split())
queries = list(zip(m, m))
print(*solve(C, queries), sep="\n")
# test()
| false | 0.833333 | [
"- for j, c in enumerate(C[pr:r], start=pr):",
"+ for j in range(pr, r):",
"+ c = C[j]"
] | false | 0.050267 | 0.107034 | 0.469636 | [
"s796375074",
"s878364374"
] |
u708255304 | p02983 | python | s010718900 | s361126752 | 1,093 | 788 | 3,060 | 2,940 | Accepted | Accepted | 27.9 | L, R = list(map(int, input().split()))
if R-L >= 2019:
print((0))
exit()
flag = True
ans = 2020
for i in range(L, L+2018):
if flag:
for j in range(i+1, R+1):
if i > R:
flag = False
break
ans = min(((i % 2019) * (j % 2019)) % 2019, ans)
print(ans)
| L, R = list(map(int, input().split()))
ans = 2019
for i in range(L, min(R+1, L+2019)):
for j in range(i+1, min(R+1, L+2019)):
ans = min(ans, (i*j)%2019)
print(ans)
| 18 | 6 | 336 | 175 | L, R = list(map(int, input().split()))
if R - L >= 2019:
print((0))
exit()
flag = True
ans = 2020
for i in range(L, L + 2018):
if flag:
for j in range(i + 1, R + 1):
if i > R:
flag = False
break
ans = min(((i % 2019) * (j % 2019)) % 2019, ans)
print(ans)
| L, R = list(map(int, input().split()))
ans = 2019
for i in range(L, min(R + 1, L + 2019)):
for j in range(i + 1, min(R + 1, L + 2019)):
ans = min(ans, (i * j) % 2019)
print(ans)
| false | 66.666667 | [
"-if R - L >= 2019:",
"- print((0))",
"- exit()",
"-flag = True",
"-ans = 2020",
"-for i in range(L, L + 2018):",
"- if flag:",
"- for j in range(i + 1, R + 1):",
"- if i > R:",
"- flag = False",
"- break",
"- ans = min(((i % 2019) * (j % 2019)) % 2019, ans)",
"+ans = 2019",
"+for i in range(L, min(R + 1, L + 2019)):",
"+ for j in range(i + 1, min(R + 1, L + 2019)):",
"+ ans = min(ans, (i * j) % 2019)"
] | false | 0.058505 | 0.098726 | 0.592602 | [
"s010718900",
"s361126752"
] |
u600402037 | p03137 | python | s187764886 | s982717059 | 258 | 187 | 22,920 | 23,076 | Accepted | Accepted | 27.52 | import numpy as np
N, M = list(map(int, input().split()))
X = np.array(sorted(map(int, input().split())))
distances = sorted(X[1:] - X[:-1], reverse=True)
print((sum(distances[N-1:]))) | # coding: utf-8
import sys
import numpy as np
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, M = lr()
X = np.array(lr())
X.sort()
if N >= M:
print((0)); exit()
Xdiff = np.abs(np.diff(X))
Xdiff.sort()
need = M - N
answer = Xdiff[:need].sum()
print(answer)
| 7 | 19 | 184 | 342 | import numpy as np
N, M = list(map(int, input().split()))
X = np.array(sorted(map(int, input().split())))
distances = sorted(X[1:] - X[:-1], reverse=True)
print((sum(distances[N - 1 :])))
| # coding: utf-8
import sys
import numpy as np
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, M = lr()
X = np.array(lr())
X.sort()
if N >= M:
print((0))
exit()
Xdiff = np.abs(np.diff(X))
Xdiff.sort()
need = M - N
answer = Xdiff[:need].sum()
print(answer)
| false | 63.157895 | [
"+# coding: utf-8",
"+import sys",
"-N, M = list(map(int, input().split()))",
"-X = np.array(sorted(map(int, input().split())))",
"-distances = sorted(X[1:] - X[:-1], reverse=True)",
"-print((sum(distances[N - 1 :])))",
"+sr = lambda: sys.stdin.readline().rstrip()",
"+ir = lambda: int(sr())",
"+lr = lambda: list(map(int, sr().split()))",
"+N, M = lr()",
"+X = np.array(lr())",
"+X.sort()",
"+if N >= M:",
"+ print((0))",
"+ exit()",
"+Xdiff = np.abs(np.diff(X))",
"+Xdiff.sort()",
"+need = M - N",
"+answer = Xdiff[:need].sum()",
"+print(answer)"
] | false | 0.24323 | 0.764945 | 0.31797 | [
"s187764886",
"s982717059"
] |
u223663729 | p03835 | python | s271578045 | s947780858 | 1,623 | 785 | 2,940 | 9,164 | Accepted | Accepted | 51.63 | K, S = list(map(int, input().split()))
cnt = 0
for x in range(K+1):
for y in range(K+1):
z = S-x-y
if 0 <= z and z <= K:
cnt+=1
print(cnt) | K, S = list(map(int, input().split()))
ans = sum(0 <= S-x-y <= K for x in range(K+1) for y in range(K+1))
print(ans) | 10 | 3 | 159 | 112 | K, S = list(map(int, input().split()))
cnt = 0
for x in range(K + 1):
for y in range(K + 1):
z = S - x - y
if 0 <= z and z <= K:
cnt += 1
print(cnt)
| K, S = list(map(int, input().split()))
ans = sum(0 <= S - x - y <= K for x in range(K + 1) for y in range(K + 1))
print(ans)
| false | 70 | [
"-cnt = 0",
"-for x in range(K + 1):",
"- for y in range(K + 1):",
"- z = S - x - y",
"- if 0 <= z and z <= K:",
"- cnt += 1",
"-print(cnt)",
"+ans = sum(0 <= S - x - y <= K for x in range(K + 1) for y in range(K + 1))",
"+print(ans)"
] | false | 0.079797 | 0.035919 | 2.2216 | [
"s271578045",
"s947780858"
] |
u246401133 | p02657 | python | s529501348 | s845477885 | 34 | 30 | 9,088 | 9,140 | Accepted | Accepted | 11.76 | a, b = list(map(int, input().split()))
print((int(a*b))) | a, b = list(map(int, input().split()))
print((a * b)) | 2 | 2 | 49 | 46 | a, b = list(map(int, input().split()))
print((int(a * b)))
| a, b = list(map(int, input().split()))
print((a * b))
| false | 0 | [
"-print((int(a * b)))",
"+print((a * b))"
] | false | 0.036823 | 0.03517 | 1.04701 | [
"s529501348",
"s845477885"
] |
u852690916 | p02996 | python | s448046521 | s277030760 | 900 | 419 | 53,732 | 31,964 | Accepted | Accepted | 53.44 | from operator import itemgetter
N=int(eval(input()))
tasks=[list(map(int,input().split())) for _ in range(N)]
tasks.sort(key=itemgetter(1))
t=0
for w,l in tasks:
if t+w>l:
print('No')
exit()
t+=w
print('Yes') | import sys
def main():
input = sys.stdin.readline
N=int(eval(input()))
tasks=[tuple(map(int, input().split())) for _ in range(N)]
from operator import itemgetter
tasks.sort(key=itemgetter(1))
t=0
for task in tasks:
t += task[0]
if t > task[1]:
print('No')
return
print('Yes')
if __name__ == '__main__':
main() | 11 | 18 | 236 | 398 | from operator import itemgetter
N = int(eval(input()))
tasks = [list(map(int, input().split())) for _ in range(N)]
tasks.sort(key=itemgetter(1))
t = 0
for w, l in tasks:
if t + w > l:
print("No")
exit()
t += w
print("Yes")
| import sys
def main():
input = sys.stdin.readline
N = int(eval(input()))
tasks = [tuple(map(int, input().split())) for _ in range(N)]
from operator import itemgetter
tasks.sort(key=itemgetter(1))
t = 0
for task in tasks:
t += task[0]
if t > task[1]:
print("No")
return
print("Yes")
if __name__ == "__main__":
main()
| false | 38.888889 | [
"-from operator import itemgetter",
"+import sys",
"-N = int(eval(input()))",
"-tasks = [list(map(int, input().split())) for _ in range(N)]",
"-tasks.sort(key=itemgetter(1))",
"-t = 0",
"-for w, l in tasks:",
"- if t + w > l:",
"- print(\"No\")",
"- exit()",
"- t += w",
"-print(\"Yes\")",
"+",
"+def main():",
"+ input = sys.stdin.readline",
"+ N = int(eval(input()))",
"+ tasks = [tuple(map(int, input().split())) for _ in range(N)]",
"+ from operator import itemgetter",
"+",
"+ tasks.sort(key=itemgetter(1))",
"+ t = 0",
"+ for task in tasks:",
"+ t += task[0]",
"+ if t > task[1]:",
"+ print(\"No\")",
"+ return",
"+ print(\"Yes\")",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.046231 | 0.046175 | 1.001223 | [
"s448046521",
"s277030760"
] |
u107091170 | p03329 | python | s047016930 | s051256819 | 681 | 245 | 4,596 | 5,580 | Accepted | Accepted | 64.02 | # 配るDP
N=int(eval(input()))
dp = [100000] * 200005;
g = [1]
a = 6
while a <= 100000:
g.append(a)
a *= 6
a = 9
while a <= 100000:
g.append(a)
a *= 9
g.sort(reverse=True)
dp[0] = 0
for i in range(N):
for j in g:
dp[i+j] = min( dp[i+j], dp[i]+1 )
print((dp[N]))
| # BFS
from collections import deque
N=int(eval(input()))
dp = [-1] * 200005;
q = deque()
g = [1]
a = 6
while a <= 100000:
g.append(a)
a *= 6
a = 9
while a <= 100000:
g.append(a)
a *= 9
g.sort(reverse=True)
dp[0] = 0
q.append(0)
while len(q) > 0:
v = q.popleft()
if v == N: break
for j in g:
if dp[v+j] != -1: continue
if v+j > N: continue
dp[v+j] = dp[v] + 1
q.append(v+j)
print((dp[N]))
| 24 | 32 | 294 | 447 | # 配るDP
N = int(eval(input()))
dp = [100000] * 200005
g = [1]
a = 6
while a <= 100000:
g.append(a)
a *= 6
a = 9
while a <= 100000:
g.append(a)
a *= 9
g.sort(reverse=True)
dp[0] = 0
for i in range(N):
for j in g:
dp[i + j] = min(dp[i + j], dp[i] + 1)
print((dp[N]))
| # BFS
from collections import deque
N = int(eval(input()))
dp = [-1] * 200005
q = deque()
g = [1]
a = 6
while a <= 100000:
g.append(a)
a *= 6
a = 9
while a <= 100000:
g.append(a)
a *= 9
g.sort(reverse=True)
dp[0] = 0
q.append(0)
while len(q) > 0:
v = q.popleft()
if v == N:
break
for j in g:
if dp[v + j] != -1:
continue
if v + j > N:
continue
dp[v + j] = dp[v] + 1
q.append(v + j)
print((dp[N]))
| false | 25 | [
"-# 配るDP",
"+# BFS",
"+from collections import deque",
"+",
"-dp = [100000] * 200005",
"+dp = [-1] * 200005",
"+q = deque()",
"-for i in range(N):",
"+q.append(0)",
"+while len(q) > 0:",
"+ v = q.popleft()",
"+ if v == N:",
"+ break",
"- dp[i + j] = min(dp[i + j], dp[i] + 1)",
"+ if dp[v + j] != -1:",
"+ continue",
"+ if v + j > N:",
"+ continue",
"+ dp[v + j] = dp[v] + 1",
"+ q.append(v + j)"
] | false | 0.099033 | 0.062454 | 1.585712 | [
"s047016930",
"s051256819"
] |
u437351386 | p03682 | python | s598112874 | s300958619 | 1,529 | 1,189 | 175,416 | 143,824 | Accepted | Accepted | 22.24 | n=int(eval(input()))
town=[]
for i in range(n):
x,y=list(map(int,input().split()))
town.append([x,y,i])
X=sorted(town,key=lambda x:x[0])
Y=sorted(town,key=lambda x:x[1])
es=[]
for i in range(1,n):
es.append((min(abs(X[i][0]-X[i-1][0]),abs(X[i][1]-X[i-1][1])),X[i][2],X[i-1][2]))
es.append((min(abs(X[i][0]-X[i-1][0]),abs(X[i][1]-X[i-1][1])),X[i-1][2],X[i][2]))
es.append((min(abs(Y[i][0]-Y[i-1][0]),abs(Y[i][1]-Y[i-1][1])),Y[i][2],Y[i-1][2]))
es.append((min(abs(Y[i][0]-Y[i-1][0]),abs(Y[i][1]-Y[i-1][1])),Y[i-1][2],Y[i][2]))
es.sort(key=lambda x:x[0])
#Union-Find木
#par[i]:iの親 deep[i]:iの深さ size[i]:iの大きさ
par=[i for i in range(n)]
deep=[1]*n
size=[1]*n
#親を見つける
def find(x):
if par[x]==x:
return x
else:
return find(par[x])
#二つのグループを統合する
def unite(x,y):
x=find(x)
y=find(y)
if x==y:
return
if deep[x]<deep[y]:
par[x]=y
size[y]+=size[x]
else:
par[y]=x
size[x]+=size[y]
if deep[x]==deep[y]:
deep[x]+=1
#xとyが同じグループに属するかどうか
def same(x,y):
return find(x)==find(y)
#xが属するグループの要素数を返す
def group_count(x):
return size[find(x)]
#クラスカル法
#esは重みで小さい順にsort済み
#es[i]:[重み、始点、終点]
def kruskal(n,es):
ans=0
for to in es:
if not same(to[1],to[2]):
ans+=to[0]
unite(to[1],to[2])
return ans
print((kruskal(n,es)))
| n=int(eval(input()))
town=[]
for i in range(n):
x,y=list(map(int,input().split()))
town.append([x,y,i])
X=sorted(town,key=lambda x:x[0])
Y=sorted(town,key=lambda x:x[1])
es=[]
for i in range(1,n):
es.append((min(abs(X[i][0]-X[i-1][0]),abs(X[i][1]-X[i-1][1])),X[i][2],X[i-1][2]))
#es.append((min(abs(X[i][0]-X[i-1][0]),abs(X[i][1]-X[i-1][1])),X[i-1][2],X[i][2]))
es.append((min(abs(Y[i][0]-Y[i-1][0]),abs(Y[i][1]-Y[i-1][1])),Y[i][2],Y[i-1][2]))
#es.append((min(abs(Y[i][0]-Y[i-1][0]),abs(Y[i][1]-Y[i-1][1])),Y[i-1][2],Y[i][2]))
es.sort(key=lambda x:x[0])
#Union-Find木
#par[i]:iの親 deep[i]:iの深さ size[i]:iの大きさ
par=[i for i in range(n)]
deep=[1]*n
size=[1]*n
#親を見つける
def find(x):
if par[x]==x:
return x
else:
return find(par[x])
#二つのグループを統合する
def unite(x,y):
x=find(x)
y=find(y)
if x==y:
return
if deep[x]<deep[y]:
par[x]=y
size[y]+=size[x]
else:
par[y]=x
size[x]+=size[y]
if deep[x]==deep[y]:
deep[x]+=1
#xとyが同じグループに属するかどうか
def same(x,y):
return find(x)==find(y)
#xが属するグループの要素数を返す
def group_count(x):
return size[find(x)]
#クラスカル法
#esは重みで小さい順にsort済み
#es[i]:[重み、始点、終点]
def kruskal(n,es):
ans=0
for to in es:
if not same(to[1],to[2]):
ans+=to[0]
unite(to[1],to[2])
return ans
print((kruskal(n,es)))
| 69 | 69 | 1,359 | 1,361 | n = int(eval(input()))
town = []
for i in range(n):
x, y = list(map(int, input().split()))
town.append([x, y, i])
X = sorted(town, key=lambda x: x[0])
Y = sorted(town, key=lambda x: x[1])
es = []
for i in range(1, n):
es.append(
(
min(abs(X[i][0] - X[i - 1][0]), abs(X[i][1] - X[i - 1][1])),
X[i][2],
X[i - 1][2],
)
)
es.append(
(
min(abs(X[i][0] - X[i - 1][0]), abs(X[i][1] - X[i - 1][1])),
X[i - 1][2],
X[i][2],
)
)
es.append(
(
min(abs(Y[i][0] - Y[i - 1][0]), abs(Y[i][1] - Y[i - 1][1])),
Y[i][2],
Y[i - 1][2],
)
)
es.append(
(
min(abs(Y[i][0] - Y[i - 1][0]), abs(Y[i][1] - Y[i - 1][1])),
Y[i - 1][2],
Y[i][2],
)
)
es.sort(key=lambda x: x[0])
# Union-Find木
# par[i]:iの親 deep[i]:iの深さ size[i]:iの大きさ
par = [i for i in range(n)]
deep = [1] * n
size = [1] * n
# 親を見つける
def find(x):
if par[x] == x:
return x
else:
return find(par[x])
# 二つのグループを統合する
def unite(x, y):
x = find(x)
y = find(y)
if x == y:
return
if deep[x] < deep[y]:
par[x] = y
size[y] += size[x]
else:
par[y] = x
size[x] += size[y]
if deep[x] == deep[y]:
deep[x] += 1
# xとyが同じグループに属するかどうか
def same(x, y):
return find(x) == find(y)
# xが属するグループの要素数を返す
def group_count(x):
return size[find(x)]
# クラスカル法
# esは重みで小さい順にsort済み
# es[i]:[重み、始点、終点]
def kruskal(n, es):
ans = 0
for to in es:
if not same(to[1], to[2]):
ans += to[0]
unite(to[1], to[2])
return ans
print((kruskal(n, es)))
| n = int(eval(input()))
town = []
for i in range(n):
x, y = list(map(int, input().split()))
town.append([x, y, i])
X = sorted(town, key=lambda x: x[0])
Y = sorted(town, key=lambda x: x[1])
es = []
for i in range(1, n):
es.append(
(
min(abs(X[i][0] - X[i - 1][0]), abs(X[i][1] - X[i - 1][1])),
X[i][2],
X[i - 1][2],
)
)
# es.append((min(abs(X[i][0]-X[i-1][0]),abs(X[i][1]-X[i-1][1])),X[i-1][2],X[i][2]))
es.append(
(
min(abs(Y[i][0] - Y[i - 1][0]), abs(Y[i][1] - Y[i - 1][1])),
Y[i][2],
Y[i - 1][2],
)
)
# es.append((min(abs(Y[i][0]-Y[i-1][0]),abs(Y[i][1]-Y[i-1][1])),Y[i-1][2],Y[i][2]))
es.sort(key=lambda x: x[0])
# Union-Find木
# par[i]:iの親 deep[i]:iの深さ size[i]:iの大きさ
par = [i for i in range(n)]
deep = [1] * n
size = [1] * n
# 親を見つける
def find(x):
if par[x] == x:
return x
else:
return find(par[x])
# 二つのグループを統合する
def unite(x, y):
x = find(x)
y = find(y)
if x == y:
return
if deep[x] < deep[y]:
par[x] = y
size[y] += size[x]
else:
par[y] = x
size[x] += size[y]
if deep[x] == deep[y]:
deep[x] += 1
# xとyが同じグループに属するかどうか
def same(x, y):
return find(x) == find(y)
# xが属するグループの要素数を返す
def group_count(x):
return size[find(x)]
# クラスカル法
# esは重みで小さい順にsort済み
# es[i]:[重み、始点、終点]
def kruskal(n, es):
ans = 0
for to in es:
if not same(to[1], to[2]):
ans += to[0]
unite(to[1], to[2])
return ans
print((kruskal(n, es)))
| false | 0 | [
"- es.append(",
"- (",
"- min(abs(X[i][0] - X[i - 1][0]), abs(X[i][1] - X[i - 1][1])),",
"- X[i - 1][2],",
"- X[i][2],",
"- )",
"- )",
"+ # es.append((min(abs(X[i][0]-X[i-1][0]),abs(X[i][1]-X[i-1][1])),X[i-1][2],X[i][2]))",
"- es.append(",
"- (",
"- min(abs(Y[i][0] - Y[i - 1][0]), abs(Y[i][1] - Y[i - 1][1])),",
"- Y[i - 1][2],",
"- Y[i][2],",
"- )",
"- )",
"+ # es.append((min(abs(Y[i][0]-Y[i-1][0]),abs(Y[i][1]-Y[i-1][1])),Y[i-1][2],Y[i][2]))"
] | false | 0.032533 | 0.044941 | 0.723897 | [
"s598112874",
"s300958619"
] |
u671060652 | p02660 | python | s687253711 | s653359600 | 346 | 123 | 77,512 | 72,796 | Accepted | Accepted | 64.45 | import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from decimal import Decimal
n = int(eval(input()))
prime = {}
num = n
i = 2
while True:
if i * i > n:
if(num > 1):
prime[num] = 1
break
while num%i == 0:
prime[i] = prime.get(i, 0) + 1
num = num//i
i += 1
count = 0
for val in list(prime.values()):
use = 1
while True:
if(val < use):
break
val -= use
use += 1
count+=1
print(count)
| import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from decimal import Decimal
n = int(eval(input()))
def how_many_prime(n):
prime = {}
num = n
i = 2
while True:
if i * i > n:
if(num > 1):
prime[num] = 1
break
while num % i == 0:
prime[i] = prime.get(i, 0) + 1
num = num//i
i += 1
return prime
prime = how_many_prime(n)
count = 0
for val in list(prime.values()):
use = 1
while True:
if(val < use):
break
val -= use
use += 1
count += 1
print(count)
| 34 | 38 | 597 | 720 | import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from decimal import Decimal
n = int(eval(input()))
prime = {}
num = n
i = 2
while True:
if i * i > n:
if num > 1:
prime[num] = 1
break
while num % i == 0:
prime[i] = prime.get(i, 0) + 1
num = num // i
i += 1
count = 0
for val in list(prime.values()):
use = 1
while True:
if val < use:
break
val -= use
use += 1
count += 1
print(count)
| import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from decimal import Decimal
n = int(eval(input()))
def how_many_prime(n):
prime = {}
num = n
i = 2
while True:
if i * i > n:
if num > 1:
prime[num] = 1
break
while num % i == 0:
prime[i] = prime.get(i, 0) + 1
num = num // i
i += 1
return prime
prime = how_many_prime(n)
count = 0
for val in list(prime.values()):
use = 1
while True:
if val < use:
break
val -= use
use += 1
count += 1
print(count)
| false | 10.526316 | [
"-prime = {}",
"-num = n",
"-i = 2",
"-while True:",
"- if i * i > n:",
"- if num > 1:",
"- prime[num] = 1",
"- break",
"- while num % i == 0:",
"- prime[i] = prime.get(i, 0) + 1",
"- num = num // i",
"- i += 1",
"+",
"+",
"+def how_many_prime(n):",
"+ prime = {}",
"+ num = n",
"+ i = 2",
"+ while True:",
"+ if i * i > n:",
"+ if num > 1:",
"+ prime[num] = 1",
"+ break",
"+ while num % i == 0:",
"+ prime[i] = prime.get(i, 0) + 1",
"+ num = num // i",
"+ i += 1",
"+ return prime",
"+",
"+",
"+prime = how_many_prime(n)"
] | false | 0.299437 | 0.260469 | 1.149606 | [
"s687253711",
"s653359600"
] |
u761320129 | p03222 | python | s155096679 | s689666073 | 42 | 36 | 3,064 | 3,064 | Accepted | Accepted | 14.29 | H,W,K = list(map(int,input().split()))
K -= 1
MOD = 10**9+7
dp = [[0]*W for i in range(H+1)]
dp[0][0] = 1
for i in range(H):
for b in range(2**(W-1)):
if '11' in bin(b): continue
b *= 2
for j in range(W):
if b&(1<<j):
dp[i+1][j-1] += dp[i][j]
dp[i+1][j-1] %= MOD
elif b&(1<<(j+1)):
dp[i+1][j+1] += dp[i][j]
dp[i+1][j+1] %= MOD
else:
dp[i+1][j] += dp[i][j]
dp[i+1][j] %= MOD
print((dp[-1][K]))
| H,W,K = list(map(int,input().split()))
MOD = 10**9+7
if W == 1:
print((1))
exit()
dp = [[0]*W for i in range(H+1)]
dp[0][0] = 1
for i in range(H):
for b in range(2**(W-1)):
if '11' in bin(b): continue
b *= 2
for j in range(W):
if b&(1<<j):
dp[i+1][j-1] += dp[i][j]
elif b&(1<<(j+1)):
dp[i+1][j+1] += dp[i][j]
else:
dp[i+1][j] += dp[i][j]
print((dp[-1][K-1] % MOD)) | 22 | 21 | 568 | 496 | H, W, K = list(map(int, input().split()))
K -= 1
MOD = 10**9 + 7
dp = [[0] * W for i in range(H + 1)]
dp[0][0] = 1
for i in range(H):
for b in range(2 ** (W - 1)):
if "11" in bin(b):
continue
b *= 2
for j in range(W):
if b & (1 << j):
dp[i + 1][j - 1] += dp[i][j]
dp[i + 1][j - 1] %= MOD
elif b & (1 << (j + 1)):
dp[i + 1][j + 1] += dp[i][j]
dp[i + 1][j + 1] %= MOD
else:
dp[i + 1][j] += dp[i][j]
dp[i + 1][j] %= MOD
print((dp[-1][K]))
| H, W, K = list(map(int, input().split()))
MOD = 10**9 + 7
if W == 1:
print((1))
exit()
dp = [[0] * W for i in range(H + 1)]
dp[0][0] = 1
for i in range(H):
for b in range(2 ** (W - 1)):
if "11" in bin(b):
continue
b *= 2
for j in range(W):
if b & (1 << j):
dp[i + 1][j - 1] += dp[i][j]
elif b & (1 << (j + 1)):
dp[i + 1][j + 1] += dp[i][j]
else:
dp[i + 1][j] += dp[i][j]
print((dp[-1][K - 1] % MOD))
| false | 4.545455 | [
"-K -= 1",
"+if W == 1:",
"+ print((1))",
"+ exit()",
"- dp[i + 1][j - 1] %= MOD",
"- dp[i + 1][j + 1] %= MOD",
"- dp[i + 1][j] %= MOD",
"-print((dp[-1][K]))",
"+print((dp[-1][K - 1] % MOD))"
] | false | 0.040488 | 0.040465 | 1.000589 | [
"s155096679",
"s689666073"
] |
u945065638 | p02571 | python | s622342298 | s691263987 | 66 | 59 | 9,052 | 8,904 | Accepted | Accepted | 10.61 | S =eval(input())
T =eval(input())
mint=10000
for i in range(len(S)-len(T)+1):
con = 0
for j in range(len(T)):
if S[i+j] != T[j]:
con += 1
mint =min(con,mint)
if mint == 0:
break
print(mint)
| s = eval(input())
t = eval(input())
mini =10000000
for i in range(len(s)-len(t)+1):
count = 0
for z in range(len(t)):
if s[i+z] != t[z]:
count += 1
if count < mini :
mini = count
print(mini) | 17 | 14 | 259 | 251 | S = eval(input())
T = eval(input())
mint = 10000
for i in range(len(S) - len(T) + 1):
con = 0
for j in range(len(T)):
if S[i + j] != T[j]:
con += 1
mint = min(con, mint)
if mint == 0:
break
print(mint)
| s = eval(input())
t = eval(input())
mini = 10000000
for i in range(len(s) - len(t) + 1):
count = 0
for z in range(len(t)):
if s[i + z] != t[z]:
count += 1
if count < mini:
mini = count
print(mini)
| false | 17.647059 | [
"-S = eval(input())",
"-T = eval(input())",
"-mint = 10000",
"-for i in range(len(S) - len(T) + 1):",
"- con = 0",
"- for j in range(len(T)):",
"- if S[i + j] != T[j]:",
"- con += 1",
"- mint = min(con, mint)",
"- if mint == 0:",
"- break",
"-print(mint)",
"+s = eval(input())",
"+t = eval(input())",
"+mini = 10000000",
"+for i in range(len(s) - len(t) + 1):",
"+ count = 0",
"+ for z in range(len(t)):",
"+ if s[i + z] != t[z]:",
"+ count += 1",
"+ if count < mini:",
"+ mini = count",
"+print(mini)"
] | false | 0.044369 | 0.045637 | 0.972232 | [
"s622342298",
"s691263987"
] |
u498487134 | p02792 | python | s941671908 | s709799526 | 271 | 225 | 42,348 | 40,428 | Accepted | Accepted | 16.97 | S=eval(input())
N=int(S)
n=len(S)
ans=0
p=[1,10,100,1000,10000,100000]
for i in range(N+1):#数iに対する相手を探す
ii=str(i)
a=int(ii[0])
b=int(ii[-1])
if a*b!=0:
if a==b:#a**aの形なら1桁の答えaが存在
ans+=1
for j in range(2,n+1):#桁数
if j<n:
ans+=p[j-2]
#print(i,j,n,ans)
elif j==n:
floor=b*p[j-1]+a
if j==2:
ceil=floor
else:
ceil=floor+p[j-1]-p[1]
#print(i,j,floor,ceil)
if N>=ceil:
ans+=p[j-2]
#print(i,j,n,ans)
elif N<floor:
continue
else:#floorとceilの間
ans+=(N-floor)//10+1
#print(i,j,n,ans)
#print("i,ans:{},{}".format(i,ans))
print(ans) | S=eval(input())
TT=[[0]*10 for _ in range(10)]
N=int(S)
for i in range(1,N+1):
ii=str(i)
a=int(ii[0])
b=int(ii[-1])
TT[a][b]+=1
ans=0
for i in range(10):
for j in range(10):
ans+=TT[i][j]*TT[j][i]
print(ans) | 37 | 16 | 929 | 259 | S = eval(input())
N = int(S)
n = len(S)
ans = 0
p = [1, 10, 100, 1000, 10000, 100000]
for i in range(N + 1): # 数iに対する相手を探す
ii = str(i)
a = int(ii[0])
b = int(ii[-1])
if a * b != 0:
if a == b: # a**aの形なら1桁の答えaが存在
ans += 1
for j in range(2, n + 1): # 桁数
if j < n:
ans += p[j - 2]
# print(i,j,n,ans)
elif j == n:
floor = b * p[j - 1] + a
if j == 2:
ceil = floor
else:
ceil = floor + p[j - 1] - p[1]
# print(i,j,floor,ceil)
if N >= ceil:
ans += p[j - 2]
# print(i,j,n,ans)
elif N < floor:
continue
else: # floorとceilの間
ans += (N - floor) // 10 + 1
# print(i,j,n,ans)
# print("i,ans:{},{}".format(i,ans))
print(ans)
| S = eval(input())
TT = [[0] * 10 for _ in range(10)]
N = int(S)
for i in range(1, N + 1):
ii = str(i)
a = int(ii[0])
b = int(ii[-1])
TT[a][b] += 1
ans = 0
for i in range(10):
for j in range(10):
ans += TT[i][j] * TT[j][i]
print(ans)
| false | 56.756757 | [
"+TT = [[0] * 10 for _ in range(10)]",
"-n = len(S)",
"-ans = 0",
"-p = [1, 10, 100, 1000, 10000, 100000]",
"-for i in range(N + 1): # 数iに対する相手を探す",
"+for i in range(1, N + 1):",
"- if a * b != 0:",
"- if a == b: # a**aの形なら1桁の答えaが存在",
"- ans += 1",
"- for j in range(2, n + 1): # 桁数",
"- if j < n:",
"- ans += p[j - 2]",
"- # print(i,j,n,ans)",
"- elif j == n:",
"- floor = b * p[j - 1] + a",
"- if j == 2:",
"- ceil = floor",
"- else:",
"- ceil = floor + p[j - 1] - p[1]",
"- # print(i,j,floor,ceil)",
"- if N >= ceil:",
"- ans += p[j - 2]",
"- # print(i,j,n,ans)",
"- elif N < floor:",
"- continue",
"- else: # floorとceilの間",
"- ans += (N - floor) // 10 + 1",
"- # print(i,j,n,ans)",
"- # print(\"i,ans:{},{}\".format(i,ans))",
"+ TT[a][b] += 1",
"+ans = 0",
"+for i in range(10):",
"+ for j in range(10):",
"+ ans += TT[i][j] * TT[j][i]"
] | false | 0.037234 | 0.073111 | 0.509286 | [
"s941671908",
"s709799526"
] |
u562935282 | p03075 | python | s877047542 | s022196422 | 24 | 17 | 3,316 | 2,940 | Accepted | Accepted | 29.17 | e = [int(eval(input())) for _ in range(5)]
k = int(eval(input()))
bl = True
for ee1 in e:
for ee2 in e:
if abs(ee1 - ee2) > k:
bl = False
break
if not bl:
break
print(('Yay!' if bl else ':('))
| v = [int(eval(input())) for _ in range(5)]
k = int(eval(input()))
bl = max(v) - min(v) <= k
print(('Yay!' if bl else ':('))
| 12 | 5 | 239 | 115 | e = [int(eval(input())) for _ in range(5)]
k = int(eval(input()))
bl = True
for ee1 in e:
for ee2 in e:
if abs(ee1 - ee2) > k:
bl = False
break
if not bl:
break
print(("Yay!" if bl else ":("))
| v = [int(eval(input())) for _ in range(5)]
k = int(eval(input()))
bl = max(v) - min(v) <= k
print(("Yay!" if bl else ":("))
| false | 58.333333 | [
"-e = [int(eval(input())) for _ in range(5)]",
"+v = [int(eval(input())) for _ in range(5)]",
"-bl = True",
"-for ee1 in e:",
"- for ee2 in e:",
"- if abs(ee1 - ee2) > k:",
"- bl = False",
"- break",
"- if not bl:",
"- break",
"+bl = max(v) - min(v) <= k"
] | false | 0.037233 | 0.037413 | 0.995172 | [
"s877047542",
"s022196422"
] |
u980205854 | p02659 | python | s206653168 | s634543308 | 23 | 21 | 9,156 | 9,164 | Accepted | Accepted | 8.7 | A,B = input().split()
A = int(A)
B = int(float(B)*100+1.0e-10)
print((int((A*B)//100)))
| # C - Multiplication 3
A,B = input().split()
A = int(A)
B = int(100*float(B)+0.001)
print(((A*B)//100)) | 5 | 5 | 91 | 105 | A, B = input().split()
A = int(A)
B = int(float(B) * 100 + 1.0e-10)
print((int((A * B) // 100)))
| # C - Multiplication 3
A, B = input().split()
A = int(A)
B = int(100 * float(B) + 0.001)
print(((A * B) // 100))
| false | 0 | [
"+# C - Multiplication 3",
"-B = int(float(B) * 100 + 1.0e-10)",
"-print((int((A * B) // 100)))",
"+B = int(100 * float(B) + 0.001)",
"+print(((A * B) // 100))"
] | false | 0.072745 | 0.101327 | 0.717922 | [
"s206653168",
"s634543308"
] |
u928051788 | p02389 | python | s608922197 | s458055594 | 30 | 20 | 7,640 | 7,652 | Accepted | Accepted | 33.33 | x = input().split()
a = int(x[0])*int(x[1])
b = 2*(int(x[1])+int(x[0]))
print((a,b)) | s = input().rstrip().split(' ')
s1=int(s[0])
s2=int(s[1])
print((s1*s2, 2*s1+2*s2)) | 5 | 4 | 87 | 84 | x = input().split()
a = int(x[0]) * int(x[1])
b = 2 * (int(x[1]) + int(x[0]))
print((a, b))
| s = input().rstrip().split(" ")
s1 = int(s[0])
s2 = int(s[1])
print((s1 * s2, 2 * s1 + 2 * s2))
| false | 20 | [
"-x = input().split()",
"-a = int(x[0]) * int(x[1])",
"-b = 2 * (int(x[1]) + int(x[0]))",
"-print((a, b))",
"+s = input().rstrip().split(\" \")",
"+s1 = int(s[0])",
"+s2 = int(s[1])",
"+print((s1 * s2, 2 * s1 + 2 * s2))"
] | false | 0.048509 | 0.066486 | 0.729615 | [
"s608922197",
"s458055594"
] |
u312025627 | p03775 | python | s549681208 | s083575057 | 179 | 67 | 39,664 | 64,620 | Accepted | Accepted | 62.57 | def main():
N = int(eval(input()))
def trial_division(n):
divs = []
for i in range(1, int(n**0.5)+1):
if n % i == 0 and i != n//i:
divs.append((i, n//i))
elif n % i == 0 and i == n//i:
divs.append((i, i))
return divs
ans = 10**13
divs = trial_division(N)
for a, b in divs:
ans = min(ans, max(len(str(a)), len(str(b))))
print(ans)
if __name__ == '__main__':
main()
| def main():
N = int(eval(input()))
def enum_divisors(n):
ans = 10**12
for i in range(1, n+1):
if i*i > n:
break
if n % i == 0:
v1 = str(i)
v2 = str(n//i)
ans = min(ans, max(len(v1), len(v2)))
return ans
print((enum_divisors(N)))
if __name__ == '__main__':
main()
| 20 | 19 | 496 | 405 | def main():
N = int(eval(input()))
def trial_division(n):
divs = []
for i in range(1, int(n**0.5) + 1):
if n % i == 0 and i != n // i:
divs.append((i, n // i))
elif n % i == 0 and i == n // i:
divs.append((i, i))
return divs
ans = 10**13
divs = trial_division(N)
for a, b in divs:
ans = min(ans, max(len(str(a)), len(str(b))))
print(ans)
if __name__ == "__main__":
main()
| def main():
N = int(eval(input()))
def enum_divisors(n):
ans = 10**12
for i in range(1, n + 1):
if i * i > n:
break
if n % i == 0:
v1 = str(i)
v2 = str(n // i)
ans = min(ans, max(len(v1), len(v2)))
return ans
print((enum_divisors(N)))
if __name__ == "__main__":
main()
| false | 5 | [
"- def trial_division(n):",
"- divs = []",
"- for i in range(1, int(n**0.5) + 1):",
"- if n % i == 0 and i != n // i:",
"- divs.append((i, n // i))",
"- elif n % i == 0 and i == n // i:",
"- divs.append((i, i))",
"- return divs",
"+ def enum_divisors(n):",
"+ ans = 10**12",
"+ for i in range(1, n + 1):",
"+ if i * i > n:",
"+ break",
"+ if n % i == 0:",
"+ v1 = str(i)",
"+ v2 = str(n // i)",
"+ ans = min(ans, max(len(v1), len(v2)))",
"+ return ans",
"- ans = 10**13",
"- divs = trial_division(N)",
"- for a, b in divs:",
"- ans = min(ans, max(len(str(a)), len(str(b))))",
"- print(ans)",
"+ print((enum_divisors(N)))"
] | false | 0.042475 | 0.079299 | 0.535633 | [
"s549681208",
"s083575057"
] |
u644972721 | p03037 | python | s853943285 | s997087994 | 278 | 231 | 3,060 | 12,732 | Accepted | Accepted | 16.91 | n , m = list(map(int,input().split()))
a , b = 1 , 100000
for i in range(m):
l , r = list(map(int,input().split()))
if a <= l:
a = l
if b >= r:
b = r
c = b - a + 1
if c > 0:
print(c)
else:
print((0)) | n, m = list(map(int, input().split()))
ok = [0] * (n + 2)
ans = 0
for _ in range(m):
l, r = list(map(int, input().split()))
ok[l] += 1
ok[r + 1] -= 1
for i in range(1, n + 2):
ok[i] += ok[i - 1]
if ok[i] == m:
ans += 1
print(ans) | 15 | 12 | 245 | 256 | n, m = list(map(int, input().split()))
a, b = 1, 100000
for i in range(m):
l, r = list(map(int, input().split()))
if a <= l:
a = l
if b >= r:
b = r
c = b - a + 1
if c > 0:
print(c)
else:
print((0))
| n, m = list(map(int, input().split()))
ok = [0] * (n + 2)
ans = 0
for _ in range(m):
l, r = list(map(int, input().split()))
ok[l] += 1
ok[r + 1] -= 1
for i in range(1, n + 2):
ok[i] += ok[i - 1]
if ok[i] == m:
ans += 1
print(ans)
| false | 20 | [
"-a, b = 1, 100000",
"-for i in range(m):",
"+ok = [0] * (n + 2)",
"+ans = 0",
"+for _ in range(m):",
"- if a <= l:",
"- a = l",
"- if b >= r:",
"- b = r",
"-c = b - a + 1",
"-if c > 0:",
"- print(c)",
"-else:",
"- print((0))",
"+ ok[l] += 1",
"+ ok[r + 1] -= 1",
"+for i in range(1, n + 2):",
"+ ok[i] += ok[i - 1]",
"+ if ok[i] == m:",
"+ ans += 1",
"+print(ans)"
] | false | 0.037227 | 0.043497 | 0.855841 | [
"s853943285",
"s997087994"
] |
u905203728 | p03221 | python | s256176394 | s136742325 | 816 | 602 | 47,200 | 125,368 | Accepted | Accepted | 26.23 | n,m=list(map(int,input().split()))
A=[[i,list(map(int,input().split()))] for i in range(m)]
A.sort(key=lambda x:x[1][1])
B={}
for x,y in A:
if y[0] not in B:
B[y[0]]=1
y[1]=1
else:
B[y[0]] +=1
y[1]=B[y[0]]
for i in sorted(A,key=lambda x:x[0]):
print((str(i[1][0]).zfill(6)+str(i[1][1]).zfill(6))) | n,m=list(map(int,input().split()))
PY=sorted([list(map(int,input().split()))+[_] for _ in range(m)],key=lambda x:x[1])
A,B={},[]
for p,y,num in PY:
if p not in A:
A[p]=1
B.append([p,A[p],num])
else:
A[p] +=1
B.append([p,A[p],num])
for a,b,c in sorted(B,key=lambda x:x[2]):
print((str(a).zfill(6)+str(b).zfill(6))) | 14 | 14 | 346 | 364 | n, m = list(map(int, input().split()))
A = [[i, list(map(int, input().split()))] for i in range(m)]
A.sort(key=lambda x: x[1][1])
B = {}
for x, y in A:
if y[0] not in B:
B[y[0]] = 1
y[1] = 1
else:
B[y[0]] += 1
y[1] = B[y[0]]
for i in sorted(A, key=lambda x: x[0]):
print((str(i[1][0]).zfill(6) + str(i[1][1]).zfill(6)))
| n, m = list(map(int, input().split()))
PY = sorted(
[list(map(int, input().split())) + [_] for _ in range(m)], key=lambda x: x[1]
)
A, B = {}, []
for p, y, num in PY:
if p not in A:
A[p] = 1
B.append([p, A[p], num])
else:
A[p] += 1
B.append([p, A[p], num])
for a, b, c in sorted(B, key=lambda x: x[2]):
print((str(a).zfill(6) + str(b).zfill(6)))
| false | 0 | [
"-A = [[i, list(map(int, input().split()))] for i in range(m)]",
"-A.sort(key=lambda x: x[1][1])",
"-B = {}",
"-for x, y in A:",
"- if y[0] not in B:",
"- B[y[0]] = 1",
"- y[1] = 1",
"+PY = sorted(",
"+ [list(map(int, input().split())) + [_] for _ in range(m)], key=lambda x: x[1]",
"+)",
"+A, B = {}, []",
"+for p, y, num in PY:",
"+ if p not in A:",
"+ A[p] = 1",
"+ B.append([p, A[p], num])",
"- B[y[0]] += 1",
"- y[1] = B[y[0]]",
"-for i in sorted(A, key=lambda x: x[0]):",
"- print((str(i[1][0]).zfill(6) + str(i[1][1]).zfill(6)))",
"+ A[p] += 1",
"+ B.append([p, A[p], num])",
"+for a, b, c in sorted(B, key=lambda x: x[2]):",
"+ print((str(a).zfill(6) + str(b).zfill(6)))"
] | false | 0.073328 | 0.037425 | 1.959329 | [
"s256176394",
"s136742325"
] |
u673361376 | p02996 | python | s752192397 | s537356442 | 1,985 | 1,044 | 82,648 | 35,648 | Accepted | Accepted | 47.41 | import heapq
N = int(eval(input()))
tasks = []
for _ in range(N):
a,b = list(map(int,input().split()))
if b-a < 0:
print('No')
exit()
else:
heapq.heappush(tasks,[b,-a])
day = 0
while len(tasks) != 0:
b, neg_a = heapq.heappop(tasks)
if day - neg_a > b:
print('No')
exit()
else: day -= neg_a
print('Yes') | N = int(eval(input()))
deadlines = []
for i in range(N):
a, b = list(map(int, input().split()))
deadlines.append([b, a])
deadlines.sort()
time = 0
for deadline, task_time in deadlines:
if time + task_time <= deadline:
time += task_time
else:
time = None
break
print(('Yes' if time is not None else 'No')) | 20 | 15 | 347 | 345 | import heapq
N = int(eval(input()))
tasks = []
for _ in range(N):
a, b = list(map(int, input().split()))
if b - a < 0:
print("No")
exit()
else:
heapq.heappush(tasks, [b, -a])
day = 0
while len(tasks) != 0:
b, neg_a = heapq.heappop(tasks)
if day - neg_a > b:
print("No")
exit()
else:
day -= neg_a
print("Yes")
| N = int(eval(input()))
deadlines = []
for i in range(N):
a, b = list(map(int, input().split()))
deadlines.append([b, a])
deadlines.sort()
time = 0
for deadline, task_time in deadlines:
if time + task_time <= deadline:
time += task_time
else:
time = None
break
print(("Yes" if time is not None else "No"))
| false | 25 | [
"-import heapq",
"-",
"-tasks = []",
"-for _ in range(N):",
"+deadlines = []",
"+for i in range(N):",
"- if b - a < 0:",
"- print(\"No\")",
"- exit()",
"+ deadlines.append([b, a])",
"+deadlines.sort()",
"+time = 0",
"+for deadline, task_time in deadlines:",
"+ if time + task_time <= deadline:",
"+ time += task_time",
"- heapq.heappush(tasks, [b, -a])",
"-day = 0",
"-while len(tasks) != 0:",
"- b, neg_a = heapq.heappop(tasks)",
"- if day - neg_a > b:",
"- print(\"No\")",
"- exit()",
"- else:",
"- day -= neg_a",
"-print(\"Yes\")",
"+ time = None",
"+ break",
"+print((\"Yes\" if time is not None else \"No\"))"
] | false | 0.060768 | 0.038469 | 1.57965 | [
"s752192397",
"s537356442"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.