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
u186206732
p02952
python
s381731916
s602304500
57
18
3,064
3,060
Accepted
Accepted
68.42
# ๅ˜็ด”ใซใ™ในใฆใ‚’ใพใ‚ใ—ใฆๆกๆ•ฐใ‚’่จˆ็ฎ—ใ—ใŸใฎใงใ‚ˆใ‹ใฃใŸใ‚‰ใ—ใ„ n = int(eval(input())) ans = 0 for i in range(1, n+1): if len(str(i)) % 2 == 1: ans += 1 print(ans)
n = eval(input()) digit_n = len(str(n)) n = int(n) ans = 0 if digit_n % 2 == 0: for i in range(digit_n // 2): ans += 9 * 10 ** (i * 2) else: if digit_n != 1: for i in range((digit_n - 1) // 2): ans += 9 * 10 ** (i * 2) hasuu = n - 10 ** ((i+1)*2) ans += hasuu + 1 else: ans = n print(ans) # ็ซฏๆ•ฐใฎ่จˆ็ฎ—ใŒ้–“้•ใฃใฆใ„ใŸ
10
23
148
398
# ๅ˜็ด”ใซใ™ในใฆใ‚’ใพใ‚ใ—ใฆๆกๆ•ฐใ‚’่จˆ็ฎ—ใ—ใŸใฎใงใ‚ˆใ‹ใฃใŸใ‚‰ใ—ใ„ n = int(eval(input())) ans = 0 for i in range(1, n + 1): if len(str(i)) % 2 == 1: ans += 1 print(ans)
n = eval(input()) digit_n = len(str(n)) n = int(n) ans = 0 if digit_n % 2 == 0: for i in range(digit_n // 2): ans += 9 * 10 ** (i * 2) else: if digit_n != 1: for i in range((digit_n - 1) // 2): ans += 9 * 10 ** (i * 2) hasuu = n - 10 ** ((i + 1) * 2) ans += hasuu + 1 else: ans = n print(ans) # ็ซฏๆ•ฐใฎ่จˆ็ฎ—ใŒ้–“้•ใฃใฆใ„ใŸ
false
56.521739
[ "-# ๅ˜็ด”ใซใ™ในใฆใ‚’ใพใ‚ใ—ใฆๆกๆ•ฐใ‚’่จˆ็ฎ—ใ—ใŸใฎใงใ‚ˆใ‹ใฃใŸใ‚‰ใ—ใ„", "-n = int(eval(input()))", "+n = eval(input())", "+digit_n = len(str(n))", "+n = int(n)", "-for i in range(1, n + 1):", "- if len(str(i)) % 2 == 1:", "- ans += 1", "+if digit_n % 2 == 0:", "+ for i in range(digit_n // 2):", "+ ans += 9 * 10 *...
false
0.056994
0.042739
1.333517
[ "s381731916", "s602304500" ]
u191874006
p03208
python
s589040076
s107403460
540
252
56,408
44,508
Accepted
Accepted
53.33
#!/usr/bin/env python3 #ABC115 C n,k = list(map(int,input().split())) h = [int(eval(input())) for _ in range(n)] h.sort() s = [h[i+k-1] - h[i] for i in range(n-k+1)] s.sort() print((s[0]))
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) 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())) n,k = LI() h = [I() for _ in range(n)] h.sort() ans = inf for i in range(n-k+1): ans = min(ans, h[i+k-1]-h[i]) print(ans)
8
26
182
691
#!/usr/bin/env python3 # ABC115 C n, k = list(map(int, input().split())) h = [int(eval(input())) for _ in range(n)] h.sort() s = [h[i + k - 1] - h[i] for i in range(n - k + 1)] s.sort() print((s[0]))
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) 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())) n, k = LI() h = [I() for _ in range(n)] h.sort() ans = inf for i in range(n - k + 1): ans = min(ans, h[i + k - 1] - h[i]) print(ans)
false
69.230769
[ "-# ABC115 C", "-n, k = list(map(int, input().split()))", "-h = [int(eval(input())) for _ in range(n)]", "+import sys", "+import math", "+from bisect import bisect_right as br", "+from bisect import bisect_left as bl", "+", "+sys.setrecursionlimit(2147483647)", "+from heapq import heappush, heappo...
false
0.065642
0.036367
1.804979
[ "s589040076", "s107403460" ]
u562935282
p03005
python
s477503214
s716799919
186
17
38,384
2,940
Accepted
Accepted
90.86
N, K = list(map(int, input().split())) if K == 1: print((0)) else: print((N - K))
N, K = list(map(int, input().split())) print((0 if K == 1 else N - K))
6
2
86
64
N, K = list(map(int, input().split())) if K == 1: print((0)) else: print((N - K))
N, K = list(map(int, input().split())) print((0 if K == 1 else N - K))
false
66.666667
[ "-if K == 1:", "- print((0))", "-else:", "- print((N - K))", "+print((0 if K == 1 else N - K))" ]
false
0.040191
0.035507
1.131925
[ "s477503214", "s716799919" ]
u759412327
p03731
python
s313297102
s966508011
153
124
25,200
26,708
Accepted
Accepted
18.95
N,T = list(map(int,input().split())) t = list(map(int,input().split())) a = T for i in range(N-1): a+=min(T,t[i+1]-t[i]) print(a)
N,T = list(map(int,input().split())) t = list(map(int,input().split())) print((T+sum([min(T,t[i+1]-t[i]) for i in range(N-1)])))
8
3
140
128
N, T = list(map(int, input().split())) t = list(map(int, input().split())) a = T for i in range(N - 1): a += min(T, t[i + 1] - t[i]) print(a)
N, T = list(map(int, input().split())) t = list(map(int, input().split())) print((T + sum([min(T, t[i + 1] - t[i]) for i in range(N - 1)])))
false
62.5
[ "-a = T", "-for i in range(N - 1):", "- a += min(T, t[i + 1] - t[i])", "-print(a)", "+print((T + sum([min(T, t[i + 1] - t[i]) for i in range(N - 1)])))" ]
false
0.044797
0.046201
0.969613
[ "s313297102", "s966508011" ]
u077291787
p03130
python
s687857643
s547118071
20
18
3,316
3,188
Accepted
Accepted
10
# yahoo-procon2019-qualB - Path from collections import Counter from itertools import chain def main(): P = [list(map(int, input().rstrip().split())) for _ in range(3)] C = Counter(chain.from_iterable(P)).most_common() c = [i[1] for i in C] print(("YES" if c == [2, 2, 1, 1] else "NO")) if __name__ == "__main__": main()
# yahoo-procon2019-qualB - Path def main(): C = [0] * 4 for _ in range(3): a, b = list(map(int, input().rstrip().split())) C[a - 1] += 1 C[b - 1] += 1 print(("YES" if set(C) == {1, 2} else "NO")) if __name__ == "__main__": main()
14
12
355
280
# yahoo-procon2019-qualB - Path from collections import Counter from itertools import chain def main(): P = [list(map(int, input().rstrip().split())) for _ in range(3)] C = Counter(chain.from_iterable(P)).most_common() c = [i[1] for i in C] print(("YES" if c == [2, 2, 1, 1] else "NO")) if __name__ == "__main__": main()
# yahoo-procon2019-qualB - Path def main(): C = [0] * 4 for _ in range(3): a, b = list(map(int, input().rstrip().split())) C[a - 1] += 1 C[b - 1] += 1 print(("YES" if set(C) == {1, 2} else "NO")) if __name__ == "__main__": main()
false
14.285714
[ "-from collections import Counter", "-from itertools import chain", "-", "-", "- P = [list(map(int, input().rstrip().split())) for _ in range(3)]", "- C = Counter(chain.from_iterable(P)).most_common()", "- c = [i[1] for i in C]", "- print((\"YES\" if c == [2, 2, 1, 1] else \"NO\"))", "+ ...
false
0.036057
0.036113
0.998448
[ "s687857643", "s547118071" ]
u553987207
p02911
python
s906323024
s759731045
256
99
4,680
9,900
Accepted
Accepted
61.33
N, K, Q = list(map(int, input().split())) P = [0] * N for _ in range(Q): a = int(eval(input())) - 1 P[a] += 1 for p in P: if Q - p < K: print("Yes") else: print("No")
import sys N, K, Q = list(map(int, input().split())) points = [0] * N for _ in range(Q): a = int(sys.stdin.readline()) points[a-1] += 1 for point in points: if point > (Q - K): print("Yes") else: print("No")
11
11
197
243
N, K, Q = list(map(int, input().split())) P = [0] * N for _ in range(Q): a = int(eval(input())) - 1 P[a] += 1 for p in P: if Q - p < K: print("Yes") else: print("No")
import sys N, K, Q = list(map(int, input().split())) points = [0] * N for _ in range(Q): a = int(sys.stdin.readline()) points[a - 1] += 1 for point in points: if point > (Q - K): print("Yes") else: print("No")
false
0
[ "+import sys", "+", "-P = [0] * N", "+points = [0] * N", "- a = int(eval(input())) - 1", "- P[a] += 1", "-for p in P:", "- if Q - p < K:", "+ a = int(sys.stdin.readline())", "+ points[a - 1] += 1", "+for point in points:", "+ if point > (Q - K):" ]
false
0.052852
0.036851
1.434194
[ "s906323024", "s759731045" ]
u698535708
p03607
python
s669842124
s381943134
233
200
8,284
16,636
Accepted
Accepted
14.16
N = int(eval(input())) a = [int(eval(input())) for i in range(N)] a = sorted(a) t = 0 b = False ans = 0 for i in range(N): if not a[i] == t: if b: ans += 1 t = a[i] b = True else: if b: b = False else: b = True if b: ans += 1 print(ans)
from collections import Counter N = int(eval(input())) A = [int(eval(input())) for i in range(N)] c = Counter(A) ans = 0 for a, b in list(c.items()): if b % 2 == 1: ans += 1 print(ans)
25
13
341
194
N = int(eval(input())) a = [int(eval(input())) for i in range(N)] a = sorted(a) t = 0 b = False ans = 0 for i in range(N): if not a[i] == t: if b: ans += 1 t = a[i] b = True else: if b: b = False else: b = True if b: ans += 1 print(ans)
from collections import Counter N = int(eval(input())) A = [int(eval(input())) for i in range(N)] c = Counter(A) ans = 0 for a, b in list(c.items()): if b % 2 == 1: ans += 1 print(ans)
false
48
[ "+from collections import Counter", "+", "-a = [int(eval(input())) for i in range(N)]", "-a = sorted(a)", "-t = 0", "-b = False", "+A = [int(eval(input())) for i in range(N)]", "+c = Counter(A)", "-for i in range(N):", "- if not a[i] == t:", "- if b:", "- ans += 1", "- ...
false
0.044101
0.04452
0.990574
[ "s669842124", "s381943134" ]
u119148115
p02560
python
s728008366
s549451630
378
266
78,220
77,816
Accepted
Accepted
29.63
import sys def I(): return int(sys.stdin.readline().rstrip()) def MI(): return list(map(int,sys.stdin.readline().rstrip().split())) def floor_sum(n,m,a,b): # sum((A*i+B)//M for i in range(N)) res = 0 res += (a//m)*n*(n-1)//2 + (b//m)*n a %= m b %= m y_max = (a*n+b)//m if y_max == 0: return res x_max = m*y_max-b res += (n+(-x_max)//a)*y_max res += floor_sum(y_max,a,m,(x_max+a-1)//a*a-x_max) return res T = I() for i in range(T): n,m,a,b = MI() print((floor_sum(n,m,a,b)))
import sys def I(): return int(sys.stdin.readline().rstrip()) def MI(): return list(map(int,sys.stdin.readline().rstrip().split())) def floor_sum(n,m,a,b): # sum((A*i+B)//M for i in range(N)) res = 0 if a >= m: res += (a//m)*n*(n-1)//2 a %= m if b >= m: res += (b//m)*n b %= m y_max = (a*n+b)//m if y_max == 0: return res x_max = m*y_max-b res += (n+(-x_max)//a)*y_max res += floor_sum(y_max,a,m,(x_max+a-1)//a*a-x_max) return res T = I() for i in range(T): n,m,a,b = MI() print((floor_sum(n,m,a,b)))
23
26
549
607
import sys def I(): return int(sys.stdin.readline().rstrip()) def MI(): return list(map(int, sys.stdin.readline().rstrip().split())) def floor_sum(n, m, a, b): # sum((A*i+B)//M for i in range(N)) res = 0 res += (a // m) * n * (n - 1) // 2 + (b // m) * n a %= m b %= m y_max = (a * n + b) // m if y_max == 0: return res x_max = m * y_max - b res += (n + (-x_max) // a) * y_max res += floor_sum(y_max, a, m, (x_max + a - 1) // a * a - x_max) return res T = I() for i in range(T): n, m, a, b = MI() print((floor_sum(n, m, a, b)))
import sys def I(): return int(sys.stdin.readline().rstrip()) def MI(): return list(map(int, sys.stdin.readline().rstrip().split())) def floor_sum(n, m, a, b): # sum((A*i+B)//M for i in range(N)) res = 0 if a >= m: res += (a // m) * n * (n - 1) // 2 a %= m if b >= m: res += (b // m) * n b %= m y_max = (a * n + b) // m if y_max == 0: return res x_max = m * y_max - b res += (n + (-x_max) // a) * y_max res += floor_sum(y_max, a, m, (x_max + a - 1) // a * a - x_max) return res T = I() for i in range(T): n, m, a, b = MI() print((floor_sum(n, m, a, b)))
false
11.538462
[ "- res += (a // m) * n * (n - 1) // 2 + (b // m) * n", "- a %= m", "- b %= m", "+ if a >= m:", "+ res += (a // m) * n * (n - 1) // 2", "+ a %= m", "+ if b >= m:", "+ res += (b // m) * n", "+ b %= m" ]
false
0.036749
0.037032
0.992378
[ "s728008366", "s549451630" ]
u029000441
p02813
python
s490948350
s030435004
35
31
8,052
3,444
Accepted
Accepted
11.43
import itertools n=int(eval(input())) numbers1k=[] numbers2k=[] s=[] for i in range(n): s.append(i+1) p=itertools.permutations(s,n) u=list(p) #print(u) numbers1=input().rstrip().split(" ") for num1 in numbers1: numbers1k.append(int(num1)) numbers2=input().rstrip().split(" ") for num2 in numbers2: numbers2k.append(int(num2)) com1=tuple(numbers1k) com2=tuple(numbers2k) for i in range(len(u)): if u[i]==com1: a=i+1 for j in range(len(u)): if u[j]==com2: b=j+1 #print(a) #print(b) print((abs(b-a)))
#floatๅž‹ใ‚’่จฑใ™ใช #numpyใฏpythonใง import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby, product from bisect import bisect_left,bisect_right from heapq import heapify, heappop, heappush from math import floor, ceil,pi,factorial from operator import itemgetter def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def LI2(): return [int(eval(input())) for i in range(n)] def MXI(): return [[LI()]for i in range(n)] def SI(): return input().rstrip() def printns(x): print(('\n'.join(x))) def printni(x): print(('\n'.join(list(map(str,x))))) inf = 10**17 mod = 10**9 + 7 n=I() lisp=tuple(LI()) lisq=tuple(LI()) x=[i for i in range(1,n+1)] u=permutations(x) count=0 for i in u: if i==lisp: P=count if i==lisq: Q=count count+=1 print((abs(P-Q)))
27
39
551
1,026
import itertools n = int(eval(input())) numbers1k = [] numbers2k = [] s = [] for i in range(n): s.append(i + 1) p = itertools.permutations(s, n) u = list(p) # print(u) numbers1 = input().rstrip().split(" ") for num1 in numbers1: numbers1k.append(int(num1)) numbers2 = input().rstrip().split(" ") for num2 in numbers2: numbers2k.append(int(num2)) com1 = tuple(numbers1k) com2 = tuple(numbers2k) for i in range(len(u)): if u[i] == com1: a = i + 1 for j in range(len(u)): if u[j] == com2: b = j + 1 # print(a) # print(b) print((abs(b - a)))
# floatๅž‹ใ‚’่จฑใ™ใช # numpyใฏpythonใง import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby, product from bisect import bisect_left, bisect_right from heapq import heapify, heappop, heappush from math import floor, ceil, pi, factorial from operator import itemgetter def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def LI2(): return [int(eval(input())) for i in range(n)] def MXI(): return [[LI()] for i in range(n)] def SI(): return input().rstrip() def printns(x): print(("\n".join(x))) def printni(x): print(("\n".join(list(map(str, x))))) inf = 10**17 mod = 10**9 + 7 n = I() lisp = tuple(LI()) lisq = tuple(LI()) x = [i for i in range(1, n + 1)] u = permutations(x) count = 0 for i in u: if i == lisp: P = count if i == lisq: Q = count count += 1 print((abs(P - Q)))
false
30.769231
[ "-import itertools", "+# floatๅž‹ใ‚’่จฑใ™ใช", "+# numpyใฏpythonใง", "+import sys", "-n = int(eval(input()))", "-numbers1k = []", "-numbers2k = []", "-s = []", "-for i in range(n):", "- s.append(i + 1)", "-p = itertools.permutations(s, n)", "-u = list(p)", "-# print(u)", "-numbers1 = input().rstri...
false
0.04177
0.038236
1.092425
[ "s490948350", "s030435004" ]
u021916304
p03361
python
s719701994
s529493670
26
19
3,064
3,064
Accepted
Accepted
26.92
def ii():return int(eval(input())) def iim():return list(map(int,input().split())) def iil():return list(map(int,input().split())) def ism():return list(map(str,input().split())) def isl():return list(map(str,input().split())) h,w = iim() flag = True l = [] dx = [0,0,1,-1] dy = [1,-1,0,0] for i in range(h): l.append(list(eval(input()))) for i in range(h): for j in range(w): if l[i][j] == '#': check = False for k in range(4): if i+dx[k] < 0 or i+dx[k] >= h: continue if j+dy[k] < 0 or j+dy[k] >= w: continue if l[i+dx[k]][j+dy[k]] == '#': check = True if not check: flag = False print(('Yes' if flag else 'No'))
def ii():return int(eval(input())) def iim():return list(map(int,input().split())) def iil():return list(map(int,input().split())) def ism():return list(map(str,input().split())) def isl():return list(map(str,input().split())) h,w = iim() l = [] l.append(['.']*(w+2)) for _ in range(h): l.append(['.']+list(eval(input()))+['.']) l.append(['.']*(w+2)) flag = True for i in range(1,h+1,): for j in range(1,w+1): if l[i][j] == '#': tmp = [l[i-1][j],l[i+1][j],l[i][j-1],l[i][j+1]] if '#' not in tmp: flag = False print(('Yes' if flag else 'No'))
31
21
799
593
def ii(): return int(eval(input())) def iim(): return list(map(int, input().split())) def iil(): return list(map(int, input().split())) def ism(): return list(map(str, input().split())) def isl(): return list(map(str, input().split())) h, w = iim() flag = True l = [] dx = [0, 0, 1, -1] dy = [1, -1, 0, 0] for i in range(h): l.append(list(eval(input()))) for i in range(h): for j in range(w): if l[i][j] == "#": check = False for k in range(4): if i + dx[k] < 0 or i + dx[k] >= h: continue if j + dy[k] < 0 or j + dy[k] >= w: continue if l[i + dx[k]][j + dy[k]] == "#": check = True if not check: flag = False print(("Yes" if flag else "No"))
def ii(): return int(eval(input())) def iim(): return list(map(int, input().split())) def iil(): return list(map(int, input().split())) def ism(): return list(map(str, input().split())) def isl(): return list(map(str, input().split())) h, w = iim() l = [] l.append(["."] * (w + 2)) for _ in range(h): l.append(["."] + list(eval(input())) + ["."]) l.append(["."] * (w + 2)) flag = True for i in range( 1, h + 1, ): for j in range(1, w + 1): if l[i][j] == "#": tmp = [l[i - 1][j], l[i + 1][j], l[i][j - 1], l[i][j + 1]] if "#" not in tmp: flag = False print(("Yes" if flag else "No"))
false
32.258065
[ "+l = []", "+l.append([\".\"] * (w + 2))", "+for _ in range(h):", "+ l.append([\".\"] + list(eval(input())) + [\".\"])", "+l.append([\".\"] * (w + 2))", "-l = []", "-dx = [0, 0, 1, -1]", "-dy = [1, -1, 0, 0]", "-for i in range(h):", "- l.append(list(eval(input())))", "-for i in range(h):",...
false
0.037141
0.036383
1.020819
[ "s719701994", "s529493670" ]
u001024152
p03478
python
s417494990
s654318787
33
30
3,060
2,940
Accepted
Accepted
9.09
n,a,b = list(map(int, input().split())) ans = 0 for i in range(1,n+1): digits = list(map(int, list(str(i)))) i_sum = sum(digits) if a <= i_sum <= b: ans += i print(ans)
N, A, B = list(map(int, input().split())) ans = 0 for i in range(1, N+1): s = 0 j = i while i > 0: s += i % 10 i //= 10 if A <= s <= B: ans += j print(ans)
10
12
187
202
n, a, b = list(map(int, input().split())) ans = 0 for i in range(1, n + 1): digits = list(map(int, list(str(i)))) i_sum = sum(digits) if a <= i_sum <= b: ans += i print(ans)
N, A, B = list(map(int, input().split())) ans = 0 for i in range(1, N + 1): s = 0 j = i while i > 0: s += i % 10 i //= 10 if A <= s <= B: ans += j print(ans)
false
16.666667
[ "-n, a, b = list(map(int, input().split()))", "+N, A, B = list(map(int, input().split()))", "-for i in range(1, n + 1):", "- digits = list(map(int, list(str(i))))", "- i_sum = sum(digits)", "- if a <= i_sum <= b:", "- ans += i", "+for i in range(1, N + 1):", "+ s = 0", "+ j =...
false
0.046082
0.076971
0.5987
[ "s417494990", "s654318787" ]
u994988729
p02834
python
s325991503
s183338469
577
450
29,456
29,836
Accepted
Accepted
22.01
from collections import deque N, U, V = list(map(int, input().split())) U -= 1 V -= 1 tree = [[] for _ in range(N)] for _ in range(N - 1): a, b = list(map(int, input().split())) a -= 1 b -= 1 tree[a].append(b) tree[b].append(a) def get_rank(v): rank = [-1] * N next_v = deque([v]) rank[v] = 0 while next_v: node = next_v.popleft() r = rank[node] for i in tree[node]: if rank[i] != -1: continue rank[i] = r + 1 next_v.append(i) return rank takahashi = get_rank(U) aoki = get_rank(V) ans = 0 for x, y in zip(takahashi, aoki): if x <= y: ans = max(ans, y-1) print(ans)
import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) N, u, v = list(map(int, input().split())) edge = [[] for _ in range(N + 1)] for _ in range(N - 1): a, b = list(map(int, input().split())) edge[a].append(b) edge[b].append(a) def calc_dist(s): dist = [-1] * (N + 1) dist[s] = 0 node = [s] while node: s = node.pop() d = dist[s] for t in edge[s]: if dist[t] != -1: continue dist[t] = d + 1 node.append(t) return dist[1:] taka = calc_dist(u) aoki = calc_dist(v) ans = 0 for x, y in zip(taka, aoki): if x <= y: ans = max(ans, y - 1) print(ans)
36
36
721
715
from collections import deque N, U, V = list(map(int, input().split())) U -= 1 V -= 1 tree = [[] for _ in range(N)] for _ in range(N - 1): a, b = list(map(int, input().split())) a -= 1 b -= 1 tree[a].append(b) tree[b].append(a) def get_rank(v): rank = [-1] * N next_v = deque([v]) rank[v] = 0 while next_v: node = next_v.popleft() r = rank[node] for i in tree[node]: if rank[i] != -1: continue rank[i] = r + 1 next_v.append(i) return rank takahashi = get_rank(U) aoki = get_rank(V) ans = 0 for x, y in zip(takahashi, aoki): if x <= y: ans = max(ans, y - 1) print(ans)
import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10**7) N, u, v = list(map(int, input().split())) edge = [[] for _ in range(N + 1)] for _ in range(N - 1): a, b = list(map(int, input().split())) edge[a].append(b) edge[b].append(a) def calc_dist(s): dist = [-1] * (N + 1) dist[s] = 0 node = [s] while node: s = node.pop() d = dist[s] for t in edge[s]: if dist[t] != -1: continue dist[t] = d + 1 node.append(t) return dist[1:] taka = calc_dist(u) aoki = calc_dist(v) ans = 0 for x, y in zip(taka, aoki): if x <= y: ans = max(ans, y - 1) print(ans)
false
0
[ "-from collections import deque", "+import sys", "-N, U, V = list(map(int, input().split()))", "-U -= 1", "-V -= 1", "-tree = [[] for _ in range(N)]", "+input = sys.stdin.buffer.readline", "+sys.setrecursionlimit(10**7)", "+N, u, v = list(map(int, input().split()))", "+edge = [[] for _ in range(N ...
false
0.034439
0.037093
0.928442
[ "s325991503", "s183338469" ]
u102902647
p03162
python
s386603485
s709232509
691
355
71,128
50,052
Accepted
Accepted
48.63
N = int(eval(input())) happy_list = [list(map(int, input().split())) for n in range(N)] def chmax(a, b): if a > b: return a else: return b dp_list = [[0, 0, 0]] for n in range(1, N+1): tmp = [0, 0, 0] tmp[1] = chmax(tmp[1], dp_list[n-1][0] + happy_list[n-1][1]) tmp[2] = chmax(tmp[2], dp_list[n-1][0] + happy_list[n-1][2]) tmp[0] = chmax(tmp[0], dp_list[n-1][1] + happy_list[n-1][0]) tmp[2] = chmax(tmp[2], dp_list[n-1][1] + happy_list[n-1][2]) tmp[0] = chmax(tmp[0], dp_list[n-1][2] + happy_list[n-1][0]) tmp[1] = chmax(tmp[1], dp_list[n-1][2] + happy_list[n-1][1]) dp_list.append(tmp) print((max(tmp)))
N = int(eval(input())) abc_list = [list(map(int, input().split())) for _ in range(N)] happy_list = [[0, 0, 0]] # nๆ—ฅ็›ฎใซa|b|cใ‚’้ธใ‚“ใ ใจใใฎๅนธ็ฆใฎใใ“ใพใงใฎๆœ€ๅคงๅ€ค # before_act = -1 # a: 0, b: 1, c: 2 for n in range(N): before_happy_a, before_happy_b, before_happy_c = happy_list[-1] a, b, c = abc_list[n] tmp_happy_a = max(before_happy_b, before_happy_c) + a tmp_happy_b = max(before_happy_c, before_happy_a) + b tmp_happy_c = max(before_happy_a, before_happy_b) + c happy_list.append([tmp_happy_a, tmp_happy_b, tmp_happy_c]) print((max(happy_list[-1])))
18
14
669
563
N = int(eval(input())) happy_list = [list(map(int, input().split())) for n in range(N)] def chmax(a, b): if a > b: return a else: return b dp_list = [[0, 0, 0]] for n in range(1, N + 1): tmp = [0, 0, 0] tmp[1] = chmax(tmp[1], dp_list[n - 1][0] + happy_list[n - 1][1]) tmp[2] = chmax(tmp[2], dp_list[n - 1][0] + happy_list[n - 1][2]) tmp[0] = chmax(tmp[0], dp_list[n - 1][1] + happy_list[n - 1][0]) tmp[2] = chmax(tmp[2], dp_list[n - 1][1] + happy_list[n - 1][2]) tmp[0] = chmax(tmp[0], dp_list[n - 1][2] + happy_list[n - 1][0]) tmp[1] = chmax(tmp[1], dp_list[n - 1][2] + happy_list[n - 1][1]) dp_list.append(tmp) print((max(tmp)))
N = int(eval(input())) abc_list = [list(map(int, input().split())) for _ in range(N)] happy_list = [[0, 0, 0]] # nๆ—ฅ็›ฎใซa|b|cใ‚’้ธใ‚“ใ ใจใใฎๅนธ็ฆใฎใใ“ใพใงใฎๆœ€ๅคงๅ€ค # before_act = -1 # a: 0, b: 1, c: 2 for n in range(N): before_happy_a, before_happy_b, before_happy_c = happy_list[-1] a, b, c = abc_list[n] tmp_happy_a = max(before_happy_b, before_happy_c) + a tmp_happy_b = max(before_happy_c, before_happy_a) + b tmp_happy_c = max(before_happy_a, before_happy_b) + c happy_list.append([tmp_happy_a, tmp_happy_b, tmp_happy_c]) print((max(happy_list[-1])))
false
22.222222
[ "-happy_list = [list(map(int, input().split())) for n in range(N)]", "-", "-", "-def chmax(a, b):", "- if a > b:", "- return a", "- else:", "- return b", "-", "-", "-dp_list = [[0, 0, 0]]", "-for n in range(1, N + 1):", "- tmp = [0, 0, 0]", "- tmp[1] = chmax(tmp[1...
false
0.047832
0.034832
1.373212
[ "s386603485", "s709232509" ]
u678167152
p03608
python
s208822669
s120215194
586
520
72,280
61,144
Accepted
Accepted
11.26
N, M, R = list(map(int, input().split())) r = list(map(int, input().split())) #Warshall Floyd d = [[float('inf')]*N for _ in range(N)] for _ in range(M): #ใฒใจใพใšๆžใŒใ‚ใ‚‹ใƒšใ‚ขใฏๆžใฎ้•ทใ•ใ‚’ใ‚ปใƒƒใƒˆ a,b,t = list(map(int, input().split())) d[a-1][b-1] = t d[b-1][a-1] = t for i in range(N): d[i][i] = 0 #่‡ช่บซใธใฎๆœ€็Ÿญ็ตŒ่ทฏใฏ0 #ไธ‰้‡ใƒซใƒผใƒ— for k in range(N): for i in range(N): for j in range(N): d[i][j] = min(d[i][j], d[i][k]+d[k][j]) from itertools import groupby, accumulate, product, permutations, combinations def solve(r,d): ans = float('inf') for p in permutations(r,R): dist = 0 for i in range(R-1): dist += d[p[i]-1][p[i+1]-1] ans = min(ans,dist) return ans print((solve(r,d)))
from itertools import groupby, accumulate, product, permutations, combinations def solve(): ans = float('inf') N, M, R = list(map(int, input().split())) r = list(map(int, input().split())) d = [[float('inf')]*N for _ in range(N)] for i in range(M): a,b,c = list(map(int, input().split())) d[a-1][b-1] = c d[b-1][a-1] = c for i in range(N): d[i][i] = 0 #่‡ช่บซใธใฎๆœ€็Ÿญ็ตŒ่ทฏใฏ0 #ไธ‰้‡ใƒซใƒผใƒ— for k in range(N): for i in range(N): for j in range(N): d[i][j] = min(d[i][j], d[i][k]+d[k][j]) for p in permutations(r,R): cnt = 0 for i in range(R-1): if d[p[i]-1][p[i+1]-1]<float('inf'): cnt += d[p[i]-1][p[i+1]-1] else: break else: ans = min(ans,cnt) return ans print((solve()))
28
28
748
866
N, M, R = list(map(int, input().split())) r = list(map(int, input().split())) # Warshall Floyd d = [[float("inf")] * N for _ in range(N)] for _ in range(M): # ใฒใจใพใšๆžใŒใ‚ใ‚‹ใƒšใ‚ขใฏๆžใฎ้•ทใ•ใ‚’ใ‚ปใƒƒใƒˆ a, b, t = list(map(int, input().split())) d[a - 1][b - 1] = t d[b - 1][a - 1] = t for i in range(N): d[i][i] = 0 # ่‡ช่บซใธใฎๆœ€็Ÿญ็ตŒ่ทฏใฏ0 # ไธ‰้‡ใƒซใƒผใƒ— for k in range(N): for i in range(N): for j in range(N): d[i][j] = min(d[i][j], d[i][k] + d[k][j]) from itertools import groupby, accumulate, product, permutations, combinations def solve(r, d): ans = float("inf") for p in permutations(r, R): dist = 0 for i in range(R - 1): dist += d[p[i] - 1][p[i + 1] - 1] ans = min(ans, dist) return ans print((solve(r, d)))
from itertools import groupby, accumulate, product, permutations, combinations def solve(): ans = float("inf") N, M, R = list(map(int, input().split())) r = list(map(int, input().split())) d = [[float("inf")] * N for _ in range(N)] for i in range(M): a, b, c = list(map(int, input().split())) d[a - 1][b - 1] = c d[b - 1][a - 1] = c for i in range(N): d[i][i] = 0 # ่‡ช่บซใธใฎๆœ€็Ÿญ็ตŒ่ทฏใฏ0 # ไธ‰้‡ใƒซใƒผใƒ— for k in range(N): for i in range(N): for j in range(N): d[i][j] = min(d[i][j], d[i][k] + d[k][j]) for p in permutations(r, R): cnt = 0 for i in range(R - 1): if d[p[i] - 1][p[i + 1] - 1] < float("inf"): cnt += d[p[i] - 1][p[i + 1] - 1] else: break else: ans = min(ans, cnt) return ans print((solve()))
false
0
[ "-N, M, R = list(map(int, input().split()))", "-r = list(map(int, input().split()))", "-# Warshall Floyd", "-d = [[float(\"inf\")] * N for _ in range(N)]", "-for _ in range(M): # ใฒใจใพใšๆžใŒใ‚ใ‚‹ใƒšใ‚ขใฏๆžใฎ้•ทใ•ใ‚’ใ‚ปใƒƒใƒˆ", "- a, b, t = list(map(int, input().split()))", "- d[a - 1][b - 1] = t", "- d[b - 1][a - 1] ...
false
0.117998
0.075738
1.557981
[ "s208822669", "s120215194" ]
u624475441
p03162
python
s688057988
s434646171
403
245
34,632
3,064
Accepted
Accepted
39.21
import sys N = int(eval(input())) A = [0] * N B = [0] * N C = [0] * N for i, e in enumerate(sys.stdin): A[i], B[i], C[i] = list(map(int, e.split())) dp = [[0] * 3 for _ in range(N + 1)] for i in range(N): dp[i][0] = max(dp[i - 1][1] + A[i], dp[i - 1][2] + A[i]) dp[i][1] = max(dp[i - 1][0] + B[i], dp[i - 1][2] + B[i]) dp[i][2] = max(dp[i - 1][0] + C[i], dp[i - 1][1] + C[i]) print((max(dp[N - 1])))
import sys N = int(eval(input())) x, y, z = 0, 0, 0 for i, e in enumerate(sys.stdin): a, b, c = list(map(int, e.split())) nx = max(y, z) + a ny = max(x, z) + b nz = max(x, y) + c x, y, z = nx, ny, nz print((max(x, y, z)))
13
10
413
236
import sys N = int(eval(input())) A = [0] * N B = [0] * N C = [0] * N for i, e in enumerate(sys.stdin): A[i], B[i], C[i] = list(map(int, e.split())) dp = [[0] * 3 for _ in range(N + 1)] for i in range(N): dp[i][0] = max(dp[i - 1][1] + A[i], dp[i - 1][2] + A[i]) dp[i][1] = max(dp[i - 1][0] + B[i], dp[i - 1][2] + B[i]) dp[i][2] = max(dp[i - 1][0] + C[i], dp[i - 1][1] + C[i]) print((max(dp[N - 1])))
import sys N = int(eval(input())) x, y, z = 0, 0, 0 for i, e in enumerate(sys.stdin): a, b, c = list(map(int, e.split())) nx = max(y, z) + a ny = max(x, z) + b nz = max(x, y) + c x, y, z = nx, ny, nz print((max(x, y, z)))
false
23.076923
[ "-A = [0] * N", "-B = [0] * N", "-C = [0] * N", "+x, y, z = 0, 0, 0", "- A[i], B[i], C[i] = list(map(int, e.split()))", "-dp = [[0] * 3 for _ in range(N + 1)]", "-for i in range(N):", "- dp[i][0] = max(dp[i - 1][1] + A[i], dp[i - 1][2] + A[i])", "- dp[i][1] = max(dp[i - 1][0] + B[i], dp[i -...
false
0.039177
0.048357
0.81016
[ "s688057988", "s434646171" ]
u767664985
p02768
python
s409401668
s743071203
1,512
157
3,064
3,572
Accepted
Accepted
89.62
def cmb(n, r, p): r = min(r, n - r) res = 1 for i in range(r): res *= pow(i+1, p-2, p) # ๅˆ†ๆฏใฎ้€†ๅ…ƒ(ใƒ•ใ‚งใƒซใƒžใƒผใฎๅฎš็†) res *= n-i # ๅˆ†ๅญ res %= p return res p = 10 ** 9 + 7 n, a, b = list(map(int, input().split())) ans = pow(2, n, p) - 1 ans -= cmb(n, a, p) + cmb(n, b, p) print((ans % p))
from functools import reduce def cmb(n, r, p): r = min(n - r, r) if r == 0: return 1 numer = reduce(lambda x, y: (x*y)%p, list(range(n, n - r, -1))) denom = reduce(lambda x, y: (x*y)%p, list(range(1, r + 1))) return (numer * pow(denom, p-2, p)) % p p = 10 ** 9 + 7 n, a, b = list(map(int, input().split())) ans = pow(2, n, p) - 1 ans -= cmb(n, a, p) + cmb(n, b, p) print((ans % p))
14
16
322
408
def cmb(n, r, p): r = min(r, n - r) res = 1 for i in range(r): res *= pow(i + 1, p - 2, p) # ๅˆ†ๆฏใฎ้€†ๅ…ƒ(ใƒ•ใ‚งใƒซใƒžใƒผใฎๅฎš็†) res *= n - i # ๅˆ†ๅญ res %= p return res p = 10**9 + 7 n, a, b = list(map(int, input().split())) ans = pow(2, n, p) - 1 ans -= cmb(n, a, p) + cmb(n, b, p) print((ans % p))
from functools import reduce def cmb(n, r, p): r = min(n - r, r) if r == 0: return 1 numer = reduce(lambda x, y: (x * y) % p, list(range(n, n - r, -1))) denom = reduce(lambda x, y: (x * y) % p, list(range(1, r + 1))) return (numer * pow(denom, p - 2, p)) % p p = 10**9 + 7 n, a, b = list(map(int, input().split())) ans = pow(2, n, p) - 1 ans -= cmb(n, a, p) + cmb(n, b, p) print((ans % p))
false
12.5
[ "+from functools import reduce", "+", "+", "- r = min(r, n - r)", "- res = 1", "- for i in range(r):", "- res *= pow(i + 1, p - 2, p) # ๅˆ†ๆฏใฎ้€†ๅ…ƒ(ใƒ•ใ‚งใƒซใƒžใƒผใฎๅฎš็†)", "- res *= n - i # ๅˆ†ๅญ", "- res %= p", "- return res", "+ r = min(n - r, r)", "+ if r == 0:", "+ ...
false
0.688907
0.151432
4.549283
[ "s409401668", "s743071203" ]
u418407003
p02576
python
s934722563
s620576479
32
26
9,100
9,100
Accepted
Accepted
18.75
N, X, T = list(map(int,input().split())) if N % X == 0: print(((N//X)*T)) else: print(((N//X+1)*T))
N, X, T = list(map(int, input().split())) if N % X == 0: print(((N // X) * T)) else: print((((N // X) + 1) * T))
5
5
97
108
N, X, T = list(map(int, input().split())) if N % X == 0: print(((N // X) * T)) else: print(((N // X + 1) * T))
N, X, T = list(map(int, input().split())) if N % X == 0: print(((N // X) * T)) else: print((((N // X) + 1) * T))
false
0
[ "- print(((N // X + 1) * T))", "+ print((((N // X) + 1) * T))" ]
false
0.044562
0.040625
1.096904
[ "s934722563", "s620576479" ]
u788137651
p03660
python
s400139464
s529244467
485
400
35,476
66,376
Accepted
Accepted
17.53
#้ซ˜้€ŸๅŒ–heapqใƒ€ใ‚คใ‚ฏใ‚นใƒˆใƒฉ from collections import * from heapq import* import sys input=lambda:sys.stdin.readline() def BFS(point,d): cost=[1e7]*(n+1) cost[point]=0 Q=deque([(0,point)]) while Q: c,p = Q.popleft() for np in d[p]: if cost[np]==1e7: cost[np]=c+1 Q.append((c+1,np)) return cost n=int(eval(input())) d={} for i in range(n-1): a,b=list(map(int,input().split())) if a in list(d.keys()): d[a].append(b) else: d[a]=[b] if b in list(d.keys()): d[b].append(a) else: d[b]=[a] x=BFS(1,d)[1:] y=BFS(n,d)[1:] #print(x,y) F=0 S=0 for s,t in zip(x,y): if s<=t: F+=1 else: S+=1 if F<=S: print("Snuke") else: print("Fennec")
#้ซ˜้€ŸๅŒ–heapqใƒ€ใ‚คใ‚ฏใ‚นใƒˆใƒฉ from collections import * from heapq import* import sys input=lambda:sys.stdin.readline() def BFS(point,d): cost=[1e7]*(n+1) cost[point]=0 Q=deque([(0,point)]) while Q: c,p = Q.popleft() for np in d[p]: if cost[np]==1e7: cost[np]=c+1 Q.append((c+1,np)) return cost n=int(eval(input())) # d={} d=[[] for _ in range(n+1)] for i in range(n-1): a,b=list(map(int,input().split())) d[a].append(b) d[b].append(a) # if a in d.keys(): # d[a].append(b) # else: # d[a]=[b] # if b in d.keys(): # d[b].append(a) # else: # d[b]=[a] x=BFS(1,d)[1:] y=BFS(n,d)[1:] #print(x,y) F=0 S=0 for s,t in zip(x,y): if s<=t: F+=1 else: S+=1 if F<=S: print("Snuke") else: print("Fennec")
51
55
824
916
# ้ซ˜้€ŸๅŒ–heapqใƒ€ใ‚คใ‚ฏใ‚นใƒˆใƒฉ from collections import * from heapq import * import sys input = lambda: sys.stdin.readline() def BFS(point, d): cost = [1e7] * (n + 1) cost[point] = 0 Q = deque([(0, point)]) while Q: c, p = Q.popleft() for np in d[p]: if cost[np] == 1e7: cost[np] = c + 1 Q.append((c + 1, np)) return cost n = int(eval(input())) d = {} for i in range(n - 1): a, b = list(map(int, input().split())) if a in list(d.keys()): d[a].append(b) else: d[a] = [b] if b in list(d.keys()): d[b].append(a) else: d[b] = [a] x = BFS(1, d)[1:] y = BFS(n, d)[1:] # print(x,y) F = 0 S = 0 for s, t in zip(x, y): if s <= t: F += 1 else: S += 1 if F <= S: print("Snuke") else: print("Fennec")
# ้ซ˜้€ŸๅŒ–heapqใƒ€ใ‚คใ‚ฏใ‚นใƒˆใƒฉ from collections import * from heapq import * import sys input = lambda: sys.stdin.readline() def BFS(point, d): cost = [1e7] * (n + 1) cost[point] = 0 Q = deque([(0, point)]) while Q: c, p = Q.popleft() for np in d[p]: if cost[np] == 1e7: cost[np] = c + 1 Q.append((c + 1, np)) return cost n = int(eval(input())) # d={} d = [[] for _ in range(n + 1)] for i in range(n - 1): a, b = list(map(int, input().split())) d[a].append(b) d[b].append(a) # if a in d.keys(): # d[a].append(b) # else: # d[a]=[b] # if b in d.keys(): # d[b].append(a) # else: # d[b]=[a] x = BFS(1, d)[1:] y = BFS(n, d)[1:] # print(x,y) F = 0 S = 0 for s, t in zip(x, y): if s <= t: F += 1 else: S += 1 if F <= S: print("Snuke") else: print("Fennec")
false
7.272727
[ "-d = {}", "+# d={}", "+d = [[] for _ in range(n + 1)]", "- if a in list(d.keys()):", "- d[a].append(b)", "- else:", "- d[a] = [b]", "- if b in list(d.keys()):", "- d[b].append(a)", "- else:", "- d[b] = [a]", "+ d[a].append(b)", "+ d[b].append(a)...
false
0.052206
0.050972
1.02421
[ "s400139464", "s529244467" ]
u782098901
p03330
python
s767126239
s081460883
1,964
738
7,540
5,620
Accepted
Accepted
62.42
import itertools def main(): N, C = list(map(int, input().split())) D = [list(map(int, input().split())) for _ in range(C)] CC = [list([int(x) - 1 for x in input().split()]) for _ in range(N)] cost = [[0 for _ in range(C)] for _ in range(3)] for c in range(C): for i in range(N): for j in range(N): cost[(i + j) % 3][c] += D[CC[i][j]][c] res = float("inf") color = [i for i in range(C)] for i, c in enumerate(list(itertools.permutations(color, 3))): tmp = 0 for it in range(3): tmp += cost[it][c[it]] res = min(res, tmp) print(res) main()
from itertools import product, permutations N, C = list(map(int, input().split())) D = [list(map(int, input().split())) for _ in range(C)] grid = [list([int(x) - 1 for x in input().split()]) for _ in range(N)] cost = [[0] * C for _ in range(3)] for x, y in product(list(range(N)), list(range(N))): cost[(x + y) % 3][grid[x][y]] += 1 minn = float("inf") for colors in permutations(list(range(C)), 3): t = 0 for s, color_n in enumerate(colors): for color_p, n in enumerate(cost[s]): t += n * D[color_p][color_n] minn = min(minn, t) print(minn)
25
19
675
581
import itertools def main(): N, C = list(map(int, input().split())) D = [list(map(int, input().split())) for _ in range(C)] CC = [list([int(x) - 1 for x in input().split()]) for _ in range(N)] cost = [[0 for _ in range(C)] for _ in range(3)] for c in range(C): for i in range(N): for j in range(N): cost[(i + j) % 3][c] += D[CC[i][j]][c] res = float("inf") color = [i for i in range(C)] for i, c in enumerate(list(itertools.permutations(color, 3))): tmp = 0 for it in range(3): tmp += cost[it][c[it]] res = min(res, tmp) print(res) main()
from itertools import product, permutations N, C = list(map(int, input().split())) D = [list(map(int, input().split())) for _ in range(C)] grid = [list([int(x) - 1 for x in input().split()]) for _ in range(N)] cost = [[0] * C for _ in range(3)] for x, y in product(list(range(N)), list(range(N))): cost[(x + y) % 3][grid[x][y]] += 1 minn = float("inf") for colors in permutations(list(range(C)), 3): t = 0 for s, color_n in enumerate(colors): for color_p, n in enumerate(cost[s]): t += n * D[color_p][color_n] minn = min(minn, t) print(minn)
false
24
[ "-import itertools", "+from itertools import product, permutations", "-", "-def main():", "- N, C = list(map(int, input().split()))", "- D = [list(map(int, input().split())) for _ in range(C)]", "- CC = [list([int(x) - 1 for x in input().split()]) for _ in range(N)]", "- cost = [[0 for _ i...
false
0.105187
0.043243
2.432489
[ "s767126239", "s081460883" ]
u671060652
p03073
python
s467578798
s172136378
312
74
66,156
77,132
Accepted
Accepted
76.28
import itertools import math import fractions import functools import copy s=eval(input()) count1 = 0 for i in range(len(s)): if i % 2 == 0 and s[i] != "0": count1 += 1 if i % 2 != 0 and s[i] == "0": count1 += 1 count2 = 0 for i in range(len(s)): if i % 2 == 0 and s[i] != "1": count2 += 1 if i % 2 != 0 and s[i] == "1": count2 += 1 print((min(count1,count2)))
import math def main(): # n = int(input()) # a, b = map(int, input().split()) # h = list(map(int, input().split())) # s = input() # h = [int(input()) for _ in rane(n)] s = list(eval(input())) # 1010... count1 = 0 # 0101... count2 = 0 for i in range(len(s)): if i % 2 == 0 and s[i] != "1": count1 += 1 if i % 2 != 0 and s[i] != "0": count1 += 1 if i % 2 == 0 and s[i] == "1": count2 += 1 if i % 2 != 0 and s[i] == "0": count2 += 1 print((min(count1, count2))) if __name__ == '__main__': main()
22
30
424
652
import itertools import math import fractions import functools import copy s = eval(input()) count1 = 0 for i in range(len(s)): if i % 2 == 0 and s[i] != "0": count1 += 1 if i % 2 != 0 and s[i] == "0": count1 += 1 count2 = 0 for i in range(len(s)): if i % 2 == 0 and s[i] != "1": count2 += 1 if i % 2 != 0 and s[i] == "1": count2 += 1 print((min(count1, count2)))
import math def main(): # n = int(input()) # a, b = map(int, input().split()) # h = list(map(int, input().split())) # s = input() # h = [int(input()) for _ in rane(n)] s = list(eval(input())) # 1010... count1 = 0 # 0101... count2 = 0 for i in range(len(s)): if i % 2 == 0 and s[i] != "1": count1 += 1 if i % 2 != 0 and s[i] != "0": count1 += 1 if i % 2 == 0 and s[i] == "1": count2 += 1 if i % 2 != 0 and s[i] == "0": count2 += 1 print((min(count1, count2))) if __name__ == "__main__": main()
false
26.666667
[ "-import itertools", "-import fractions", "-import functools", "-import copy", "-s = eval(input())", "-count1 = 0", "-for i in range(len(s)):", "- if i % 2 == 0 and s[i] != \"0\":", "- count1 += 1", "- if i % 2 != 0 and s[i] == \"0\":", "- count1 += 1", "-count2 = 0", "-f...
false
0.047535
0.068784
0.691087
[ "s467578798", "s172136378" ]
u753803401
p03632
python
s581810995
s836334823
20
17
3,316
3,060
Accepted
Accepted
15
a, b, c, d = list(map(int, input().split())) e = max(a, c) f = min(b, d) print((f - e if f - e >= 0 else 0))
l = [0] * (100 + 1) a, b, c, d = list(map(int, input().split())) l[a] += 1 l[b] += -1 l[c] += 1 l[d] += -1 cnt = 0 t = 0 for i in range(101): t += l[i] if t == 2: cnt += 1 print(cnt)
4
13
104
205
a, b, c, d = list(map(int, input().split())) e = max(a, c) f = min(b, d) print((f - e if f - e >= 0 else 0))
l = [0] * (100 + 1) a, b, c, d = list(map(int, input().split())) l[a] += 1 l[b] += -1 l[c] += 1 l[d] += -1 cnt = 0 t = 0 for i in range(101): t += l[i] if t == 2: cnt += 1 print(cnt)
false
69.230769
[ "+l = [0] * (100 + 1)", "-e = max(a, c)", "-f = min(b, d)", "-print((f - e if f - e >= 0 else 0))", "+l[a] += 1", "+l[b] += -1", "+l[c] += 1", "+l[d] += -1", "+cnt = 0", "+t = 0", "+for i in range(101):", "+ t += l[i]", "+ if t == 2:", "+ cnt += 1", "+print(cnt)" ]
false
0.119016
0.063236
1.882087
[ "s581810995", "s836334823" ]
u021019433
p03032
python
s919865651
s132952753
31
27
3,064
3,064
Accepted
Accepted
12.9
from itertools import chain, islice R = lambda: list(map(int, input().split())) n, k = R() v = list(R()) a = sorted((x, i) for i, x in enumerate(v) if x < 0) ans = max(sum(v[m] for m in chain(list(range(i - j)), list(range(n - j, n)))) - sum(islice((x for x, m in a if m < i - j or m >= n - j), k - i)) for i in range(1, min(n, k) + 1) for j in range(i)) print(ans)
from itertools import islice R = lambda: list(map(int, input().split())) n, k = R() v = list(R()) a = sorted((x, i) for i, x in enumerate(v) if x < 0) ans = max(sum(v[:i - j] + v[n - j:]) - sum(islice((x for x, m in a if m < i - j or m >= n - j), k - i)) for i in range(1, min(n, k) + 1) for j in range(i)) print(ans)
10
10
379
343
from itertools import chain, islice R = lambda: list(map(int, input().split())) n, k = R() v = list(R()) a = sorted((x, i) for i, x in enumerate(v) if x < 0) ans = max( sum(v[m] for m in chain(list(range(i - j)), list(range(n - j, n)))) - sum(islice((x for x, m in a if m < i - j or m >= n - j), k - i)) for i in range(1, min(n, k) + 1) for j in range(i) ) print(ans)
from itertools import islice R = lambda: list(map(int, input().split())) n, k = R() v = list(R()) a = sorted((x, i) for i, x in enumerate(v) if x < 0) ans = max( sum(v[: i - j] + v[n - j :]) - sum(islice((x for x, m in a if m < i - j or m >= n - j), k - i)) for i in range(1, min(n, k) + 1) for j in range(i) ) print(ans)
false
0
[ "-from itertools import chain, islice", "+from itertools import islice", "- sum(v[m] for m in chain(list(range(i - j)), list(range(n - j, n))))", "+ sum(v[: i - j] + v[n - j :])" ]
false
0.103427
0.047195
2.191488
[ "s919865651", "s132952753" ]
u363407238
p03448
python
s407528950
s754301467
50
18
3,060
3,060
Accepted
Accepted
64
a=int(eval(input())) b=int(eval(input())) c=int(eval(input())) x=int(eval(input())) ans=0 for i in range(a+1): for j in range(b+1): for k in range(c+1): if i*500 + j*100 + k*50 == x: ans += 1 print(ans)
a=int(eval(input())) b=int(eval(input())) c=int(eval(input())) x=int(eval(input())) ans=0 for i in range(a+1): for j in range(b+1): if 0 <= x - (500*i) - (100*j) <= (50*c): ans += 1 print(ans)
11
10
228
205
a = int(eval(input())) b = int(eval(input())) c = int(eval(input())) x = int(eval(input())) ans = 0 for i in range(a + 1): for j in range(b + 1): for k in range(c + 1): if i * 500 + j * 100 + k * 50 == x: ans += 1 print(ans)
a = int(eval(input())) b = int(eval(input())) c = int(eval(input())) x = int(eval(input())) ans = 0 for i in range(a + 1): for j in range(b + 1): if 0 <= x - (500 * i) - (100 * j) <= (50 * c): ans += 1 print(ans)
false
9.090909
[ "- for k in range(c + 1):", "- if i * 500 + j * 100 + k * 50 == x:", "- ans += 1", "+ if 0 <= x - (500 * i) - (100 * j) <= (50 * c):", "+ ans += 1" ]
false
0.185752
0.036009
5.158535
[ "s407528950", "s754301467" ]
u618251217
p02603
python
s247283281
s061999707
32
28
9,224
9,208
Accepted
Accepted
12.5
N = int(eval(input())) A = list(map(int, input().split())) lis = [0]*N isnextup = [0]*(N-1) # -1:ไธ‹ใŒใ‚‹, 0: ๅŒใ˜, 1:ไธŠใŒใ‚‹ for day in range(N-1): today = A[day] tommorow = A[day+1] if today < tommorow: isnextup[day] = 1 elif today > tommorow: isnextup[day] = -1 money = 1000 stock = 0 for day in range(N-1): if isnextup[day] == 1:#ๅบ•ๅ€คใง่ฒทใ† price = A[day] div, mod = divmod(money, price) money -= price * div stock += div elif isnextup[day] == -1: #ๅคฉไบ•ใงๅฃฒใ‚‹ price = A[day] money += price * stock stock = 0 money += stock*A[-1] print(money)
N = int(eval(input())) A = list(map(int, input().split())) money = 1000 stock = 0 for day in range(N-1): today_price = A[day] tommorow_price = A[day+1] if today_price < tommorow_price: div,mod = divmod(money, today_price) stock += div money = mod elif today_price > tommorow_price: money += today_price * stock stock = 0 money += A[N-1] * stock print(money)
30
17
656
424
N = int(eval(input())) A = list(map(int, input().split())) lis = [0] * N isnextup = [0] * (N - 1) # -1:ไธ‹ใŒใ‚‹, 0: ๅŒใ˜, 1:ไธŠใŒใ‚‹ for day in range(N - 1): today = A[day] tommorow = A[day + 1] if today < tommorow: isnextup[day] = 1 elif today > tommorow: isnextup[day] = -1 money = 1000 stock = 0 for day in range(N - 1): if isnextup[day] == 1: # ๅบ•ๅ€คใง่ฒทใ† price = A[day] div, mod = divmod(money, price) money -= price * div stock += div elif isnextup[day] == -1: # ๅคฉไบ•ใงๅฃฒใ‚‹ price = A[day] money += price * stock stock = 0 money += stock * A[-1] print(money)
N = int(eval(input())) A = list(map(int, input().split())) money = 1000 stock = 0 for day in range(N - 1): today_price = A[day] tommorow_price = A[day + 1] if today_price < tommorow_price: div, mod = divmod(money, today_price) stock += div money = mod elif today_price > tommorow_price: money += today_price * stock stock = 0 money += A[N - 1] * stock print(money)
false
43.333333
[ "-lis = [0] * N", "-isnextup = [0] * (N - 1) # -1:ไธ‹ใŒใ‚‹, 0: ๅŒใ˜, 1:ไธŠใŒใ‚‹", "-for day in range(N - 1):", "- today = A[day]", "- tommorow = A[day + 1]", "- if today < tommorow:", "- isnextup[day] = 1", "- elif today > tommorow:", "- isnextup[day] = -1", "- if isnextup[day] =...
false
0.082513
0.103569
0.7967
[ "s247283281", "s061999707" ]
u677121387
p02701
python
s976467757
s368725768
293
254
38,496
35,572
Accepted
Accepted
13.31
n = int(eval(input())) s = [eval(input()) for _ in range(n)] d = {} for i in range(n): if s[i] not in d: d[s[i]] = 1 print((len(d)))
n = int(eval(input())) s = [eval(input()) for _ in range(n)] print((len(set(s))))
7
3
136
69
n = int(eval(input())) s = [eval(input()) for _ in range(n)] d = {} for i in range(n): if s[i] not in d: d[s[i]] = 1 print((len(d)))
n = int(eval(input())) s = [eval(input()) for _ in range(n)] print((len(set(s))))
false
57.142857
[ "-d = {}", "-for i in range(n):", "- if s[i] not in d:", "- d[s[i]] = 1", "-print((len(d)))", "+print((len(set(s))))" ]
false
0.039725
0.039122
1.015408
[ "s976467757", "s368725768" ]
u462831976
p02265
python
s288572287
s130480009
4,020
1,960
71,848
71,952
Accepted
Accepted
51.24
# -*- coding: utf-8 -*- from collections import deque N = int(eval(input())) q = deque() for i in range(N): lst = input().split() command = lst[0] if command == 'insert': q.appendleft(lst[1]) elif command == 'delete': try: q.remove(lst[1]) except Exception: pass elif command == 'deleteFirst': q.popleft() elif command == 'deleteLast': q.pop() print((*q))
# -*- coding: utf-8 -*- import sys import os from collections import deque N = int(sys.stdin.readline()) q = deque() for i in range(N): lst = sys.stdin.readline().split() command = lst[0] if command == 'insert': q.appendleft(lst[1]) elif command == 'delete': try: q.remove(lst[1]) except Exception: pass elif command == 'deleteFirst': q.popleft() elif command == 'deleteLast': q.pop() print((*q))
23
26
461
512
# -*- coding: utf-8 -*- from collections import deque N = int(eval(input())) q = deque() for i in range(N): lst = input().split() command = lst[0] if command == "insert": q.appendleft(lst[1]) elif command == "delete": try: q.remove(lst[1]) except Exception: pass elif command == "deleteFirst": q.popleft() elif command == "deleteLast": q.pop() print((*q))
# -*- coding: utf-8 -*- import sys import os from collections import deque N = int(sys.stdin.readline()) q = deque() for i in range(N): lst = sys.stdin.readline().split() command = lst[0] if command == "insert": q.appendleft(lst[1]) elif command == "delete": try: q.remove(lst[1]) except Exception: pass elif command == "deleteFirst": q.popleft() elif command == "deleteLast": q.pop() print((*q))
false
11.538462
[ "+import sys", "+import os", "-N = int(eval(input()))", "+N = int(sys.stdin.readline())", "- lst = input().split()", "+ lst = sys.stdin.readline().split()" ]
false
0.07585
0.04395
1.725806
[ "s288572287", "s130480009" ]
u636162168
p03434
python
s436827002
s236040922
20
17
3,060
2,940
Accepted
Accepted
15
n=int(eval(input())) a=list(map(int,input().split())) ali=0 bob=0 a.sort(reverse=True) for i in range(len(a)): if i%2==0: ali+=a[i] else: bob+=a[i] print((ali-bob))
n=int(eval(input())) a=list(map(int,input().split())) a.sort(reverse=True) alice=sum(a[::2]) bob=sum(a[1::2]) print((alice-bob))
11
7
190
128
n = int(eval(input())) a = list(map(int, input().split())) ali = 0 bob = 0 a.sort(reverse=True) for i in range(len(a)): if i % 2 == 0: ali += a[i] else: bob += a[i] print((ali - bob))
n = int(eval(input())) a = list(map(int, input().split())) a.sort(reverse=True) alice = sum(a[::2]) bob = sum(a[1::2]) print((alice - bob))
false
36.363636
[ "-ali = 0", "-bob = 0", "-for i in range(len(a)):", "- if i % 2 == 0:", "- ali += a[i]", "- else:", "- bob += a[i]", "-print((ali - bob))", "+alice = sum(a[::2])", "+bob = sum(a[1::2])", "+print((alice - bob))" ]
false
0.047392
0.047645
0.994686
[ "s436827002", "s236040922" ]
u945181840
p03910
python
s890508247
s246917578
22
19
3,620
3,572
Accepted
Accepted
13.64
from itertools import accumulate from math import sqrt, ceil from bisect import bisect_left N = int(eval(input())) n = list(accumulate(list(range(ceil(sqrt(2 * N)) + 1)))) r = bisect_left(n, N) if n[r] == N: print(('\n'.join(map(str, list(range(1, r + 1)))))) exit() d = n[r] - N for i in range(1, r + 1): if i != d: print(i)
from itertools import accumulate from math import sqrt, ceil from bisect import bisect_left N = int(eval(input())) n = list(accumulate(list(range(ceil(sqrt(2 * N)) + 1)))) r = bisect_left(n, N) answer = list(map(str, list(range(1, r + 1)))) if n[r] != N: d = n[r] - N answer.remove(str(d)) print(('\n'.join(answer)))
17
15
345
322
from itertools import accumulate from math import sqrt, ceil from bisect import bisect_left N = int(eval(input())) n = list(accumulate(list(range(ceil(sqrt(2 * N)) + 1)))) r = bisect_left(n, N) if n[r] == N: print(("\n".join(map(str, list(range(1, r + 1)))))) exit() d = n[r] - N for i in range(1, r + 1): if i != d: print(i)
from itertools import accumulate from math import sqrt, ceil from bisect import bisect_left N = int(eval(input())) n = list(accumulate(list(range(ceil(sqrt(2 * N)) + 1)))) r = bisect_left(n, N) answer = list(map(str, list(range(1, r + 1)))) if n[r] != N: d = n[r] - N answer.remove(str(d)) print(("\n".join(answer)))
false
11.764706
[ "-if n[r] == N:", "- print((\"\\n\".join(map(str, list(range(1, r + 1))))))", "- exit()", "-d = n[r] - N", "-for i in range(1, r + 1):", "- if i != d:", "- print(i)", "+answer = list(map(str, list(range(1, r + 1))))", "+if n[r] != N:", "+ d = n[r] - N", "+ answer.remove(str...
false
0.108382
0.043911
2.468241
[ "s890508247", "s246917578" ]
u114920558
p03062
python
s811576676
s854639306
127
107
14,468
14,412
Accepted
Accepted
15.75
N = int(eval(input())) A = list(map(int, input().split())) cnt = 1 ans = 0 for i in range(N): if(A[i] < 0): cnt = cnt * (-1) elif(A[i] == 0): cnt = cnt * 0 if(cnt >= 0): for i in range(N): ans += abs(A[i]) else: for i in range(N): A[i] = abs(A[i]) A.sort() for i in range(N): ans += A[i] ans -= A[0] * 2 print(ans)
N = int(eval(input())) A = list(map(int, input().split())) cnt = 0 ans = 0 for i in range(N): if(A[i] < 0): cnt += 1 if(cnt % 2 == 0): for i in range(N): ans += abs(A[i]) print(ans) else: minabs = 10**9 for i in range(N): minabs = min(minabs, abs(A[i])) for i in range(N): ans += abs(A[i]) print((ans - 2*minabs))
20
18
362
352
N = int(eval(input())) A = list(map(int, input().split())) cnt = 1 ans = 0 for i in range(N): if A[i] < 0: cnt = cnt * (-1) elif A[i] == 0: cnt = cnt * 0 if cnt >= 0: for i in range(N): ans += abs(A[i]) else: for i in range(N): A[i] = abs(A[i]) A.sort() for i in range(N): ans += A[i] ans -= A[0] * 2 print(ans)
N = int(eval(input())) A = list(map(int, input().split())) cnt = 0 ans = 0 for i in range(N): if A[i] < 0: cnt += 1 if cnt % 2 == 0: for i in range(N): ans += abs(A[i]) print(ans) else: minabs = 10**9 for i in range(N): minabs = min(minabs, abs(A[i])) for i in range(N): ans += abs(A[i]) print((ans - 2 * minabs))
false
10
[ "-cnt = 1", "+cnt = 0", "- cnt = cnt * (-1)", "- elif A[i] == 0:", "- cnt = cnt * 0", "-if cnt >= 0:", "+ cnt += 1", "+if cnt % 2 == 0:", "+ print(ans)", "+ minabs = 10**9", "- A[i] = abs(A[i])", "- A.sort()", "+ minabs = min(minabs, abs(A[i]))"...
false
0.038271
0.037268
1.026917
[ "s811576676", "s854639306" ]
u814265211
p02622
python
s201262567
s591133307
67
45
9,308
9,288
Accepted
Accepted
32.84
S, T = [eval(input()) for _ in range(2)] cnt = 0 for i, c in enumerate(S): if c != T[i]: cnt += 1 print(cnt)
S, T = [eval(input()) for _ in range(2)] print((sum(s != t for s, t in zip(S, T))))
7
2
121
76
S, T = [eval(input()) for _ in range(2)] cnt = 0 for i, c in enumerate(S): if c != T[i]: cnt += 1 print(cnt)
S, T = [eval(input()) for _ in range(2)] print((sum(s != t for s, t in zip(S, T))))
false
71.428571
[ "-cnt = 0", "-for i, c in enumerate(S):", "- if c != T[i]:", "- cnt += 1", "-print(cnt)", "+print((sum(s != t for s, t in zip(S, T))))" ]
false
0.037528
0.063654
0.589565
[ "s201262567", "s591133307" ]
u767797498
p02598
python
s897977956
s279798808
1,067
637
31,084
31,116
Accepted
Accepted
40.3
# -*- coding: utf-8 -*- # template: v1.3.1 # ไธธๅคชใฎๅˆ†ๅ‰ฒๅˆ†ๅ‰ฒๅ•้กŒใ€‚ # ้€Ÿๅบฆใฎ่ฆณ็‚นใ‹ใ‚‰ใ€ใ€Œ็ญ”ใˆใฎไบŒๅˆ†ๆŽข็ดขใ€ใŒๅฟ…่ฆใ€‚ๅ…ธๅž‹ใ‚‰ใ—ใ„ใ€‚ import io import sys import math ### DEBUG ### _DEB = 0 # 1:ON / 0:OFF _INPUT = """\ 2 1 1 50 """ # Worst # _INPUT = f"{str(2*(10**5))} {str(10**9)}\n{(str(10**9)+' ')*(2*(10**5)) }" # _INPUT = f"{str(2*(10**5))} {str(10**9)}\n{(str(10**9)+' ')*(2*(10**5)) }" _EXPECTED = """\ ABC """ if _DEB: sys.stdin = io.StringIO(_INPUT) print("!! Debug Mode !!") def logd(str): if _DEB: print(f"[deb] {str}") # is_m_OK? def f(m): cut=0 for aa in a: c=math.ceil(aa/m) cut+=c-1 if cut > k: return False return True #m=7,a=[7,9] ### INPUT #### n,k = list(map(int, input().split())) a = list(map(int, input().split())) ### Solve #### def solve(): # Process ans=0 l,r=0,10**9 while abs(r-l)!=1: m=(l+r)//2 if f(m): # m is ok: Go left r=m else: # m is ng : Go right l=m ans=r # ans=min(r,max(a)) # OUPUT ans = str(ans) print(ans) return ans ### MAIN ### if __name__ == "__main__": ans = solve() # Checker if _DEB: if _EXPECTED.strip() == ans.strip(): print("\n!! Success !!") else: print(f"\n!! Failed... !!\nANSWER: {ans}\nExpected: {_EXPECTED}")
# -*- coding: utf-8 -*- # template: v1.3.1 # ไธธๅคชใฎๅˆ†ๅ‰ฒๅˆ†ๅ‰ฒๅ•้กŒใ€‚ # ้€Ÿๅบฆใฎ่ฆณ็‚นใ‹ใ‚‰ใ€ใ€Œ็ญ”ใˆใฎไบŒๅˆ†ๆŽข็ดขใ€ใŒๅฟ…่ฆใ€‚ๅ…ธๅž‹ใ‚‰ใ—ใ„ใ€‚ # f(x) ใฎๅ‡ฆ็†ใ€ใ™ใฌใ‘ใ•ใ‚“ใฎใ‚’ใƒใ‚งใƒƒใ‚ฏ import io import sys import math ### DEBUG ### _DEB = 0 # 1:ON / 0:OFF _INPUT = """\ 2 1 1 3 """ # Worst # _INPUT = f"{str(2*(10**5))} {str(10**9)}\n{(str(10**9)+' ')*(2*(10**5)) }" # _INPUT = f"{str(2*(10**5))} {str(10**9)}\n{(str(10**9)+' ')*(2*(10**5)) }" _EXPECTED = """\ ABC """ if _DEB: sys.stdin = io.StringIO(_INPUT) print("!! Debug Mode !!") def logd(str): if _DEB: print(f"[deb] {str}") # is_m_OK? def f(m): cut=0 for aa in a: #ใ“ใ“ใ‚’ๅค‰ใˆใŸ c=(aa-1)//m cut+=c if cut > k: return False return True #m=7,a=[7,9] ### INPUT #### n,k = list(map(int, input().split())) a = list(map(int, input().split())) ### Solve #### def solve(): # Process ans=0 l,r=0,10**9 while abs(r-l)!=1: m=(l+r)//2 if f(m): # m is ok: Go left r=m else: # m is ng : Go right l=m ans=r # ans=min(r,max(a)) # OUPUT ans = str(ans) print(ans) return ans ### MAIN ### if __name__ == "__main__": ans = solve() # Checker if _DEB: if _EXPECTED.strip() == ans.strip(): print("\n!! Success !!") else: print(f"\n!! Failed... !!\nANSWER: {ans}\nExpected: {_EXPECTED}")
81
82
1,394
1,425
# -*- coding: utf-8 -*- # template: v1.3.1 # ไธธๅคชใฎๅˆ†ๅ‰ฒๅˆ†ๅ‰ฒๅ•้กŒใ€‚ # ้€Ÿๅบฆใฎ่ฆณ็‚นใ‹ใ‚‰ใ€ใ€Œ็ญ”ใˆใฎไบŒๅˆ†ๆŽข็ดขใ€ใŒๅฟ…่ฆใ€‚ๅ…ธๅž‹ใ‚‰ใ—ใ„ใ€‚ import io import sys import math ### DEBUG ### _DEB = 0 # 1:ON / 0:OFF _INPUT = """\ 2 1 1 50 """ # Worst # _INPUT = f"{str(2*(10**5))} {str(10**9)}\n{(str(10**9)+' ')*(2*(10**5)) }" # _INPUT = f"{str(2*(10**5))} {str(10**9)}\n{(str(10**9)+' ')*(2*(10**5)) }" _EXPECTED = """\ ABC """ if _DEB: sys.stdin = io.StringIO(_INPUT) print("!! Debug Mode !!") def logd(str): if _DEB: print(f"[deb] {str}") # is_m_OK? def f(m): cut = 0 for aa in a: c = math.ceil(aa / m) cut += c - 1 if cut > k: return False return True # m=7,a=[7,9] ### INPUT #### n, k = list(map(int, input().split())) a = list(map(int, input().split())) ### Solve #### def solve(): # Process ans = 0 l, r = 0, 10**9 while abs(r - l) != 1: m = (l + r) // 2 if f(m): # m is ok: Go left r = m else: # m is ng : Go right l = m ans = r # ans=min(r,max(a)) # OUPUT ans = str(ans) print(ans) return ans ### MAIN ### if __name__ == "__main__": ans = solve() # Checker if _DEB: if _EXPECTED.strip() == ans.strip(): print("\n!! Success !!") else: print(f"\n!! Failed... !!\nANSWER: {ans}\nExpected: {_EXPECTED}")
# -*- coding: utf-8 -*- # template: v1.3.1 # ไธธๅคชใฎๅˆ†ๅ‰ฒๅˆ†ๅ‰ฒๅ•้กŒใ€‚ # ้€Ÿๅบฆใฎ่ฆณ็‚นใ‹ใ‚‰ใ€ใ€Œ็ญ”ใˆใฎไบŒๅˆ†ๆŽข็ดขใ€ใŒๅฟ…่ฆใ€‚ๅ…ธๅž‹ใ‚‰ใ—ใ„ใ€‚ # f(x) ใฎๅ‡ฆ็†ใ€ใ™ใฌใ‘ใ•ใ‚“ใฎใ‚’ใƒใ‚งใƒƒใ‚ฏ import io import sys import math ### DEBUG ### _DEB = 0 # 1:ON / 0:OFF _INPUT = """\ 2 1 1 3 """ # Worst # _INPUT = f"{str(2*(10**5))} {str(10**9)}\n{(str(10**9)+' ')*(2*(10**5)) }" # _INPUT = f"{str(2*(10**5))} {str(10**9)}\n{(str(10**9)+' ')*(2*(10**5)) }" _EXPECTED = """\ ABC """ if _DEB: sys.stdin = io.StringIO(_INPUT) print("!! Debug Mode !!") def logd(str): if _DEB: print(f"[deb] {str}") # is_m_OK? def f(m): cut = 0 for aa in a: # ใ“ใ“ใ‚’ๅค‰ใˆใŸ c = (aa - 1) // m cut += c if cut > k: return False return True # m=7,a=[7,9] ### INPUT #### n, k = list(map(int, input().split())) a = list(map(int, input().split())) ### Solve #### def solve(): # Process ans = 0 l, r = 0, 10**9 while abs(r - l) != 1: m = (l + r) // 2 if f(m): # m is ok: Go left r = m else: # m is ng : Go right l = m ans = r # ans=min(r,max(a)) # OUPUT ans = str(ans) print(ans) return ans ### MAIN ### if __name__ == "__main__": ans = solve() # Checker if _DEB: if _EXPECTED.strip() == ans.strip(): print("\n!! Success !!") else: print(f"\n!! Failed... !!\nANSWER: {ans}\nExpected: {_EXPECTED}")
false
1.219512
[ "+# f(x) ใฎๅ‡ฆ็†ใ€ใ™ใฌใ‘ใ•ใ‚“ใฎใ‚’ใƒใ‚งใƒƒใ‚ฏ", "-1 50", "+1 3", "- c = math.ceil(aa / m)", "- cut += c - 1", "+ # ใ“ใ“ใ‚’ๅค‰ใˆใŸ", "+ c = (aa - 1) // m", "+ cut += c" ]
false
0.037623
0.046634
0.806774
[ "s897977956", "s279798808" ]
u197955752
p02819
python
s982681053
s466344246
55
17
6,132
3,060
Accepted
Accepted
69.09
X = int(eval(input())) n = 2 * X is_prime = [False] * 2 + [True] * (n - 1) for i in range(2, int(n ** 0.5) + 1): # ็ด ๆ•ฐๅ€™่ฃœ if not is_prime[i]: continue for j in range(2 * i, n + 1, i): is_prime[j] = False for i in range(X, n): if is_prime[i]: print(i) break
X = int(eval(input())) p = X while True: for j in range(2, int(p ** 0.5) + 1): if p % j == 0: break else: break p += 1 print(p)
14
11
300
161
X = int(eval(input())) n = 2 * X is_prime = [False] * 2 + [True] * (n - 1) for i in range(2, int(n**0.5) + 1): # ็ด ๆ•ฐๅ€™่ฃœ if not is_prime[i]: continue for j in range(2 * i, n + 1, i): is_prime[j] = False for i in range(X, n): if is_prime[i]: print(i) break
X = int(eval(input())) p = X while True: for j in range(2, int(p**0.5) + 1): if p % j == 0: break else: break p += 1 print(p)
false
21.428571
[ "-n = 2 * X", "-is_prime = [False] * 2 + [True] * (n - 1)", "-for i in range(2, int(n**0.5) + 1): # ็ด ๆ•ฐๅ€™่ฃœ", "- if not is_prime[i]:", "- continue", "- for j in range(2 * i, n + 1, i):", "- is_prime[j] = False", "-for i in range(X, n):", "- if is_prime[i]:", "- print(i)...
false
0.080328
0.039365
2.040576
[ "s982681053", "s466344246" ]
u794544096
p02676
python
s167258306
s612428437
64
59
61,760
61,596
Accepted
Accepted
7.81
K = int(eval(input())) S = eval(input()) if len(S) <= K: print(S) elif len(S) >= K: print((S[:K] + '...'))
k = int(eval(input())) s = eval(input()) if len(s) <= k: print(s) else: print((s[:k] + '...'))
8
7
113
95
K = int(eval(input())) S = eval(input()) if len(S) <= K: print(S) elif len(S) >= K: print((S[:K] + "..."))
k = int(eval(input())) s = eval(input()) if len(s) <= k: print(s) else: print((s[:k] + "..."))
false
12.5
[ "-K = int(eval(input()))", "-S = eval(input())", "-if len(S) <= K:", "- print(S)", "-elif len(S) >= K:", "- print((S[:K] + \"...\"))", "+k = int(eval(input()))", "+s = eval(input())", "+if len(s) <= k:", "+ print(s)", "+else:", "+ print((s[:k] + \"...\"))" ]
false
0.047686
0.047643
1.000894
[ "s167258306", "s612428437" ]
u945418216
p03331
python
s751534990
s271815189
204
17
3,464
2,940
Accepted
Accepted
91.67
n = int(eval(input())) def digitsum(x): array = list(map(int, list(str(x)))) return sum(array) dsum = [digitsum(a)+digitsum(n-a) for a in range(1,int(n/2)+1)] print((min(dsum)))
# n = int(input()) # def digitsum(x): # array = list(map(int, list(str(x)))) # return sum(array) # dsum = [digitsum(a)+digitsum(n-a) for a in range(1,int(n/2)+1)] # print(min(dsum)) NL = list(map(int, list(eval(input())))) if NL[0] == 1 and sum(NL) == 1: print((10)) else: print((sum(NL)))
7
13
184
310
n = int(eval(input())) def digitsum(x): array = list(map(int, list(str(x)))) return sum(array) dsum = [digitsum(a) + digitsum(n - a) for a in range(1, int(n / 2) + 1)] print((min(dsum)))
# n = int(input()) # def digitsum(x): # array = list(map(int, list(str(x)))) # return sum(array) # dsum = [digitsum(a)+digitsum(n-a) for a in range(1,int(n/2)+1)] # print(min(dsum)) NL = list(map(int, list(eval(input())))) if NL[0] == 1 and sum(NL) == 1: print((10)) else: print((sum(NL)))
false
46.153846
[ "-n = int(eval(input()))", "-", "-", "-def digitsum(x):", "- array = list(map(int, list(str(x))))", "- return sum(array)", "-", "-", "-dsum = [digitsum(a) + digitsum(n - a) for a in range(1, int(n / 2) + 1)]", "-print((min(dsum)))", "+# n = int(input())", "+# def digitsum(x):", "+# ...
false
0.11918
0.042677
2.792612
[ "s751534990", "s271815189" ]
u877428733
p02712
python
s356013481
s829462423
169
112
30,112
30,020
Accepted
Accepted
33.73
N = int(eval(input())) l = [] for i in range(N+1): if not i % 3 == 0 and not i % 5 == 0: l.append(i) print((sum(l)))
N = int(eval(input())) l = [i for i in range(N+1) if not i % 3 == 0 and not i % 5 == 0] print((sum(l)))
7
3
127
98
N = int(eval(input())) l = [] for i in range(N + 1): if not i % 3 == 0 and not i % 5 == 0: l.append(i) print((sum(l)))
N = int(eval(input())) l = [i for i in range(N + 1) if not i % 3 == 0 and not i % 5 == 0] print((sum(l)))
false
57.142857
[ "-l = []", "-for i in range(N + 1):", "- if not i % 3 == 0 and not i % 5 == 0:", "- l.append(i)", "+l = [i for i in range(N + 1) if not i % 3 == 0 and not i % 5 == 0]" ]
false
0.507209
0.269989
1.878626
[ "s356013481", "s829462423" ]
u133936772
p02630
python
s320966841
s943160420
584
531
23,960
21,640
Accepted
Accepted
9.08
f=lambda:[*list(map(int,input().split()))] f(); l,q=f(),f()[0] from collections import * C,s=Counter(l),sum(l) for _ in range(q): b,c=f(); s+=(c-b)*C[b]; C[c]+=C[b]; C[b]=0; print(s)
f=lambda:[*list(map(int,input().split()))] f() s,*l=[0]*100002 for i in f(): s+=i; l[i]+=1 q=f()[0] for _ in range(q): b,c=f(); s+=(c-b)*l[b]; l[c]+=l[b]; l[b]=0; print(s)
5
6
180
170
f = lambda: [*list(map(int, input().split()))] f() l, q = f(), f()[0] from collections import * C, s = Counter(l), sum(l) for _ in range(q): b, c = f() s += (c - b) * C[b] C[c] += C[b] C[b] = 0 print(s)
f = lambda: [*list(map(int, input().split()))] f() s, *l = [0] * 100002 for i in f(): s += i l[i] += 1 q = f()[0] for _ in range(q): b, c = f() s += (c - b) * l[b] l[c] += l[b] l[b] = 0 print(s)
false
16.666667
[ "-l, q = f(), f()[0]", "-from collections import *", "-", "-C, s = Counter(l), sum(l)", "+s, *l = [0] * 100002", "+for i in f():", "+ s += i", "+ l[i] += 1", "+q = f()[0]", "- s += (c - b) * C[b]", "- C[c] += C[b]", "- C[b] = 0", "+ s += (c - b) * l[b]", "+ l[c] += l[b...
false
0.048854
0.091857
0.531845
[ "s320966841", "s943160420" ]
u493520238
p03329
python
s549091822
s755240574
637
570
3,828
3,828
Accepted
Accepted
10.52
n = int(eval(input())) dp = [200000] * (n+10) dp[0] = 0 # dp[1] = 1 for i in range(n): dp[i+1] = min(dp[i+1], dp[i]+1) six = 6 while i + six <= n: dp[i+six] = min(dp[i+six], dp[i]+1) six *= 6 nine = 9 while i + nine <= n: dp[i+nine] = min(dp[i+nine], dp[i]+1) nine *= 9 print((dp[n]))
n = int(eval(input())) dp = [200000] * (n+10) dp[0] = 0 for i in range(1,n+1): dp[i] = min(dp[i-1]+1, dp[i]) six = 6 while i - six >= 0: dp[i] = min(dp[i-six]+1, dp[i]) six *= 6 nine = 9 while i - nine >= 0: dp[i] = min(dp[i-nine]+1, dp[i]) nine *= 9 print((dp[n]))
17
17
347
333
n = int(eval(input())) dp = [200000] * (n + 10) dp[0] = 0 # dp[1] = 1 for i in range(n): dp[i + 1] = min(dp[i + 1], dp[i] + 1) six = 6 while i + six <= n: dp[i + six] = min(dp[i + six], dp[i] + 1) six *= 6 nine = 9 while i + nine <= n: dp[i + nine] = min(dp[i + nine], dp[i] + 1) nine *= 9 print((dp[n]))
n = int(eval(input())) dp = [200000] * (n + 10) dp[0] = 0 for i in range(1, n + 1): dp[i] = min(dp[i - 1] + 1, dp[i]) six = 6 while i - six >= 0: dp[i] = min(dp[i - six] + 1, dp[i]) six *= 6 nine = 9 while i - nine >= 0: dp[i] = min(dp[i - nine] + 1, dp[i]) nine *= 9 print((dp[n]))
false
0
[ "-# dp[1] = 1", "-for i in range(n):", "- dp[i + 1] = min(dp[i + 1], dp[i] + 1)", "+for i in range(1, n + 1):", "+ dp[i] = min(dp[i - 1] + 1, dp[i])", "- while i + six <= n:", "- dp[i + six] = min(dp[i + six], dp[i] + 1)", "+ while i - six >= 0:", "+ dp[i] = min(dp[i - six]...
false
0.29859
0.268046
1.113951
[ "s549091822", "s755240574" ]
u949338836
p02407
python
s320637505
s044193985
40
30
6,724
6,724
Accepted
Accepted
25
#coding:utf-8 #1_6_A 2015.4.1 n = int(input()) numbers = list(map(int,input().split())) for i in range(n): if i == n - 1: print(numbers[-i-1]) else: print(numbers[-i-1], end = ' ')
#coding:utf-8 #1_6_A 2015.4.1 eval(input()) numbers = input().split() numbers.reverse() print((' '.join(numbers)))
10
6
214
111
# coding:utf-8 # 1_6_A 2015.4.1 n = int(input()) numbers = list(map(int, input().split())) for i in range(n): if i == n - 1: print(numbers[-i - 1]) else: print(numbers[-i - 1], end=" ")
# coding:utf-8 # 1_6_A 2015.4.1 eval(input()) numbers = input().split() numbers.reverse() print((" ".join(numbers)))
false
40
[ "-n = int(input())", "-numbers = list(map(int, input().split()))", "-for i in range(n):", "- if i == n - 1:", "- print(numbers[-i - 1])", "- else:", "- print(numbers[-i - 1], end=\" \")", "+eval(input())", "+numbers = input().split()", "+numbers.reverse()", "+print((\" \".joi...
false
0.036326
0.039026
0.930821
[ "s320637505", "s044193985" ]
u833492079
p03651
python
s085399947
s022009256
131
86
16,276
16,280
Accepted
Accepted
34.35
import sys from fractions import gcd PO = "POSSIBLE" IM = "IMPOSSIBLE" ans = "" N, K = list(map(int, input().split())) # 5 7 a = sorted(list(map(int, input().split()))) # 1 2 3 4 5 ... if max(a)<K: print(IM) sys.exit() if K in a: print(PO) sys.exit() g=a[0] for i in range(1,N): g = gcd(g,a[i]) if K%g==0: ans=PO else: ans=IM print(ans)
import sys from fractions import gcd PO = "POSSIBLE" IM = "IMPOSSIBLE" ans = "" N, K = list(map(int, input().split())) # 5 7 a = list(map(int, input().split())) # 1 2 3 4 5 ... if max(a)<K: print(IM) sys.exit() if K in a: print(PO) sys.exit() g=a[0] for i in range(1,N): g = gcd(g,a[i]) if K%g==0: ans=PO break else: ans=IM print(ans)
30
29
377
376
import sys from fractions import gcd PO = "POSSIBLE" IM = "IMPOSSIBLE" ans = "" N, K = list(map(int, input().split())) # 5 7 a = sorted(list(map(int, input().split()))) # 1 2 3 4 5 ... if max(a) < K: print(IM) sys.exit() if K in a: print(PO) sys.exit() g = a[0] for i in range(1, N): g = gcd(g, a[i]) if K % g == 0: ans = PO else: ans = IM print(ans)
import sys from fractions import gcd PO = "POSSIBLE" IM = "IMPOSSIBLE" ans = "" N, K = list(map(int, input().split())) # 5 7 a = list(map(int, input().split())) # 1 2 3 4 5 ... if max(a) < K: print(IM) sys.exit() if K in a: print(PO) sys.exit() g = a[0] for i in range(1, N): g = gcd(g, a[i]) if K % g == 0: ans = PO break else: ans = IM print(ans)
false
3.333333
[ "-a = sorted(list(map(int, input().split()))) # 1 2 3 4 5 ...", "+a = list(map(int, input().split())) # 1 2 3 4 5 ...", "-if K % g == 0:", "- ans = PO", "+ if K % g == 0:", "+ ans = PO", "+ break" ]
false
0.052975
0.046884
1.129923
[ "s085399947", "s022009256" ]
u075595666
p02757
python
s436936654
s710767894
481
298
12,944
41,196
Accepted
Accepted
38.05
def main(): import sys input = sys.stdin.readline n,p = [int(i) for i in input().split()] s = eval(input()) ans = 0 import collections if p == 2 or p == 5: for i in range(n): if int(s[i]) % p == 0: ans += i + 1 print(ans) exit() else: chk = [] m = 0 chk = collections.deque(chk) for i in range(n)[::-1]: m = (int(s[i])*pow(10,n-1-i,p)+m)%p chk.append(m) chk.append(0) chk = list(chk) c = collections.Counter(chk) for i in range(p): ans += c[i]*(c[i]-1)/2 print((int(ans))) if __name__ == '__main__': main()
import sys input = sys.stdin.readline n,p = [int(i) for i in input().split()] s = eval(input()) ans = 0 if p == 2 or p == 5: for i in range(n): if int(s[i]) % p == 0: ans += i + 1 print(ans) exit() else: chk = [0]*p chk[0] = 1 m = 0 for i in range(n)[::-1]: m = (int(s[i])*pow(10,n-1-i,p)+m)%p chk[m] += 1 chk= [i*(i-1)/2 for i in chk] print((int(sum(chk))))
30
22
649
430
def main(): import sys input = sys.stdin.readline n, p = [int(i) for i in input().split()] s = eval(input()) ans = 0 import collections if p == 2 or p == 5: for i in range(n): if int(s[i]) % p == 0: ans += i + 1 print(ans) exit() else: chk = [] m = 0 chk = collections.deque(chk) for i in range(n)[::-1]: m = (int(s[i]) * pow(10, n - 1 - i, p) + m) % p chk.append(m) chk.append(0) chk = list(chk) c = collections.Counter(chk) for i in range(p): ans += c[i] * (c[i] - 1) / 2 print((int(ans))) if __name__ == "__main__": main()
import sys input = sys.stdin.readline n, p = [int(i) for i in input().split()] s = eval(input()) ans = 0 if p == 2 or p == 5: for i in range(n): if int(s[i]) % p == 0: ans += i + 1 print(ans) exit() else: chk = [0] * p chk[0] = 1 m = 0 for i in range(n)[::-1]: m = (int(s[i]) * pow(10, n - 1 - i, p) + m) % p chk[m] += 1 chk = [i * (i - 1) / 2 for i in chk] print((int(sum(chk))))
false
26.666667
[ "-def main():", "- import sys", "+import sys", "- input = sys.stdin.readline", "- n, p = [int(i) for i in input().split()]", "- s = eval(input())", "- ans = 0", "- import collections", "-", "- if p == 2 or p == 5:", "- for i in range(n):", "- if int(s[i])...
false
0.077972
0.039894
1.954479
[ "s436936654", "s710767894" ]
u685263709
p03283
python
s645049594
s425788192
2,804
1,623
56,072
15,332
Accepted
Accepted
42.12
N, M, Q = list(map(int, input().split())) coordinate = [[0 for _ in range(N+1)] for i in range(N+1)] for m in range(M): l, r = list(map(int, input().split())) coordinate[l-1][r-1] += 1 for i in range(N): for j in range(1, N): coordinate[i][j] += coordinate[i][j-1] for i in range(Q): p, q = list(map(int, input().split())) ans = 0 for i in range(p-1, q): ans += coordinate[i][q-1] - coordinate[i][p-2] print(ans)
N, M, Q = list(map(int, input().split())) coordinate = [[0] * N for _ in range(N)] for _ in range(M): l, r = list(map(int, input().split())) l, r = l - 1, r - 1 coordinate[l][r] += 1 acc = [[0] * (N + 1) for _ in range(N + 1)] for i in range(N): for j in range(N): acc[i + 1][j + 1] = acc[i][j + 1] + acc[i + 1][j] - acc[i][j] + coordinate[i][j] for _ in range(Q): p, q = list(map(int, input().split())) p, q = p - 1, q - 1 ans = acc[N][q + 1] - acc[p][q + 1] print(ans)
17
18
457
512
N, M, Q = list(map(int, input().split())) coordinate = [[0 for _ in range(N + 1)] for i in range(N + 1)] for m in range(M): l, r = list(map(int, input().split())) coordinate[l - 1][r - 1] += 1 for i in range(N): for j in range(1, N): coordinate[i][j] += coordinate[i][j - 1] for i in range(Q): p, q = list(map(int, input().split())) ans = 0 for i in range(p - 1, q): ans += coordinate[i][q - 1] - coordinate[i][p - 2] print(ans)
N, M, Q = list(map(int, input().split())) coordinate = [[0] * N for _ in range(N)] for _ in range(M): l, r = list(map(int, input().split())) l, r = l - 1, r - 1 coordinate[l][r] += 1 acc = [[0] * (N + 1) for _ in range(N + 1)] for i in range(N): for j in range(N): acc[i + 1][j + 1] = acc[i][j + 1] + acc[i + 1][j] - acc[i][j] + coordinate[i][j] for _ in range(Q): p, q = list(map(int, input().split())) p, q = p - 1, q - 1 ans = acc[N][q + 1] - acc[p][q + 1] print(ans)
false
5.555556
[ "-coordinate = [[0 for _ in range(N + 1)] for i in range(N + 1)]", "-for m in range(M):", "+coordinate = [[0] * N for _ in range(N)]", "+for _ in range(M):", "- coordinate[l - 1][r - 1] += 1", "+ l, r = l - 1, r - 1", "+ coordinate[l][r] += 1", "+acc = [[0] * (N + 1) for _ in range(N + 1)]", ...
false
0.059885
0.036053
1.661022
[ "s645049594", "s425788192" ]
u759934006
p00102
python
s143713241
s265523104
30
20
4,256
4,252
Accepted
Accepted
33.33
while True: n = int(input()) if n == 0: break a = [[] for i in range(n + 1)] for i in range(n + 1): if i < n: a[i] = list(map(int, input().split())) a[i].append(sum(a[i])) else: a[i] = [sum([a[j][k] for j in range(n)]) for k in range(n + 1)] s = "" for i in range(n + 1): for j in range(n + 1): s += "{0:5d}".format(a[i][j]) s += "\n" print(s, end=' ')
while True: n = int(input()) if n == 0: break a = [[] for i in range(n + 1)] for i in range(n + 1): if i < n: a[i] = list(map(int, input().split())) a[i].append(sum(a[i])) else: a[i] = [sum([a[j][k] for j in range(n)]) for k in range(n + 1)] s = "" for i in range(n + 1): s += "".join([str(x).rjust(5, " ") for x in a[i]]) + "\n" print(s, end=' ')
20
17
483
459
while True: n = int(input()) if n == 0: break a = [[] for i in range(n + 1)] for i in range(n + 1): if i < n: a[i] = list(map(int, input().split())) a[i].append(sum(a[i])) else: a[i] = [sum([a[j][k] for j in range(n)]) for k in range(n + 1)] s = "" for i in range(n + 1): for j in range(n + 1): s += "{0:5d}".format(a[i][j]) s += "\n" print(s, end=" ")
while True: n = int(input()) if n == 0: break a = [[] for i in range(n + 1)] for i in range(n + 1): if i < n: a[i] = list(map(int, input().split())) a[i].append(sum(a[i])) else: a[i] = [sum([a[j][k] for j in range(n)]) for k in range(n + 1)] s = "" for i in range(n + 1): s += "".join([str(x).rjust(5, " ") for x in a[i]]) + "\n" print(s, end=" ")
false
15
[ "- for j in range(n + 1):", "- s += \"{0:5d}\".format(a[i][j])", "- s += \"\\n\"", "+ s += \"\".join([str(x).rjust(5, \" \") for x in a[i]]) + \"\\n\"" ]
false
0.036919
0.035899
1.028397
[ "s143713241", "s265523104" ]
u885634168
p02629
python
s755724746
s988433660
73
61
61,848
61,540
Accepted
Accepted
16.44
N = int(eval(input())) d = "abcdefghijklmnopqrstuvwxyz" ans = "" N -= 1 while(N >= 0): ans += d[N % 26] N //= 26 N -= 1 print((ans[::-1]))
def num2alpha(num): if num <= 26: return chr(64 + num) elif num % 26 == 0: return num2alpha(num // 26 - 1) + chr(90) return num2alpha(num // 26) + chr(64 + num % 26) N = int(eval(input())) ans = num2alpha(N).lower() print(ans)
11
8
158
242
N = int(eval(input())) d = "abcdefghijklmnopqrstuvwxyz" ans = "" N -= 1 while N >= 0: ans += d[N % 26] N //= 26 N -= 1 print((ans[::-1]))
def num2alpha(num): if num <= 26: return chr(64 + num) elif num % 26 == 0: return num2alpha(num // 26 - 1) + chr(90) return num2alpha(num // 26) + chr(64 + num % 26) N = int(eval(input())) ans = num2alpha(N).lower() print(ans)
false
27.272727
[ "+def num2alpha(num):", "+ if num <= 26:", "+ return chr(64 + num)", "+ elif num % 26 == 0:", "+ return num2alpha(num // 26 - 1) + chr(90)", "+ return num2alpha(num // 26) + chr(64 + num % 26)", "+", "+", "-d = \"abcdefghijklmnopqrstuvwxyz\"", "-ans = \"\"", "-N -= 1", "...
false
0.063667
0.037339
1.705113
[ "s755724746", "s988433660" ]
u445624660
p03088
python
s920695048
s799536282
117
40
4,596
10,132
Accepted
Accepted
65.81
# ใกใƒผใจใ‚‚ใ‚ใ‹ใ‚‰ใ‚“ใฎใง่งฃ่ชฌ่ฆ‹ใŸ # ใ‚‰ใ€ๆ‚”ใ—ใ•ใ‚ใตใ‚Œใ‚‹ๆ„Ÿใ˜ # NGใซใชใ‚‹ๆ–‡ๅญ—ใฎไธฆใณใฏ้™ๅฎšใ•ใ‚Œใ‚‹ใ€‚3ๆ–‡ๅญ—ใฎใ‚‚ใฎใฏ"ACG" "GAC", 4ๆ–‡ๅญ—ใฎใ‚‚ใฎใฏ"AxGC", "AGxC" # ใ“ใ“ใง, "AAGC"ใจใ‹"AGCC"ใชใ‚“ใฆใฎใ‚’่€ƒใˆๅ‡บใ™ใจใ€Œใ™ใงใซ"AGC"ใŒๅซใพใ‚Œใจใ‚‹ใ‚„ใ‚“ใ‘ใ€->๏ผˆใ ใ‹ใ‚‰ไฝ•๏ผŸ๏ผ‰ใฟใŸใ„ใชใ‚ˆใใ‚ใ‹ใ‚‰ใ‚“ๆ€่€ƒใซ้™ฅใฃใฆใ—ใพใฃใŸ # ๏ผˆใ„ใพใฟใฆใ‚‹ใฎใจใใ‚Œไปฅๅ‰ใฎ3ใคใ‚’ไฟๅญ˜ใ—ใฆๆŽข็ดขใ™ใ‚‹ใจ็ตๅฑ€ใ‹ใถใ‚‰ใšๅ…จๆŽข็ดขใงใใ‚‹ใฎใง่€ƒใˆใชใใฆใ„ใ„๏ผ‰ # n = input() # ใชใ‚“ใง๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ # ใ“ใ‚ŒใŒ็„ก้™ใƒซใƒผใƒ—ใซใชใ‚‹ใฎ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ # ใฏ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ # def f(i, s): # if i == n: # return 1 # # print("now s : {}".format(s)) # ret = 0 # for c in "ACGT": # print(s + c) # is_include = True if "AGC" in s + c else False # if is_include: # continue # ret += f(i + 1, s[1:] + c) # return ret # print(f(0, "xxx")) # coding: utf-8 # Your code here! n = int(eval(input())) memo = {} def f(i, s): if (i, s) in memo: return memo[(i, s)] if i == n: return 1 ret = 0 for c in "AGCT": flag = False for j in range(4): t = list(s + c) if j >= 1: t[j], t[j - 1] = t[j - 1], t[j] if "AGC" in "".join(t): flag = True if not flag: ret += f(i + 1, s[1:] + c) ret %= 10 ** 9 + 7 memo[(i, s)] = ret return ret print((f(0, "TTT")))
# 2ๅ›žๅ‰ใพใงใฎใ‚’ไฟๅญ˜ใ—ใฆใŠใๅ…จๆŽข็ดข๏ผŸ # -> ATGC ACGC AGGC ใฎๅ ดๅˆใ‚‚ๆกไปถใ‚’ๆบ€ใŸใ—ใฆใ—ใพใ†ใฎใงใ€3ใคๅ‰ใพใงใ‹ใ‚‚๏ผˆๆฐ—ใฅใใฎใซ้•ทๆ™‚้–“ใ‹ใ‹ใฃใŸ๏ผ‰ # -> AGxCใฎๅ ดๅˆใ‚‚ๆฐ—ใฅใ‹ใชใ‹ใฃใŸ... # ใชใœใ‹ใ‚ตใƒณใƒ—ใƒซ3ใŒๅˆใ‚ใชใ„ใŒใ‚ณใƒผใƒ‰ใŒ้–“้•ใฃใฆใ‚‹ใ‚ใ‘ใชใ„ใฎใง่กจ่จ˜ใƒŸใ‚นใจๅˆคๆ–ญใ—ใฆๆๅ‡บ๏ผˆๅ‚ฒๆ…ข # -> MODใ—ใฆใชใ„ใ ใ‘ใ ใฃใŸ... n = int(eval(input())) if n == 3: print((61)) exit() memo = {} MOD = 10**9 + 7 def rec(i, pre3, pre2, pre1): if pre3 == "A" and pre2 == "G" and pre1 == "C": return 0 if pre3 == "G" and pre2 == "A" and pre1 == "C": return 0 if pre3 == "A" and pre2 == "C" and pre1 == "G": return 0 if (i, pre1, pre2, pre3) in memo: return memo[(i, pre1, pre2, pre3)] if i == n - 3: return 1 else: ret = 0 if (pre1 == "G" and pre2 == "A") or (pre1 == "A" and pre2 == "G"): ret = rec(i + 1, pre2, pre1, "A") % MOD + rec( i + 1, pre2, pre1, "G") % MOD + rec(i + 1, pre2, pre1, "T") % MOD elif pre1 == "C" and pre2 == "A": ret = rec(i + 1, pre2, pre1, "C") % MOD + rec( i + 1, pre2, pre1, "A") % MOD + rec(i + 1, pre2, pre1, "T") % MOD elif pre3 == "A" and pre1 == "G": ret = rec(i + 1, pre2, pre1, "A") % MOD + rec( i + 1, pre2, pre1, "G") % MOD + rec(i + 1, pre2, pre1, "T") % MOD elif pre3 == "A" and pre2 == "G": ret = rec(i + 1, pre2, pre1, "A") % MOD + rec( i + 1, pre2, pre1, "G") % MOD + rec(i + 1, pre2, pre1, "T") % MOD else: ret = rec(i + 1, pre2, pre1, "A") + rec(i + 1, pre2, pre1, "G") % MOD + rec( i + 1, pre2, pre1, "C") % MOD + rec( i + 1, pre2, pre1, "T") % MOD ret %= MOD memo[(i, pre1, pre2, pre3)] = ret return ret # ๆœ€ๅˆใจใ‚Šใ†ใ‚‹ใ‚„ใค๏ผˆใ‚ใ‚“ใฉใ„๏ผ‰ ans = 0 for i in ["A", "G", "C", "T"]: for j in ["A", "G", "C", "T"]: for k in ["A", "G", "C", "T"]: ans += rec(0, i, j, k) print((ans % MOD))
53
63
1,252
2,182
# ใกใƒผใจใ‚‚ใ‚ใ‹ใ‚‰ใ‚“ใฎใง่งฃ่ชฌ่ฆ‹ใŸ # ใ‚‰ใ€ๆ‚”ใ—ใ•ใ‚ใตใ‚Œใ‚‹ๆ„Ÿใ˜ # NGใซใชใ‚‹ๆ–‡ๅญ—ใฎไธฆใณใฏ้™ๅฎšใ•ใ‚Œใ‚‹ใ€‚3ๆ–‡ๅญ—ใฎใ‚‚ใฎใฏ"ACG" "GAC", 4ๆ–‡ๅญ—ใฎใ‚‚ใฎใฏ"AxGC", "AGxC" # ใ“ใ“ใง, "AAGC"ใจใ‹"AGCC"ใชใ‚“ใฆใฎใ‚’่€ƒใˆๅ‡บใ™ใจใ€Œใ™ใงใซ"AGC"ใŒๅซใพใ‚Œใจใ‚‹ใ‚„ใ‚“ใ‘ใ€->๏ผˆใ ใ‹ใ‚‰ไฝ•๏ผŸ๏ผ‰ใฟใŸใ„ใชใ‚ˆใใ‚ใ‹ใ‚‰ใ‚“ๆ€่€ƒใซ้™ฅใฃใฆใ—ใพใฃใŸ # ๏ผˆใ„ใพใฟใฆใ‚‹ใฎใจใใ‚Œไปฅๅ‰ใฎ3ใคใ‚’ไฟๅญ˜ใ—ใฆๆŽข็ดขใ™ใ‚‹ใจ็ตๅฑ€ใ‹ใถใ‚‰ใšๅ…จๆŽข็ดขใงใใ‚‹ใฎใง่€ƒใˆใชใใฆใ„ใ„๏ผ‰ # n = input() # ใชใ‚“ใง๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ # ใ“ใ‚ŒใŒ็„ก้™ใƒซใƒผใƒ—ใซใชใ‚‹ใฎ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ # ใฏ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ # def f(i, s): # if i == n: # return 1 # # print("now s : {}".format(s)) # ret = 0 # for c in "ACGT": # print(s + c) # is_include = True if "AGC" in s + c else False # if is_include: # continue # ret += f(i + 1, s[1:] + c) # return ret # print(f(0, "xxx")) # coding: utf-8 # Your code here! n = int(eval(input())) memo = {} def f(i, s): if (i, s) in memo: return memo[(i, s)] if i == n: return 1 ret = 0 for c in "AGCT": flag = False for j in range(4): t = list(s + c) if j >= 1: t[j], t[j - 1] = t[j - 1], t[j] if "AGC" in "".join(t): flag = True if not flag: ret += f(i + 1, s[1:] + c) ret %= 10**9 + 7 memo[(i, s)] = ret return ret print((f(0, "TTT")))
# 2ๅ›žๅ‰ใพใงใฎใ‚’ไฟๅญ˜ใ—ใฆใŠใๅ…จๆŽข็ดข๏ผŸ # -> ATGC ACGC AGGC ใฎๅ ดๅˆใ‚‚ๆกไปถใ‚’ๆบ€ใŸใ—ใฆใ—ใพใ†ใฎใงใ€3ใคๅ‰ใพใงใ‹ใ‚‚๏ผˆๆฐ—ใฅใใฎใซ้•ทๆ™‚้–“ใ‹ใ‹ใฃใŸ๏ผ‰ # -> AGxCใฎๅ ดๅˆใ‚‚ๆฐ—ใฅใ‹ใชใ‹ใฃใŸ... # ใชใœใ‹ใ‚ตใƒณใƒ—ใƒซ3ใŒๅˆใ‚ใชใ„ใŒใ‚ณใƒผใƒ‰ใŒ้–“้•ใฃใฆใ‚‹ใ‚ใ‘ใชใ„ใฎใง่กจ่จ˜ใƒŸใ‚นใจๅˆคๆ–ญใ—ใฆๆๅ‡บ๏ผˆๅ‚ฒๆ…ข # -> MODใ—ใฆใชใ„ใ ใ‘ใ ใฃใŸ... n = int(eval(input())) if n == 3: print((61)) exit() memo = {} MOD = 10**9 + 7 def rec(i, pre3, pre2, pre1): if pre3 == "A" and pre2 == "G" and pre1 == "C": return 0 if pre3 == "G" and pre2 == "A" and pre1 == "C": return 0 if pre3 == "A" and pre2 == "C" and pre1 == "G": return 0 if (i, pre1, pre2, pre3) in memo: return memo[(i, pre1, pre2, pre3)] if i == n - 3: return 1 else: ret = 0 if (pre1 == "G" and pre2 == "A") or (pre1 == "A" and pre2 == "G"): ret = ( rec(i + 1, pre2, pre1, "A") % MOD + rec(i + 1, pre2, pre1, "G") % MOD + rec(i + 1, pre2, pre1, "T") % MOD ) elif pre1 == "C" and pre2 == "A": ret = ( rec(i + 1, pre2, pre1, "C") % MOD + rec(i + 1, pre2, pre1, "A") % MOD + rec(i + 1, pre2, pre1, "T") % MOD ) elif pre3 == "A" and pre1 == "G": ret = ( rec(i + 1, pre2, pre1, "A") % MOD + rec(i + 1, pre2, pre1, "G") % MOD + rec(i + 1, pre2, pre1, "T") % MOD ) elif pre3 == "A" and pre2 == "G": ret = ( rec(i + 1, pre2, pre1, "A") % MOD + rec(i + 1, pre2, pre1, "G") % MOD + rec(i + 1, pre2, pre1, "T") % MOD ) else: ret = ( rec(i + 1, pre2, pre1, "A") + rec(i + 1, pre2, pre1, "G") % MOD + rec(i + 1, pre2, pre1, "C") % MOD + rec(i + 1, pre2, pre1, "T") % MOD ) ret %= MOD memo[(i, pre1, pre2, pre3)] = ret return ret # ๆœ€ๅˆใจใ‚Šใ†ใ‚‹ใ‚„ใค๏ผˆใ‚ใ‚“ใฉใ„๏ผ‰ ans = 0 for i in ["A", "G", "C", "T"]: for j in ["A", "G", "C", "T"]: for k in ["A", "G", "C", "T"]: ans += rec(0, i, j, k) print((ans % MOD))
false
15.873016
[ "-# ใกใƒผใจใ‚‚ใ‚ใ‹ใ‚‰ใ‚“ใฎใง่งฃ่ชฌ่ฆ‹ใŸ", "-# ใ‚‰ใ€ๆ‚”ใ—ใ•ใ‚ใตใ‚Œใ‚‹ๆ„Ÿใ˜", "-# NGใซใชใ‚‹ๆ–‡ๅญ—ใฎไธฆใณใฏ้™ๅฎšใ•ใ‚Œใ‚‹ใ€‚3ๆ–‡ๅญ—ใฎใ‚‚ใฎใฏ\"ACG\" \"GAC\", 4ๆ–‡ๅญ—ใฎใ‚‚ใฎใฏ\"AxGC\", \"AGxC\"", "-# ใ“ใ“ใง, \"AAGC\"ใจใ‹\"AGCC\"ใชใ‚“ใฆใฎใ‚’่€ƒใˆๅ‡บใ™ใจใ€Œใ™ใงใซ\"AGC\"ใŒๅซใพใ‚Œใจใ‚‹ใ‚„ใ‚“ใ‘ใ€->๏ผˆใ ใ‹ใ‚‰ไฝ•๏ผŸ๏ผ‰ใฟใŸใ„ใชใ‚ˆใใ‚ใ‹ใ‚‰ใ‚“ๆ€่€ƒใซ้™ฅใฃใฆใ—ใพใฃใŸ", "-# ๏ผˆใ„ใพใฟใฆใ‚‹ใฎใจใใ‚Œไปฅๅ‰ใฎ3ใคใ‚’ไฟๅญ˜ใ—ใฆๆŽข็ดขใ™ใ‚‹ใจ็ตๅฑ€ใ‹ใถใ‚‰ใšๅ…จๆŽข็ดขใงใใ‚‹ใฎใง่€ƒใˆใชใใฆใ„ใ„๏ผ‰", "-# n = input()", "-# ใชใ‚“ใง๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ๏ผŸ", "-# ใ“ใ‚ŒใŒ...
false
0.171854
0.044997
3.819194
[ "s920695048", "s799536282" ]
u225388820
p03165
python
s339108759
s919600096
531
288
119,772
62,236
Accepted
Accepted
45.76
s=eval(input()) t=eval(input()) n=len(s) m=len(t) dp=[[0 for i in range(m+1)] for j in range(n+1)] for i in range(n): for j in range(m): if s[i]==t[j]: dp[i+1][j+1]=dp[i][j]+1 else: dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]) ans = '' while(dp[n][m]>0): if dp[n][m] == dp[n-1][m-1] +1 and dp[n][m] == dp[n-1][m] +1 and dp[n][m] == dp[n][m-1] +1: ans = ''.join([s[n-1],ans]) n -= 1 m -= 1 elif dp[n-1][m] > dp[n][m-1]: n -= 1 else: m -= 1 print(ans)
import numpy as np def longest_common_subsequence(S, T): """compute table dp satisfying: dp[i,j] = LCS(S[:i], T[:j])""" LS, LT = len(S), len(T) dp = np.zeros((LS + 1, LT + 1), np.int32) for n in range(1, LS + 1): dp[n, 1:] = dp[n - 1, :-1] + (S[n - 1] == T) # ๅทฆไธŠใ‹ใ‚‰ np.maximum(dp[n], dp[n - 1], out=dp[n]) # ไธŠใ‹ใ‚‰ np.maximum.accumulate(dp[n], out=dp[n]) # ๅทฆใ‹ใ‚‰ return dp def reconstruct_LCS(S, T, dp): tmp = [] i, j = len(S), len(T) while i and j: if S[i - 1] == T[j - 1]: i, j = i - 1, j - 1 tmp.append(S[i]) elif dp[i, j] == dp[i - 1, j]: i -= 1 else: j -= 1 return ''.join(reversed(tmp)) s, t = np.array(list(eval(input()))), np.array(list(eval(input()))) print((reconstruct_LCS(s, t, longest_common_subsequence(s, t))))
22
30
523
880
s = eval(input()) t = eval(input()) n = len(s) m = len(t) dp = [[0 for i in range(m + 1)] for j in range(n + 1)] for i in range(n): for j in range(m): if s[i] == t[j]: dp[i + 1][j + 1] = dp[i][j] + 1 else: dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]) ans = "" while dp[n][m] > 0: if ( dp[n][m] == dp[n - 1][m - 1] + 1 and dp[n][m] == dp[n - 1][m] + 1 and dp[n][m] == dp[n][m - 1] + 1 ): ans = "".join([s[n - 1], ans]) n -= 1 m -= 1 elif dp[n - 1][m] > dp[n][m - 1]: n -= 1 else: m -= 1 print(ans)
import numpy as np def longest_common_subsequence(S, T): """compute table dp satisfying: dp[i,j] = LCS(S[:i], T[:j])""" LS, LT = len(S), len(T) dp = np.zeros((LS + 1, LT + 1), np.int32) for n in range(1, LS + 1): dp[n, 1:] = dp[n - 1, :-1] + (S[n - 1] == T) # ๅทฆไธŠใ‹ใ‚‰ np.maximum(dp[n], dp[n - 1], out=dp[n]) # ไธŠใ‹ใ‚‰ np.maximum.accumulate(dp[n], out=dp[n]) # ๅทฆใ‹ใ‚‰ return dp def reconstruct_LCS(S, T, dp): tmp = [] i, j = len(S), len(T) while i and j: if S[i - 1] == T[j - 1]: i, j = i - 1, j - 1 tmp.append(S[i]) elif dp[i, j] == dp[i - 1, j]: i -= 1 else: j -= 1 return "".join(reversed(tmp)) s, t = np.array(list(eval(input()))), np.array(list(eval(input()))) print((reconstruct_LCS(s, t, longest_common_subsequence(s, t))))
false
26.666667
[ "-s = eval(input())", "-t = eval(input())", "-n = len(s)", "-m = len(t)", "-dp = [[0 for i in range(m + 1)] for j in range(n + 1)]", "-for i in range(n):", "- for j in range(m):", "- if s[i] == t[j]:", "- dp[i + 1][j + 1] = dp[i][j] + 1", "+import numpy as np", "+", "+", ...
false
0.107032
0.210254
0.509061
[ "s339108759", "s919600096" ]
u867848444
p03457
python
s077543134
s999994997
461
388
11,744
11,772
Accepted
Accepted
15.84
n=int(eval(input())) t,x,y=[0],[0],[0] for i in range(n): T,X,Y=list(map(int,input().split())) t.append(T) x.append(X) y.append(Y) #print(t,x,y) for i in range(n): time=t[i+1]-t[i] dx=abs(x[i+1]-x[i]) dy=abs(y[i+1]-y[i]) if time<dx+dy or (time+dx+dy)%2!=0: print('No') exit() print('Yes')
n=int(eval(input())) t,x,y=[],[],[] for i in range(n): a,b,c=list(map(int,input().split())) t.append(a) x.append(b) y.append(c) current=[0,0] for i in range(n): next=[x[i]-current[0],y[i]-current[1]] if abs(sum(next))>t[i] or (abs(sum(next))+t[i])%2!=0: print('No') exit() print('Yes')
17
16
341
330
n = int(eval(input())) t, x, y = [0], [0], [0] for i in range(n): T, X, Y = list(map(int, input().split())) t.append(T) x.append(X) y.append(Y) # print(t,x,y) for i in range(n): time = t[i + 1] - t[i] dx = abs(x[i + 1] - x[i]) dy = abs(y[i + 1] - y[i]) if time < dx + dy or (time + dx + dy) % 2 != 0: print("No") exit() print("Yes")
n = int(eval(input())) t, x, y = [], [], [] for i in range(n): a, b, c = list(map(int, input().split())) t.append(a) x.append(b) y.append(c) current = [0, 0] for i in range(n): next = [x[i] - current[0], y[i] - current[1]] if abs(sum(next)) > t[i] or (abs(sum(next)) + t[i]) % 2 != 0: print("No") exit() print("Yes")
false
5.882353
[ "-t, x, y = [0], [0], [0]", "+t, x, y = [], [], []", "- T, X, Y = list(map(int, input().split()))", "- t.append(T)", "- x.append(X)", "- y.append(Y)", "-# print(t,x,y)", "+ a, b, c = list(map(int, input().split()))", "+ t.append(a)", "+ x.append(b)", "+ y.append(c)", "+...
false
0.033766
0.037654
0.89673
[ "s077543134", "s999994997" ]
u442877951
p02720
python
s292168016
s127844792
122
100
11,908
18,916
Accepted
Accepted
18.03
from collections import deque K = int(eval(input())) Q = deque([i for i in range(1,10)]) for _ in range(K-1): q = Q.popleft() if q%10 != 0: Q.append(q*10+q%10-1) Q.append(q*10+q%10) if q%10 != 9: Q.append(q*10+q%10+1) print((Q.popleft()))
from collections import deque K = int(eval(input())) q = deque([1,2,3,4,5,6,7,8,9]) for i in range(K): num = q.popleft() if num%10 != 0: q.append(num*10+num%10-1) q.append(num*10+num%10) if num%10 != 9: q.append(num*10+num%10+1) print(num)
12
13
258
263
from collections import deque K = int(eval(input())) Q = deque([i for i in range(1, 10)]) for _ in range(K - 1): q = Q.popleft() if q % 10 != 0: Q.append(q * 10 + q % 10 - 1) Q.append(q * 10 + q % 10) if q % 10 != 9: Q.append(q * 10 + q % 10 + 1) print((Q.popleft()))
from collections import deque K = int(eval(input())) q = deque([1, 2, 3, 4, 5, 6, 7, 8, 9]) for i in range(K): num = q.popleft() if num % 10 != 0: q.append(num * 10 + num % 10 - 1) q.append(num * 10 + num % 10) if num % 10 != 9: q.append(num * 10 + num % 10 + 1) print(num)
false
7.692308
[ "-Q = deque([i for i in range(1, 10)])", "-for _ in range(K - 1):", "- q = Q.popleft()", "- if q % 10 != 0:", "- Q.append(q * 10 + q % 10 - 1)", "- Q.append(q * 10 + q % 10)", "- if q % 10 != 9:", "- Q.append(q * 10 + q % 10 + 1)", "-print((Q.popleft()))", "+q = deque([1,...
false
0.056635
0.042981
1.317668
[ "s292168016", "s127844792" ]
u852690916
p02774
python
s232927838
s143359765
1,014
590
79,828
78,596
Accepted
Accepted
41.81
import sys def main(): input = sys.stdin.readline N, K = list(map(int, input().split())) A = list(map(int, input().split())) neg, pos, zero = list(), list(), 0 for a in A: if a < 0: neg.append(a) elif a > 0: pos.append(a) else: zero += 1 neg.sort() pos.sort() #xๆœชๆบ€ใซใชใ‚‹็ต„ใฟๅˆใ‚ใ›ใฎๅ€‹ๆ•ฐ def calc(x): result = 0 if x < 0: #่ฒ ใซใชใ‚‹ใฎใฏ ๆญฃ*่ฒ , ่ฒ *ๆญฃ i, j = len(pos)-1, len(neg)-1 while i >= 0: while j >= 0 and pos[i]*neg[j] >= x: j -= 1 if j < 0: break result += j + 1 i -= 1 elif x == 0: result += len(neg) * len(pos) #่ฒ  else: #ๆญฃ*ๆญฃ i, j = 0, len(pos)-1 while i < len(pos): while j >= 0 and pos[i]*pos[j] >= x: j -= 1 if j < 0: break result += j + 1 if pos[i]*pos[i] < x: result -= 1 #ๅŒใ˜ใ‚‚ใฎๅŒๅฃซใ‚’้™คๅค– i += 1 #่ฒ *่ฒ  i, j = len(neg)-1, 0 while i >= 0: while j < len(neg) and neg[i]*neg[j] >= x: j += 1 if j >= len(neg): break result += len(neg) - j if neg[i]*neg[i] < x: result -= 1 #ๅŒใ˜ใ‚‚ใฎๅŒๅฃซใ‚’้™คๅค– i -= 1 result //= 2 #ใƒšใ‚ขใฎๅ…ฅใ‚Œๆ›ฟใˆๅˆ† result += len(neg) * len(pos) #่ฒ  result += (len(neg) + len(pos)) * zero + (zero)*(zero-1)//2 #0 return result #ไบŒๅˆ†ๆŽข็ดข l, over = -10**18, 10**20+1 while over - l > 1: m = (l+over)//2 if calc(m) < K: l = m else: over = m print(l) if __name__ == '__main__': main()
import sys def main(): input = sys.stdin.readline N, K = list(map(int, input().split())) A = list(map(int, input().split())) neg, pos, zero = list(), list(), 0 for a in A: if a < 0: neg.append(a) elif a > 0: pos.append(a) else: zero += 1 neg.sort() pos.sort() #xๆœชๆบ€ใซใชใ‚‹็ต„ใฟๅˆใ‚ใ›ใฎๅ€‹ๆ•ฐ def calc(x): result = 0 if x < 0: #่ฒ ใซใชใ‚‹ใฎใฏ ๆญฃ*่ฒ , ่ฒ *ๆญฃ i, j = len(pos)-1, len(neg)-1 while i >= 0: while j >= 0 and pos[i]*neg[j] >= x: j -= 1 if j < 0: break result += j + 1 i -= 1 elif x == 0: result += len(neg) * len(pos) #่ฒ  else: #ๆญฃ*ๆญฃ i, j = 0, len(pos)-1 while i < len(pos): while j >= 0 and pos[i]*pos[j] >= x: j -= 1 if j < 0: break result += j + 1 if pos[i]*pos[i] < x: result -= 1 #ๅŒใ˜ใ‚‚ใฎๅŒๅฃซใ‚’้™คๅค– i += 1 #่ฒ *่ฒ  i, j = len(neg)-1, 0 while i >= 0: while j < len(neg) and neg[i]*neg[j] >= x: j += 1 if j >= len(neg): break result += len(neg) - j if neg[i]*neg[i] < x: result -= 1 #ๅŒใ˜ใ‚‚ใฎๅŒๅฃซใ‚’้™คๅค– i -= 1 result //= 2 #ใƒšใ‚ขใฎๅ…ฅใ‚Œๆ›ฟใˆๅˆ† result += len(neg) * len(pos) #่ฒ  result += (len(neg) + len(pos)) * zero + (zero)*(zero-1)//2 #0 return result #ไบŒๅˆ†ๆŽข็ดข l, over = -10**18, 10**18+1 while over - l > 1: m = (l+over)//2 if calc(m) < K: l = m else: over = m print(l) if __name__ == '__main__': main()
59
59
1,729
1,729
import sys def main(): input = sys.stdin.readline N, K = list(map(int, input().split())) A = list(map(int, input().split())) neg, pos, zero = list(), list(), 0 for a in A: if a < 0: neg.append(a) elif a > 0: pos.append(a) else: zero += 1 neg.sort() pos.sort() # xๆœชๆบ€ใซใชใ‚‹็ต„ใฟๅˆใ‚ใ›ใฎๅ€‹ๆ•ฐ def calc(x): result = 0 if x < 0: # ่ฒ ใซใชใ‚‹ใฎใฏ ๆญฃ*่ฒ , ่ฒ *ๆญฃ i, j = len(pos) - 1, len(neg) - 1 while i >= 0: while j >= 0 and pos[i] * neg[j] >= x: j -= 1 if j < 0: break result += j + 1 i -= 1 elif x == 0: result += len(neg) * len(pos) # ่ฒ  else: # ๆญฃ*ๆญฃ i, j = 0, len(pos) - 1 while i < len(pos): while j >= 0 and pos[i] * pos[j] >= x: j -= 1 if j < 0: break result += j + 1 if pos[i] * pos[i] < x: result -= 1 # ๅŒใ˜ใ‚‚ใฎๅŒๅฃซใ‚’้™คๅค– i += 1 # ่ฒ *่ฒ  i, j = len(neg) - 1, 0 while i >= 0: while j < len(neg) and neg[i] * neg[j] >= x: j += 1 if j >= len(neg): break result += len(neg) - j if neg[i] * neg[i] < x: result -= 1 # ๅŒใ˜ใ‚‚ใฎๅŒๅฃซใ‚’้™คๅค– i -= 1 result //= 2 # ใƒšใ‚ขใฎๅ…ฅใ‚Œๆ›ฟใˆๅˆ† result += len(neg) * len(pos) # ่ฒ  result += (len(neg) + len(pos)) * zero + (zero) * (zero - 1) // 2 # 0 return result # ไบŒๅˆ†ๆŽข็ดข l, over = -(10**18), 10**20 + 1 while over - l > 1: m = (l + over) // 2 if calc(m) < K: l = m else: over = m print(l) if __name__ == "__main__": main()
import sys def main(): input = sys.stdin.readline N, K = list(map(int, input().split())) A = list(map(int, input().split())) neg, pos, zero = list(), list(), 0 for a in A: if a < 0: neg.append(a) elif a > 0: pos.append(a) else: zero += 1 neg.sort() pos.sort() # xๆœชๆบ€ใซใชใ‚‹็ต„ใฟๅˆใ‚ใ›ใฎๅ€‹ๆ•ฐ def calc(x): result = 0 if x < 0: # ่ฒ ใซใชใ‚‹ใฎใฏ ๆญฃ*่ฒ , ่ฒ *ๆญฃ i, j = len(pos) - 1, len(neg) - 1 while i >= 0: while j >= 0 and pos[i] * neg[j] >= x: j -= 1 if j < 0: break result += j + 1 i -= 1 elif x == 0: result += len(neg) * len(pos) # ่ฒ  else: # ๆญฃ*ๆญฃ i, j = 0, len(pos) - 1 while i < len(pos): while j >= 0 and pos[i] * pos[j] >= x: j -= 1 if j < 0: break result += j + 1 if pos[i] * pos[i] < x: result -= 1 # ๅŒใ˜ใ‚‚ใฎๅŒๅฃซใ‚’้™คๅค– i += 1 # ่ฒ *่ฒ  i, j = len(neg) - 1, 0 while i >= 0: while j < len(neg) and neg[i] * neg[j] >= x: j += 1 if j >= len(neg): break result += len(neg) - j if neg[i] * neg[i] < x: result -= 1 # ๅŒใ˜ใ‚‚ใฎๅŒๅฃซใ‚’้™คๅค– i -= 1 result //= 2 # ใƒšใ‚ขใฎๅ…ฅใ‚Œๆ›ฟใˆๅˆ† result += len(neg) * len(pos) # ่ฒ  result += (len(neg) + len(pos)) * zero + (zero) * (zero - 1) // 2 # 0 return result # ไบŒๅˆ†ๆŽข็ดข l, over = -(10**18), 10**18 + 1 while over - l > 1: m = (l + over) // 2 if calc(m) < K: l = m else: over = m print(l) if __name__ == "__main__": main()
false
0
[ "- l, over = -(10**18), 10**20 + 1", "+ l, over = -(10**18), 10**18 + 1" ]
false
0.038857
0.070214
0.553405
[ "s232927838", "s143359765" ]
u077291787
p02912
python
s524811314
s544552659
133
120
20,432
20,252
Accepted
Accepted
9.77
# ABC141D - Powerful Discount Tickets from heapq import heapify, heappop, heappush def main(): _, M = list(map(int, input().split())) A = [-i for i in map(int, input().split())] heapify(A) heappop_max = lambda heap: -heappop(heap) heappush_max = lambda heap, x: heappush(heap, -x) discount = lambda: heappush_max(A, heappop_max(A) // 2) for _ in range(M): discount() print((-sum(A))) if __name__ == "__main__": main()
# ABC141D - Powerful Discount Tickets from heapq import heapify, heappop, heappush def main(): _, M = list(map(int, input().split())) A = [-i for i in map(int, input().split())] heapify(A) discount = lambda: heappush(A, -(-heappop(A) // 2)) for _ in range(M): discount() print((-sum(A))) if __name__ == "__main__": main()
20
18
479
373
# ABC141D - Powerful Discount Tickets from heapq import heapify, heappop, heappush def main(): _, M = list(map(int, input().split())) A = [-i for i in map(int, input().split())] heapify(A) heappop_max = lambda heap: -heappop(heap) heappush_max = lambda heap, x: heappush(heap, -x) discount = lambda: heappush_max(A, heappop_max(A) // 2) for _ in range(M): discount() print((-sum(A))) if __name__ == "__main__": main()
# ABC141D - Powerful Discount Tickets from heapq import heapify, heappop, heappush def main(): _, M = list(map(int, input().split())) A = [-i for i in map(int, input().split())] heapify(A) discount = lambda: heappush(A, -(-heappop(A) // 2)) for _ in range(M): discount() print((-sum(A))) if __name__ == "__main__": main()
false
10
[ "- heappop_max = lambda heap: -heappop(heap)", "- heappush_max = lambda heap, x: heappush(heap, -x)", "- discount = lambda: heappush_max(A, heappop_max(A) // 2)", "+ discount = lambda: heappush(A, -(-heappop(A) // 2))" ]
false
0.047597
0.137131
0.347088
[ "s524811314", "s544552659" ]
u427344224
p03039
python
s036963892
s087550020
292
236
26,796
18,988
Accepted
Accepted
19.18
class FactMod: def __init__(self, n, mod): self.mod = mod self.f = [1] * (n + 1) for i in range(1, n + 1): self.f[i] = self.f[i - 1] * i % mod self.inv = [pow(self.f[-1], mod - 2, mod)] for i in reversed(list(range(1, n + 1))): self.inv.append(self.inv[-1] * i % mod) self.inv.reverse() def fact(self, n): """ :return: n! """ return self.f[n] def comb(self, n, r): """ :return: nCr """ return self.f[n] * self.inv[n - r] * self.inv[r] % self.mod N, M, K = list(map(int, input().split())) mod = 10 ** 9 + 7 NM = N * M fa = [1] * (NM + 1) for i in range(1, NM + 1): fa[i] = (fa[i - 1] * i) % mod ans = 0 for i in range(1, N): ans += (i * M * M * (N - i)) % mod ans %= mod for i in range(1, M): ans += (i * N * N *(M-i)) % mod ans %= mod factmod = FactMod(NM-2, mod) ans *= factmod.comb(NM-2, K-2) ans %= mod print(ans)
class FactMod: def __init__(self, n, mod): self.mod = mod self.f = [1] * (n + 1) for i in range(1, n + 1): self.f[i] = self.f[i - 1] * i % mod self.inv = [pow(self.f[-1], mod - 2, mod)] for i in reversed(list(range(1, n + 1))): self.inv.append(self.inv[-1] * i % mod) self.inv.reverse() def fact(self, n): """ :return: n! """ return self.f[n] def comb(self, n, r): """ :return: nCr """ return self.f[n] * self.inv[n - r] * self.inv[r] % self.mod N, M, K = list(map(int, input().split())) mod = 10 ** 9 + 7 NM = N * M ans = 0 for i in range(1, N): ans += (i * M * M * (N - i)) % mod ans %= mod for i in range(1, M): ans += (i * N * N * (M - i)) % mod ans %= mod factmod = FactMod(NM - 2, mod) ans *= factmod.comb(NM - 2, K - 2) ans %= mod print(ans)
47
44
1,029
954
class FactMod: def __init__(self, n, mod): self.mod = mod self.f = [1] * (n + 1) for i in range(1, n + 1): self.f[i] = self.f[i - 1] * i % mod self.inv = [pow(self.f[-1], mod - 2, mod)] for i in reversed(list(range(1, n + 1))): self.inv.append(self.inv[-1] * i % mod) self.inv.reverse() def fact(self, n): """ :return: n! """ return self.f[n] def comb(self, n, r): """ :return: nCr """ return self.f[n] * self.inv[n - r] * self.inv[r] % self.mod N, M, K = list(map(int, input().split())) mod = 10**9 + 7 NM = N * M fa = [1] * (NM + 1) for i in range(1, NM + 1): fa[i] = (fa[i - 1] * i) % mod ans = 0 for i in range(1, N): ans += (i * M * M * (N - i)) % mod ans %= mod for i in range(1, M): ans += (i * N * N * (M - i)) % mod ans %= mod factmod = FactMod(NM - 2, mod) ans *= factmod.comb(NM - 2, K - 2) ans %= mod print(ans)
class FactMod: def __init__(self, n, mod): self.mod = mod self.f = [1] * (n + 1) for i in range(1, n + 1): self.f[i] = self.f[i - 1] * i % mod self.inv = [pow(self.f[-1], mod - 2, mod)] for i in reversed(list(range(1, n + 1))): self.inv.append(self.inv[-1] * i % mod) self.inv.reverse() def fact(self, n): """ :return: n! """ return self.f[n] def comb(self, n, r): """ :return: nCr """ return self.f[n] * self.inv[n - r] * self.inv[r] % self.mod N, M, K = list(map(int, input().split())) mod = 10**9 + 7 NM = N * M ans = 0 for i in range(1, N): ans += (i * M * M * (N - i)) % mod ans %= mod for i in range(1, M): ans += (i * N * N * (M - i)) % mod ans %= mod factmod = FactMod(NM - 2, mod) ans *= factmod.comb(NM - 2, K - 2) ans %= mod print(ans)
false
6.382979
[ "-fa = [1] * (NM + 1)", "-for i in range(1, NM + 1):", "- fa[i] = (fa[i - 1] * i) % mod" ]
false
0.101145
0.107677
0.939334
[ "s036963892", "s087550020" ]
u690536347
p02708
python
s099773235
s222418466
176
141
9,164
9,092
Accepted
Accepted
19.89
N, K = list(map(int, input().split())) ans = 0 MOD = 10**9+7 f = lambda x:x*(x+1)//2 for i in range(K, N+2): ans += f(N)-f(N-i)-f(i-1)+1 ans %= MOD print(ans)
N, K = list(map(int, input().split())) MOD = 10**9+7 f = lambda x:x*(x+1)//2 ans = sum(f(N)-f(N-i)-f(i-1)+1 for i in range(K, N+2))%MOD print(ans)
8
5
168
145
N, K = list(map(int, input().split())) ans = 0 MOD = 10**9 + 7 f = lambda x: x * (x + 1) // 2 for i in range(K, N + 2): ans += f(N) - f(N - i) - f(i - 1) + 1 ans %= MOD print(ans)
N, K = list(map(int, input().split())) MOD = 10**9 + 7 f = lambda x: x * (x + 1) // 2 ans = sum(f(N) - f(N - i) - f(i - 1) + 1 for i in range(K, N + 2)) % MOD print(ans)
false
37.5
[ "-ans = 0", "-for i in range(K, N + 2):", "- ans += f(N) - f(N - i) - f(i - 1) + 1", "- ans %= MOD", "+ans = sum(f(N) - f(N - i) - f(i - 1) + 1 for i in range(K, N + 2)) % MOD" ]
false
0.152409
0.067551
2.256197
[ "s099773235", "s222418466" ]
u561083515
p02761
python
s520716605
s719076320
25
21
3,444
3,316
Accepted
Accepted
16
N,M = list(map(int,input().split())) from collections import defaultdict sc = defaultdict(set) for _ in range(M): s,c = list(map(int,input().split())) sc[s].add(c) if N == 1: if len(sc[1]) > 1: print((-1)) elif len(sc[1]) == 1: print((sc[1].pop())) else: print((0)) exit() ans = "" for i in range(1,N+1): if len(sc[i]) > 1: print((-1)) exit() if i == 1: if len(sc[i]) == 1: tmp = sc[i].pop() if tmp == 0: print((-1)) exit() else: ans += str(tmp) else: ans += "1" else: if len(sc[i]) == 1: ans += str(sc[i].pop()) else: ans += "0" print(ans)
N,M = list(map(int, input().split())) from collections import defaultdict SC = defaultdict(set) for _ in range(M): s,c = list(map(int, input().split())) SC[s].add(c) if N == 1: if len(SC[1]) > 1: ans = -1 elif len(SC[1]) == 1: ans = SC[1].pop() else: ans = 0 print(ans) exit() ans = "" for i in range(1, N + 1): if len(SC[i]) > 1: ans = -1 break if i == 1: if len(SC[i]) == 1: tmp = SC[i].pop() if tmp == 0: ans = -1 break else: ans += str(tmp) else: ans += "1" else: if len(SC[i]) == 1: ans += str(SC[i].pop()) else: ans += "0" print(ans)
40
40
790
802
N, M = list(map(int, input().split())) from collections import defaultdict sc = defaultdict(set) for _ in range(M): s, c = list(map(int, input().split())) sc[s].add(c) if N == 1: if len(sc[1]) > 1: print((-1)) elif len(sc[1]) == 1: print((sc[1].pop())) else: print((0)) exit() ans = "" for i in range(1, N + 1): if len(sc[i]) > 1: print((-1)) exit() if i == 1: if len(sc[i]) == 1: tmp = sc[i].pop() if tmp == 0: print((-1)) exit() else: ans += str(tmp) else: ans += "1" else: if len(sc[i]) == 1: ans += str(sc[i].pop()) else: ans += "0" print(ans)
N, M = list(map(int, input().split())) from collections import defaultdict SC = defaultdict(set) for _ in range(M): s, c = list(map(int, input().split())) SC[s].add(c) if N == 1: if len(SC[1]) > 1: ans = -1 elif len(SC[1]) == 1: ans = SC[1].pop() else: ans = 0 print(ans) exit() ans = "" for i in range(1, N + 1): if len(SC[i]) > 1: ans = -1 break if i == 1: if len(SC[i]) == 1: tmp = SC[i].pop() if tmp == 0: ans = -1 break else: ans += str(tmp) else: ans += "1" else: if len(SC[i]) == 1: ans += str(SC[i].pop()) else: ans += "0" print(ans)
false
0
[ "-sc = defaultdict(set)", "+SC = defaultdict(set)", "- sc[s].add(c)", "+ SC[s].add(c)", "- if len(sc[1]) > 1:", "- print((-1))", "- elif len(sc[1]) == 1:", "- print((sc[1].pop()))", "+ if len(SC[1]) > 1:", "+ ans = -1", "+ elif len(SC[1]) == 1:", "+ ...
false
0.035697
0.035381
1.008927
[ "s520716605", "s719076320" ]
u367130284
p03660
python
s144822334
s451253140
549
387
121,564
66,376
Accepted
Accepted
29.51
from collections import * from heapq import* import sys input=lambda:sys.stdin.readline() def BFS(point,d): cost=[1e7]*(n+1) cost[point]=0 Q=[] Q.append((0,point)) while Q: c,p=Q.pop() for np in d[p]: if cost[np]==1e7: cost[np]=c+1 Q.append((c+1,np)) return cost n=int(eval(input())) d=[deque()for i in range(n+1)] for i in range(n-1): a,b=list(map(int,input().split())) d[a].append(b) d[b].append(a) x=BFS(1,d)[1:] y=BFS(n,d)[1:] #print(x,y) F=0 S=0 for s,t in zip(x,y): if s<=t: F+=1 else: S+=1 if F<=S: print("Snuke") else: print("Fennec")
from collections import * from heapq import* import sys input=lambda:sys.stdin.readline() def BFS(point,d): cost=[1e7]*(n+1) cost[point]=0 Q=deque() Q.appendleft((0,point)) while Q: c,p=Q.pop() for np in d[p]: if cost[np]==1e7: cost[np]=c+1 Q.appendleft((c+1,np)) return cost n=int(eval(input())) d=[[]for i in range(n+1)] for i in range(n-1): a,b=list(map(int,input().split())) d[a].append(b) d[b].append(a) x=BFS(1,d)[1:] y=BFS(n,d)[1:] #print(x,y) F=0 S=0 for s,t in zip(x,y): if s<=t: F+=1 else: S+=1 if F<=S: print("Snuke") else: print("Fennec")
45
45
724
731
from collections import * from heapq import * import sys input = lambda: sys.stdin.readline() def BFS(point, d): cost = [1e7] * (n + 1) cost[point] = 0 Q = [] Q.append((0, point)) while Q: c, p = Q.pop() for np in d[p]: if cost[np] == 1e7: cost[np] = c + 1 Q.append((c + 1, np)) return cost n = int(eval(input())) d = [deque() for i in range(n + 1)] for i in range(n - 1): a, b = list(map(int, input().split())) d[a].append(b) d[b].append(a) x = BFS(1, d)[1:] y = BFS(n, d)[1:] # print(x,y) F = 0 S = 0 for s, t in zip(x, y): if s <= t: F += 1 else: S += 1 if F <= S: print("Snuke") else: print("Fennec")
from collections import * from heapq import * import sys input = lambda: sys.stdin.readline() def BFS(point, d): cost = [1e7] * (n + 1) cost[point] = 0 Q = deque() Q.appendleft((0, point)) while Q: c, p = Q.pop() for np in d[p]: if cost[np] == 1e7: cost[np] = c + 1 Q.appendleft((c + 1, np)) return cost n = int(eval(input())) d = [[] for i in range(n + 1)] for i in range(n - 1): a, b = list(map(int, input().split())) d[a].append(b) d[b].append(a) x = BFS(1, d)[1:] y = BFS(n, d)[1:] # print(x,y) F = 0 S = 0 for s, t in zip(x, y): if s <= t: F += 1 else: S += 1 if F <= S: print("Snuke") else: print("Fennec")
false
0
[ "- Q = []", "- Q.append((0, point))", "+ Q = deque()", "+ Q.appendleft((0, point))", "- Q.append((c + 1, np))", "+ Q.appendleft((c + 1, np))", "-d = [deque() for i in range(n + 1)]", "+d = [[] for i in range(n + 1)]" ]
false
0.041496
0.041209
1.006967
[ "s144822334", "s451253140" ]
u416011173
p02682
python
s892662955
s523637211
24
22
9,176
9,192
Accepted
Accepted
8.33
# -*- coding: utf-8 -*- # ๆจ™ๆบ–ๅ…ฅๅŠ›ใฎๅ–ๅพ— A, B, C, K = list(map(int, input().split())) # ๆฑ‚่งฃๅ‡ฆ็† result = int() if K <= A: result = K elif A < K and K <= A + B: result = A elif A + B < K and K <= A + B + C: result = 2*A + B - K # ็ตๆžœๅ‡บๅŠ› print(result)
# -*- coding: utf-8 -*- def get_input() -> tuple: """ๆจ™ๆบ–ๅ…ฅๅŠ›ใฎๅ–ๅพ— Returns: tuple -- ๆจ™ๆบ–ๅ…ฅๅŠ› """ A, B, C, K = list(map(int, input().split())) return A, B, C, K def main(A: int, B: int, C: int, K: int) -> None: """ๆฑ‚่งฃๅ‡ฆ็†. Kใฎๅ€คใงๅ ดๅˆๅˆ†ใ‘ใ™ใ‚‹. Arguments: A {int} -- ๆ•ดๆ•ฐ B {int} -- ๆ•ดๆ•ฐ C {int} -- ๆ•ดๆ•ฐ K {int} -- ๆ•ดๆ•ฐ """ result = int() if K <= A: result = K elif A < K and K <= A + B: result = A elif A + B < K and K <= A + B + C: result = 2*A + B - K # ็ตๆžœๅ‡บๅŠ› print(result) if __name__ == "__main__": A, B, C, K = get_input() main(A, B, C, K)
15
38
266
692
# -*- coding: utf-8 -*- # ๆจ™ๆบ–ๅ…ฅๅŠ›ใฎๅ–ๅพ— A, B, C, K = list(map(int, input().split())) # ๆฑ‚่งฃๅ‡ฆ็† result = int() if K <= A: result = K elif A < K and K <= A + B: result = A elif A + B < K and K <= A + B + C: result = 2 * A + B - K # ็ตๆžœๅ‡บๅŠ› print(result)
# -*- coding: utf-8 -*- def get_input() -> tuple: """ๆจ™ๆบ–ๅ…ฅๅŠ›ใฎๅ–ๅพ— Returns: tuple -- ๆจ™ๆบ–ๅ…ฅๅŠ› """ A, B, C, K = list(map(int, input().split())) return A, B, C, K def main(A: int, B: int, C: int, K: int) -> None: """ๆฑ‚่งฃๅ‡ฆ็†. Kใฎๅ€คใงๅ ดๅˆๅˆ†ใ‘ใ™ใ‚‹. Arguments: A {int} -- ๆ•ดๆ•ฐ B {int} -- ๆ•ดๆ•ฐ C {int} -- ๆ•ดๆ•ฐ K {int} -- ๆ•ดๆ•ฐ """ result = int() if K <= A: result = K elif A < K and K <= A + B: result = A elif A + B < K and K <= A + B + C: result = 2 * A + B - K # ็ตๆžœๅ‡บๅŠ› print(result) if __name__ == "__main__": A, B, C, K = get_input() main(A, B, C, K)
false
60.526316
[ "-# ๆจ™ๆบ–ๅ…ฅๅŠ›ใฎๅ–ๅพ—", "-A, B, C, K = list(map(int, input().split()))", "-# ๆฑ‚่งฃๅ‡ฆ็†", "-result = int()", "-if K <= A:", "- result = K", "-elif A < K and K <= A + B:", "- result = A", "-elif A + B < K and K <= A + B + C:", "- result = 2 * A + B - K", "-# ็ตๆžœๅ‡บๅŠ›", "-print(result)", "+def get_input(...
false
0.084345
0.110949
0.760218
[ "s892662955", "s523637211" ]
u509739538
p03294
python
s645854022
s898095827
90
29
9,516
9,512
Accepted
Accepted
67.78
from collections import defaultdict def readInt(): return int(eval(input())) def readInts(): return list(map(int, input().split())) def readChar(): return eval(input()) def readChars(): return input().split() n = readInt() a = readInts() ma = max(a) ans = 0 seki = 1 for i in a: seki*=i for i in a: ans += (seki-1)%i print(ans)
from collections import defaultdict def readInt(): return int(eval(input())) def readInts(): return list(map(int, input().split())) def readChar(): return eval(input()) def readChars(): return input().split() n = readInt() a = readInts() ans = 0 for i in a: ans+=i-1 print(ans)
23
17
353
293
from collections import defaultdict def readInt(): return int(eval(input())) def readInts(): return list(map(int, input().split())) def readChar(): return eval(input()) def readChars(): return input().split() n = readInt() a = readInts() ma = max(a) ans = 0 seki = 1 for i in a: seki *= i for i in a: ans += (seki - 1) % i print(ans)
from collections import defaultdict def readInt(): return int(eval(input())) def readInts(): return list(map(int, input().split())) def readChar(): return eval(input()) def readChars(): return input().split() n = readInt() a = readInts() ans = 0 for i in a: ans += i - 1 print(ans)
false
26.086957
[ "-ma = max(a)", "-seki = 1", "- seki *= i", "-for i in a:", "- ans += (seki - 1) % i", "+ ans += i - 1" ]
false
0.037612
0.037293
1.00856
[ "s645854022", "s898095827" ]
u489959379
p03001
python
s646067745
s473412888
19
17
2,940
2,940
Accepted
Accepted
10.53
w, h, x, y = list(map(int, input().split())) ans = w * h / 2 if x * 2 == w and y * 2 == h: print((ans, 1)) else: print((ans, 0))
import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): w, h, x, y = list(map(int, input().split())) print((w * h / 2, int(x * 2 == w and y * 2 == h))) if __name__ == '__main__': resolve()
6
15
131
253
w, h, x, y = list(map(int, input().split())) ans = w * h / 2 if x * 2 == w and y * 2 == h: print((ans, 1)) else: print((ans, 0))
import sys sys.setrecursionlimit(10**7) f_inf = float("inf") mod = 10**9 + 7 def resolve(): w, h, x, y = list(map(int, input().split())) print((w * h / 2, int(x * 2 == w and y * 2 == h))) if __name__ == "__main__": resolve()
false
60
[ "-w, h, x, y = list(map(int, input().split()))", "-ans = w * h / 2", "-if x * 2 == w and y * 2 == h:", "- print((ans, 1))", "-else:", "- print((ans, 0))", "+import sys", "+", "+sys.setrecursionlimit(10**7)", "+f_inf = float(\"inf\")", "+mod = 10**9 + 7", "+", "+", "+def resolve():", ...
false
0.043498
0.043521
0.999485
[ "s646067745", "s473412888" ]
u903005414
p02720
python
s061911835
s265469608
588
308
78,776
65,632
Accepted
Accepted
47.62
K = int(eval(input())) numbers = set([]) q = set(list(map(str, [1, 2, 3, 4, 5, 6, 7, 8, 9]))) # print(f'{q=}') while len(numbers) <= 100000: # 10**8: # print('test') qq = set([]) for i in q: # print(f'{i=}') if len(i) == 1: if i == '0': n = i + '0' qq.add(n) n = i + '1' qq.add(n) elif i == '9': n = i + '9' qq.add(n) n = i + '8' qq.add(n) else: v = int(i) n = i + str(v - 1) qq.add(n) n = i + str(v) qq.add(n) n = i + str(v + 1) qq.add(n) else: if i[-1] == '0': n = i + '0' qq.add(n) n = i + '1' qq.add(n) elif i[-1] == '9': n = i + '9' qq.add(n) n = i + '8' qq.add(n) else: v = int(i[-1]) n = i + str(v - 1) qq.add(n) n = i + str(v) qq.add(n) n = i + str(v + 1) qq.add(n) # print(f'{qq=}') numbers |= q # print(f'{numbers=}') # print(f'{len(numbers)=}') q = qq numbers = sorted(map(int, numbers)) # print(f'{numbers[:30]=}') ans = numbers[K - 1] print(ans)
K = int(eval(input())) numbers = set([]) q = set([1, 2, 3, 4, 5, 6, 7, 8, 9]) # print(f'{q=}') while len(numbers) <= 100000: # 10**8: # print('test') qq = set([]) for i in q: # print(f'{i=}') if i % 10 != 0: n = i * 10 + (i % 10) - 1 qq.add(n) if i % 10 != 9: n = i * 10 + (i % 10) + 1 qq.add(n) n = i * 10 + (i % 10) qq.add(n) numbers |= q # print(f'{numbers=}') # print(f'{len(numbers)=}') q = qq numbers = sorted(map(int, numbers)) # print(f'{numbers[:30]=}') ans = numbers[K - 1] print(ans)
58
27
1,521
634
K = int(eval(input())) numbers = set([]) q = set(list(map(str, [1, 2, 3, 4, 5, 6, 7, 8, 9]))) # print(f'{q=}') while len(numbers) <= 100000: # 10**8: # print('test') qq = set([]) for i in q: # print(f'{i=}') if len(i) == 1: if i == "0": n = i + "0" qq.add(n) n = i + "1" qq.add(n) elif i == "9": n = i + "9" qq.add(n) n = i + "8" qq.add(n) else: v = int(i) n = i + str(v - 1) qq.add(n) n = i + str(v) qq.add(n) n = i + str(v + 1) qq.add(n) else: if i[-1] == "0": n = i + "0" qq.add(n) n = i + "1" qq.add(n) elif i[-1] == "9": n = i + "9" qq.add(n) n = i + "8" qq.add(n) else: v = int(i[-1]) n = i + str(v - 1) qq.add(n) n = i + str(v) qq.add(n) n = i + str(v + 1) qq.add(n) # print(f'{qq=}') numbers |= q # print(f'{numbers=}') # print(f'{len(numbers)=}') q = qq numbers = sorted(map(int, numbers)) # print(f'{numbers[:30]=}') ans = numbers[K - 1] print(ans)
K = int(eval(input())) numbers = set([]) q = set([1, 2, 3, 4, 5, 6, 7, 8, 9]) # print(f'{q=}') while len(numbers) <= 100000: # 10**8: # print('test') qq = set([]) for i in q: # print(f'{i=}') if i % 10 != 0: n = i * 10 + (i % 10) - 1 qq.add(n) if i % 10 != 9: n = i * 10 + (i % 10) + 1 qq.add(n) n = i * 10 + (i % 10) qq.add(n) numbers |= q # print(f'{numbers=}') # print(f'{len(numbers)=}') q = qq numbers = sorted(map(int, numbers)) # print(f'{numbers[:30]=}') ans = numbers[K - 1] print(ans)
false
53.448276
[ "-q = set(list(map(str, [1, 2, 3, 4, 5, 6, 7, 8, 9])))", "+q = set([1, 2, 3, 4, 5, 6, 7, 8, 9])", "- if len(i) == 1:", "- if i == \"0\":", "- n = i + \"0\"", "- qq.add(n)", "- n = i + \"1\"", "- qq.add(n)", "- e...
false
1.544572
1.221556
1.26443
[ "s061911835", "s265469608" ]
u557729026
p02832
python
s761223047
s949875875
236
136
26,268
26,012
Accepted
Accepted
42.37
N = int(eval(input())) ori = [int(i) for i in input().split()] count = ori.count(1) if count == 0: print((-1)) else: savepoint = 0 for j in range(1,N+1): for i in range(savepoint,N): if ori[i] == j: savepoint = i #print(savepoint) #print(j,i) sub = j break if i == N-1: break print((N-sub))
N=int(eval(input())) a=[int(i) for i in input().split()] if a.count(1)==0: print((-1)) else: ans=[] for i in range(N): if a[i]==len(ans)+1: ans.append(a[i]) #print(N) #print(len(ans)) print((N-len(ans)))
19
12
435
250
N = int(eval(input())) ori = [int(i) for i in input().split()] count = ori.count(1) if count == 0: print((-1)) else: savepoint = 0 for j in range(1, N + 1): for i in range(savepoint, N): if ori[i] == j: savepoint = i # print(savepoint) # print(j,i) sub = j break if i == N - 1: break print((N - sub))
N = int(eval(input())) a = [int(i) for i in input().split()] if a.count(1) == 0: print((-1)) else: ans = [] for i in range(N): if a[i] == len(ans) + 1: ans.append(a[i]) # print(N) # print(len(ans)) print((N - len(ans)))
false
36.842105
[ "-ori = [int(i) for i in input().split()]", "-count = ori.count(1)", "-if count == 0:", "+a = [int(i) for i in input().split()]", "+if a.count(1) == 0:", "- savepoint = 0", "- for j in range(1, N + 1):", "- for i in range(savepoint, N):", "- if ori[i] == j:", "- ...
false
0.037575
0.03701
1.015268
[ "s761223047", "s949875875" ]
u644907318
p03805
python
s036081962
s813536617
260
31
45,548
3,188
Accepted
Accepted
88.08
N,M = list(map(int,input().split())) G = {} for _ in range(M): a,b = list(map(int,input().split())) if a not in G: G[a] = [] G[a].append(b) if b not in G: G[b] = [] G[b].append(a) hist = [0 for _ in range(N+1)] stack = [1] hist[1] = 1 cnt = 0 F = {} while stack: cur = stack[-1] if cur not in F: F[cur] = G[cur][:] F[cur] = iter(F[cur]) F1 = list(F[cur]) # print("cur={},F1={}".format(cur,F1)) if len(F1)>0: F[cur] = iter(F1) x = next(F[cur]) if hist[x]==0: stack.append(x) hist[x] = 1 else: if sum(hist)==N: cnt += 1 hist[cur]=0 del F[cur] stack.pop() else: # print("cur={}".format(cur)) # print("stack={}".format(stack)) if sum(hist)==N: cnt += 1 hist[cur]=0 del F[cur] stack.pop() print(cnt)
from itertools import permutations def check(i,j): if j==N-2 and x[j] in G[i]: return True if x[j] in G[i]: return check(x[j],j+1) return False N,M = list(map(int,input().split())) G = {i:[] for i in range(1,N+1)} for _ in range(M): a,b = list(map(int,input().split())) G[a].append(b) G[b].append(a) cnt = 0 for x in permutations(list(range(2,N+1)),N-1): if check(1,0): cnt += 1 print(cnt)
43
19
992
449
N, M = list(map(int, input().split())) G = {} for _ in range(M): a, b = list(map(int, input().split())) if a not in G: G[a] = [] G[a].append(b) if b not in G: G[b] = [] G[b].append(a) hist = [0 for _ in range(N + 1)] stack = [1] hist[1] = 1 cnt = 0 F = {} while stack: cur = stack[-1] if cur not in F: F[cur] = G[cur][:] F[cur] = iter(F[cur]) F1 = list(F[cur]) # print("cur={},F1={}".format(cur,F1)) if len(F1) > 0: F[cur] = iter(F1) x = next(F[cur]) if hist[x] == 0: stack.append(x) hist[x] = 1 else: if sum(hist) == N: cnt += 1 hist[cur] = 0 del F[cur] stack.pop() else: # print("cur={}".format(cur)) # print("stack={}".format(stack)) if sum(hist) == N: cnt += 1 hist[cur] = 0 del F[cur] stack.pop() print(cnt)
from itertools import permutations def check(i, j): if j == N - 2 and x[j] in G[i]: return True if x[j] in G[i]: return check(x[j], j + 1) return False N, M = list(map(int, input().split())) G = {i: [] for i in range(1, N + 1)} for _ in range(M): a, b = list(map(int, input().split())) G[a].append(b) G[b].append(a) cnt = 0 for x in permutations(list(range(2, N + 1)), N - 1): if check(1, 0): cnt += 1 print(cnt)
false
55.813953
[ "+from itertools import permutations", "+", "+", "+def check(i, j):", "+ if j == N - 2 and x[j] in G[i]:", "+ return True", "+ if x[j] in G[i]:", "+ return check(x[j], j + 1)", "+ return False", "+", "+", "-G = {}", "+G = {i: [] for i in range(1, N + 1)}", "- if a...
false
0.042475
0.03938
1.078587
[ "s036081962", "s813536617" ]
u970449052
p03624
python
s094698195
s845103489
26
17
3,956
3,188
Accepted
Accepted
34.62
s=eval(input()) al=[chr(ord('a') + i) for i in range(26)] sl=set([s[i] for i in range(len(s))]) for si in sl: al.remove(si) if len(al)>0: print((al[0])) else: print('None')
s=eval(input()) al='abcdefghijklmnopqrstuvwxyz' for a in al: if not a in s: print(a) exit() print('None')
9
7
184
125
s = eval(input()) al = [chr(ord("a") + i) for i in range(26)] sl = set([s[i] for i in range(len(s))]) for si in sl: al.remove(si) if len(al) > 0: print((al[0])) else: print("None")
s = eval(input()) al = "abcdefghijklmnopqrstuvwxyz" for a in al: if not a in s: print(a) exit() print("None")
false
22.222222
[ "-al = [chr(ord(\"a\") + i) for i in range(26)]", "-sl = set([s[i] for i in range(len(s))])", "-for si in sl:", "- al.remove(si)", "-if len(al) > 0:", "- print((al[0]))", "-else:", "- print(\"None\")", "+al = \"abcdefghijklmnopqrstuvwxyz\"", "+for a in al:", "+ if not a in s:", "+ ...
false
0.075002
0.076066
0.986015
[ "s094698195", "s845103489" ]
u811434779
p02469
python
s412330309
s643209187
30
10
6,436
6,436
Accepted
Accepted
66.67
from functools import reduce def gcd(a, b): if a < b: a, b = b, a while b: t = a / b a -= b * t a, b = b, a return a def lcm(a, b): return a * b / gcd(a, b) n = eval(input()) print(reduce(lambda a, b:lcm(a, b), list(map(int, input().split()))))
from functools import reduce def gcd(a, b): if b == 0: return a else: return gcd(b, a % b) def lcm(a, b): return a * b / gcd(a, b) n = eval(input()) print(reduce(lambda a, b:lcm(a, b), list(map(int, input().split()))))
11
7
256
198
from functools import reduce def gcd(a, b): if a < b: a, b = b, a while b: t = a / b a -= b * t a, b = b, a return a def lcm(a, b): return a * b / gcd(a, b) n = eval(input()) print(reduce(lambda a, b: lcm(a, b), list(map(int, input().split()))))
from functools import reduce def gcd(a, b): if b == 0: return a else: return gcd(b, a % b) def lcm(a, b): return a * b / gcd(a, b) n = eval(input()) print(reduce(lambda a, b: lcm(a, b), list(map(int, input().split()))))
false
36.363636
[ "- if a < b:", "- a, b = b, a", "- while b:", "- t = a / b", "- a -= b * t", "- a, b = b, a", "- return a", "+ if b == 0:", "+ return a", "+ else:", "+ return gcd(b, a % b)" ]
false
0.041267
0.041293
0.999367
[ "s412330309", "s643209187" ]
u130900604
p02912
python
s417679043
s326709712
173
156
14,180
15,432
Accepted
Accepted
9.83
from heapq import * n,m=list(map(int,input().split())) a=list(map(int,input().split())) q=[] for x in a: heappush(q,-x) for i in range(m): temp=-heappop(q) heappush(q,-(temp//2)) print((-sum(q)))
from heapq import * n, m = list(map(int,input().split())) a = list(map(int,input().split())) q = [] for i in a: heappush(q,-i) #print(q) for j in range(m): temp = -heappop(q) temp //= 2 heappush(q,-temp) #print(q) print((-(sum(q))))
13
13
212
240
from heapq import * n, m = list(map(int, input().split())) a = list(map(int, input().split())) q = [] for x in a: heappush(q, -x) for i in range(m): temp = -heappop(q) heappush(q, -(temp // 2)) print((-sum(q)))
from heapq import * n, m = list(map(int, input().split())) a = list(map(int, input().split())) q = [] for i in a: heappush(q, -i) # print(q) for j in range(m): temp = -heappop(q) temp //= 2 heappush(q, -temp) # print(q) print((-(sum(q))))
false
0
[ "-for x in a:", "- heappush(q, -x)", "-for i in range(m):", "+for i in a:", "+ heappush(q, -i)", "+# print(q)", "+for j in range(m):", "- heappush(q, -(temp // 2))", "-print((-sum(q)))", "+ temp //= 2", "+ heappush(q, -temp)", "+ # print(q)", "+print((-(sum(q))))" ]
false
0.067713
0.090485
0.748334
[ "s417679043", "s326709712" ]
u156815136
p03030
python
s636977486
s842753086
38
34
10,200
10,196
Accepted
Accepted
10.53
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)ใงๆœ€ๅคงใฎ2ๅ€‹ใจใ‚Šใ ใ›ใ‚‹ใŠ a[0][0] from fractions import gcd from itertools import combinations,permutations,accumulate # (string,3) 3ๅ›ž #from collections import deque from collections import deque,defaultdict,Counter import decimal import re #import bisect # # d = m - k[i] - k[j] # if kk[bisect.bisect_right(kk,d) - 1] == d: # # # # pythonใง็„ก็†ใชใจใใฏใ€pypyใงใ‚„ใ‚‹ใจๆญฃ่งฃใ™ใ‚‹ใ‹ใ‚‚๏ผ๏ผ # # import sys sys.setrecursionlimit(10000000) mod = 10**9 + 7 #mod = 9982443453 def readInts(): return list(map(int,input().split())) def I(): return int(eval(input())) n = I() li = [] for i in range(n): s,t = input().split() li.append([s,int(t),i+1]) li = sorted(li,key = lambda x:x[1], reverse = True) li = sorted(li,key = lambda x:x[0]) for i in range(n): print((li[i][2]))
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)ใงๆœ€ๅคงใฎ2ๅ€‹ใจใ‚Šใ ใ›ใ‚‹ใŠ a[0][0] from fractions import gcd from itertools import combinations,permutations,accumulate # (string,3) 3ๅ›ž #from collections import deque from collections import deque,defaultdict,Counter import decimal import re #import bisect # # d = m - k[i] - k[j] # if kk[bisect.bisect_right(kk,d) - 1] == d: # # # # pythonใง็„ก็†ใชใจใใฏใ€pypyใงใ‚„ใ‚‹ใจๆญฃ่งฃใ™ใ‚‹ใ‹ใ‚‚๏ผ๏ผ # # # my_round_int = lambda x:np.round((x*2 + 1)//2) # ๅ››ๆจไบ”ๅ…ฅ import sys sys.setrecursionlimit(10000000) mod = 10**9 + 7 #mod = 9982443453 def readInts(): return list(map(int,input().split())) def I(): return int(eval(input())) n = I() ans = [] for i in range(n): name,score = input().split() score = int(score) ans.append([name,score,i+1]) ans = sorted(ans,key = lambda x:x[1],reverse = True) ans = sorted(ans,key = lambda x:x[0]) for i in range(n): print((ans[i][2]))
37
39
893
988
# from statistics import median # import collections # aa = collections.Counter(a) # list to list || .most_common(2)ใงๆœ€ๅคงใฎ2ๅ€‹ใจใ‚Šใ ใ›ใ‚‹ใŠ a[0][0] from fractions import gcd from itertools import combinations, permutations, accumulate # (string,3) 3ๅ›ž # from collections import deque from collections import deque, defaultdict, Counter import decimal import re # import bisect # # d = m - k[i] - k[j] # if kk[bisect.bisect_right(kk,d) - 1] == d: # # # # pythonใง็„ก็†ใชใจใใฏใ€pypyใงใ‚„ใ‚‹ใจๆญฃ่งฃใ™ใ‚‹ใ‹ใ‚‚๏ผ๏ผ # # import sys sys.setrecursionlimit(10000000) mod = 10**9 + 7 # mod = 9982443453 def readInts(): return list(map(int, input().split())) def I(): return int(eval(input())) n = I() li = [] for i in range(n): s, t = input().split() li.append([s, int(t), i + 1]) li = sorted(li, key=lambda x: x[1], reverse=True) li = sorted(li, key=lambda x: x[0]) for i in range(n): print((li[i][2]))
# from statistics import median # import collections # aa = collections.Counter(a) # list to list || .most_common(2)ใงๆœ€ๅคงใฎ2ๅ€‹ใจใ‚Šใ ใ›ใ‚‹ใŠ a[0][0] from fractions import gcd from itertools import combinations, permutations, accumulate # (string,3) 3ๅ›ž # from collections import deque from collections import deque, defaultdict, Counter import decimal import re # import bisect # # d = m - k[i] - k[j] # if kk[bisect.bisect_right(kk,d) - 1] == d: # # # # pythonใง็„ก็†ใชใจใใฏใ€pypyใงใ‚„ใ‚‹ใจๆญฃ่งฃใ™ใ‚‹ใ‹ใ‚‚๏ผ๏ผ # # # my_round_int = lambda x:np.round((x*2 + 1)//2) # ๅ››ๆจไบ”ๅ…ฅ import sys sys.setrecursionlimit(10000000) mod = 10**9 + 7 # mod = 9982443453 def readInts(): return list(map(int, input().split())) def I(): return int(eval(input())) n = I() ans = [] for i in range(n): name, score = input().split() score = int(score) ans.append([name, score, i + 1]) ans = sorted(ans, key=lambda x: x[1], reverse=True) ans = sorted(ans, key=lambda x: x[0]) for i in range(n): print((ans[i][2]))
false
5.128205
[ "+# my_round_int = lambda x:np.round((x*2 + 1)//2)", "+# ๅ››ๆจไบ”ๅ…ฅ", "-li = []", "+ans = []", "- s, t = input().split()", "- li.append([s, int(t), i + 1])", "-li = sorted(li, key=lambda x: x[1], reverse=True)", "-li = sorted(li, key=lambda x: x[0])", "+ name, score = input().split()", "+ sc...
false
0.049582
0.047657
1.040388
[ "s636977486", "s842753086" ]
u912237403
p00154
python
s430004559
s839713809
40
30
4,400
4,408
Accepted
Accepted
25
while 1: m = int(input()) if m==0: break card = [] total = 0 for i in range(m): a, b = list(map(int, input().split())) card.append([a, b]) total += a*b card = sorted(card)[::-1] B = [0]*(total+1) for a, b in card: A = B[:] B = [0] * (total+1) B[a:a*b+1:a] = [1]*b for i in range(total+1)[::-1]: if A[i]: for e in range(i, i+a*b+1, a): B[e] += A[i] g = int(input()) for _ in [0] * g: n = int(input()) if 0<=n<=total: print(B[n]) else: print(0)
def In(): return int(input()) while 1: m = In() if m==0: break card = [0]*m total = 0 for i in range(m): a,b = list(map(int, input().split())) card[i] = [a,b] total += a*b card = sorted(card)[::-1] B = [0]*(total+1) for a,b in card: A = B[:] B = [0]*(total+1) B[a:a*b+1:a] = [1]*b for i in range(total+1)[::-1]: if A[i]: for e in range(i,i+a*b+1,a): B[e] += A[i] for _ in [0]*In(): n = In() if 0<=n<=total: print(B[n]) else: print(0)
29
26
577
533
while 1: m = int(input()) if m == 0: break card = [] total = 0 for i in range(m): a, b = list(map(int, input().split())) card.append([a, b]) total += a * b card = sorted(card)[::-1] B = [0] * (total + 1) for a, b in card: A = B[:] B = [0] * (total + 1) B[a : a * b + 1 : a] = [1] * b for i in range(total + 1)[::-1]: if A[i]: for e in range(i, i + a * b + 1, a): B[e] += A[i] g = int(input()) for _ in [0] * g: n = int(input()) if 0 <= n <= total: print(B[n]) else: print(0)
def In(): return int(input()) while 1: m = In() if m == 0: break card = [0] * m total = 0 for i in range(m): a, b = list(map(int, input().split())) card[i] = [a, b] total += a * b card = sorted(card)[::-1] B = [0] * (total + 1) for a, b in card: A = B[:] B = [0] * (total + 1) B[a : a * b + 1 : a] = [1] * b for i in range(total + 1)[::-1]: if A[i]: for e in range(i, i + a * b + 1, a): B[e] += A[i] for _ in [0] * In(): n = In() if 0 <= n <= total: print(B[n]) else: print(0)
false
10.344828
[ "+def In():", "+ return int(input())", "+", "+", "- m = int(input())", "+ m = In()", "- card = []", "+ card = [0] * m", "- card.append([a, b])", "+ card[i] = [a, b]", "- g = int(input())", "- for _ in [0] * g:", "- n = int(input())", "+ for _ in...
false
0.144234
0.063897
2.257283
[ "s430004559", "s839713809" ]
u631277801
p03776
python
s461588821
s664576001
24
18
3,444
3,192
Accepted
Accepted
25
import sys stdin = sys.stdin def li(): return [int(x) for x in stdin.readline().split()] def li_(): return [int(x)-1 for x in stdin.readline().split()] def lf(): return [float(x) for x in stdin.readline().split()] def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() def lc(): return list(ns()) def ni(): return int(ns()) def nf(): return float(ns()) # nใฎ้€†ๅ…ƒใฎใƒชใ‚นใƒˆ def inv_mod(n:int, mod:int) -> list: inv = [0,1] for i in range(2,n+1): inv.append(mod - ((mod//i)*inv[mod%i]) % mod) return inv # nใฎ้šŽไน—ใฎใƒชใ‚นใƒˆ def fact(n:int, mod:int) -> list: fac = [1,1] res = 1 for i in range(2,n+1): res = res*i%mod fac.append(res) return fac # nใฎ้šŽไน—ใฎ้€†ๅ…ƒใฎใƒชใ‚นใƒˆ def fact_inv(n:int, inv:list, mod:int) -> list: facInv = [1,1] for i in range(2,n+1): facInv.append(facInv[i-1]*inv[i] % mod) return facInv # ไบŒ้ …ไฟ‚ๆ•ฐ def nCr(n:int, r:int, mod:int, fac:list, facInv:list) -> int: if not (0<=r and r<=n): return 0 return ((fac[n]*facInv[r]) % mod) * facInv[n-r] % mod from itertools import accumulate from collections import Counter n,a,b = li() v = li() v.sort(reverse=True) v_cum = list(accumulate(v)) ans_cand = [] # ่ฒชๆฌฒใซๆœ€ๅคงๅ€คใ‚’้ธใถ for i in range(a,b+1): ans_cand.append(v_cum[i-1] / i) ans = max(ans_cand) opt_i = a + ans_cand.index(ans) - 1 cnt_v = Counter(v) opt_set = v[:opt_i+1] # ่ฒชๆฌฒๆœ€ๅคงใŒไฝ•้€šใ‚Šใงใใ‚‹ใ‹่€ƒใˆใ‚‹ MOD = 46116646144580591 inv = inv_mod(n, MOD) fac = fact(n, MOD) facInv = fact_inv(n,inv, MOD) pat = 0 if v[0] == v[opt_i]: for i in range(a, min(b, cnt_v[v[0]]) + 1): pat += nCr(cnt_v[v[0]], i, MOD, fac, facInv) else: cnt_opt = Counter(opt_set) pat = nCr(cnt_v[v[opt_i]], cnt_opt[v[opt_i]], MOD, fac, facInv) print(ans) print(pat)
import sys stdin = sys.stdin sys.setrecursionlimit(10**5) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x)-1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() def lc(): return list(ns()) def ni(): return int(stdin.readline()) def nf(): return float(stdin.readline()) # nใฎ้€†ๅ…ƒใฎใƒชใ‚นใƒˆ def inv_mod(n:int, mod:int) -> list: inv = [0,1] for i in range(2,n+1): inv.append(mod - ((mod//i)*inv[mod%i]) % mod) return inv # nใฎ้šŽไน—ใฎใƒชใ‚นใƒˆ def fact(n:int, mod:int) -> list: fac = [1,1] res = 1 for i in range(2,n+1): res = res*i%mod fac.append(res) return fac # nใฎ้šŽไน—ใฎ้€†ๅ…ƒใฎใƒชใ‚นใƒˆ def fact_inv(n:int, inv:list, mod:int) -> list: facInv = [1,1] for i in range(2,n+1): facInv.append(facInv[i-1]*inv[i] % mod) return facInv # ไบŒ้ …ไฟ‚ๆ•ฐ def nCr(n:int, r:int, mod:int, fac:list, facInv:list) -> int: if not (0<=r and r<=n): return 0 return ((fac[n]*facInv[r]) % mod) * facInv[n-r] % mod # nCrใฎๅ’Œใ‚’ใจใ‚‹้–ขๆ•ฐ def comb_sum(base: int, start: int, last: int, mod: int, fac: list, facInv:list): ret = 0 for i in range(start, last+1): ret += nCr(base, i, mod, fac, facInv) return ret n,a,b = li() v = list(li()) v.sort(reverse=True) maxv = max(v) maxs = v.count(maxv) MOD = 2**61-1 MAXN = 100 inv = inv_mod(MAXN, MOD) fac = fact(MAXN, MOD) fac_inv = fact_inv(MAXN, inv, MOD) if maxs <= a: ans = sum(v[:a]) / a lastcnt = v.count(v[a-1]) pat = nCr(lastcnt, a-v.index(v[a-1]), MOD, fac, fac_inv) elif a < maxs < b: ans = maxv pat = comb_sum(maxs, a, maxs, MOD, fac, fac_inv) else: ans = maxv pat = comb_sum(maxs, a, b, MOD, fac, fac_inv) print(ans) print(pat)
83
82
1,872
1,942
import sys stdin = sys.stdin def li(): return [int(x) for x in stdin.readline().split()] def li_(): return [int(x) - 1 for x in stdin.readline().split()] def lf(): return [float(x) for x in stdin.readline().split()] def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() def lc(): return list(ns()) def ni(): return int(ns()) def nf(): return float(ns()) # nใฎ้€†ๅ…ƒใฎใƒชใ‚นใƒˆ def inv_mod(n: int, mod: int) -> list: inv = [0, 1] for i in range(2, n + 1): inv.append(mod - ((mod // i) * inv[mod % i]) % mod) return inv # nใฎ้šŽไน—ใฎใƒชใ‚นใƒˆ def fact(n: int, mod: int) -> list: fac = [1, 1] res = 1 for i in range(2, n + 1): res = res * i % mod fac.append(res) return fac # nใฎ้šŽไน—ใฎ้€†ๅ…ƒใฎใƒชใ‚นใƒˆ def fact_inv(n: int, inv: list, mod: int) -> list: facInv = [1, 1] for i in range(2, n + 1): facInv.append(facInv[i - 1] * inv[i] % mod) return facInv # ไบŒ้ …ไฟ‚ๆ•ฐ def nCr(n: int, r: int, mod: int, fac: list, facInv: list) -> int: if not (0 <= r and r <= n): return 0 return ((fac[n] * facInv[r]) % mod) * facInv[n - r] % mod from itertools import accumulate from collections import Counter n, a, b = li() v = li() v.sort(reverse=True) v_cum = list(accumulate(v)) ans_cand = [] # ่ฒชๆฌฒใซๆœ€ๅคงๅ€คใ‚’้ธใถ for i in range(a, b + 1): ans_cand.append(v_cum[i - 1] / i) ans = max(ans_cand) opt_i = a + ans_cand.index(ans) - 1 cnt_v = Counter(v) opt_set = v[: opt_i + 1] # ่ฒชๆฌฒๆœ€ๅคงใŒไฝ•้€šใ‚Šใงใใ‚‹ใ‹่€ƒใˆใ‚‹ MOD = 46116646144580591 inv = inv_mod(n, MOD) fac = fact(n, MOD) facInv = fact_inv(n, inv, MOD) pat = 0 if v[0] == v[opt_i]: for i in range(a, min(b, cnt_v[v[0]]) + 1): pat += nCr(cnt_v[v[0]], i, MOD, fac, facInv) else: cnt_opt = Counter(opt_set) pat = nCr(cnt_v[v[opt_i]], cnt_opt[v[opt_i]], MOD, fac, facInv) print(ans) print(pat)
import sys stdin = sys.stdin sys.setrecursionlimit(10**5) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x) - 1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() def lc(): return list(ns()) def ni(): return int(stdin.readline()) def nf(): return float(stdin.readline()) # nใฎ้€†ๅ…ƒใฎใƒชใ‚นใƒˆ def inv_mod(n: int, mod: int) -> list: inv = [0, 1] for i in range(2, n + 1): inv.append(mod - ((mod // i) * inv[mod % i]) % mod) return inv # nใฎ้šŽไน—ใฎใƒชใ‚นใƒˆ def fact(n: int, mod: int) -> list: fac = [1, 1] res = 1 for i in range(2, n + 1): res = res * i % mod fac.append(res) return fac # nใฎ้šŽไน—ใฎ้€†ๅ…ƒใฎใƒชใ‚นใƒˆ def fact_inv(n: int, inv: list, mod: int) -> list: facInv = [1, 1] for i in range(2, n + 1): facInv.append(facInv[i - 1] * inv[i] % mod) return facInv # ไบŒ้ …ไฟ‚ๆ•ฐ def nCr(n: int, r: int, mod: int, fac: list, facInv: list) -> int: if not (0 <= r and r <= n): return 0 return ((fac[n] * facInv[r]) % mod) * facInv[n - r] % mod # nCrใฎๅ’Œใ‚’ใจใ‚‹้–ขๆ•ฐ def comb_sum(base: int, start: int, last: int, mod: int, fac: list, facInv: list): ret = 0 for i in range(start, last + 1): ret += nCr(base, i, mod, fac, facInv) return ret n, a, b = li() v = list(li()) v.sort(reverse=True) maxv = max(v) maxs = v.count(maxv) MOD = 2**61 - 1 MAXN = 100 inv = inv_mod(MAXN, MOD) fac = fact(MAXN, MOD) fac_inv = fact_inv(MAXN, inv, MOD) if maxs <= a: ans = sum(v[:a]) / a lastcnt = v.count(v[a - 1]) pat = nCr(lastcnt, a - v.index(v[a - 1]), MOD, fac, fac_inv) elif a < maxs < b: ans = maxv pat = comb_sum(maxs, a, maxs, MOD, fac, fac_inv) else: ans = maxv pat = comb_sum(maxs, a, b, MOD, fac, fac_inv) print(ans) print(pat)
false
1.204819
[ "+sys.setrecursionlimit(10**5)", "- return [int(x) for x in stdin.readline().split()]", "+ return list(map(int, stdin.readline().split()))", "- return [float(x) for x in stdin.readline().split()]", "+ return list(map(float, stdin.readline().split()))", "- return int(ns())", "+ return i...
false
0.120702
0.045491
2.653305
[ "s461588821", "s664576001" ]
u379142263
p03557
python
s308711554
s472223311
323
214
23,840
104,348
Accepted
Accepted
33.75
import sys import itertools sys.setrecursionlimit(1000000000) from heapq import heapify,heappop,heappush,heappushpop import math import collections import copy import bisect n = int(eval(input())) A = list(map(int,input().split())) B = list(map(int,input().split())) C = list(map(int,input().split())) A.sort() B.sort() C.sort() ans = 0 for b in B: a = bisect.bisect_left(A,b) c = n - bisect.bisect_left(C,b+1) ans += a*c print(ans)
import sys import itertools sys.setrecursionlimit(1000000000) from heapq import heapify,heappop,heappush,heappushpop import math import collections import copy import bisect mod = 10**9+7 if __name__ == "__main__": n = int(eval(input())) A = sorted(list(map(int,input().split()))) B = sorted(list(map(int,input().split()))) C = sorted(list(map(int,input().split()))) ans = 0 for b in B: a = bisect.bisect_left(A,b) c = n - bisect.bisect_left(C,b+1) ans += a*c print(ans)
22
21
460
537
import sys import itertools sys.setrecursionlimit(1000000000) from heapq import heapify, heappop, heappush, heappushpop import math import collections import copy import bisect n = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() B.sort() C.sort() ans = 0 for b in B: a = bisect.bisect_left(A, b) c = n - bisect.bisect_left(C, b + 1) ans += a * c print(ans)
import sys import itertools sys.setrecursionlimit(1000000000) from heapq import heapify, heappop, heappush, heappushpop import math import collections import copy import bisect mod = 10**9 + 7 if __name__ == "__main__": n = int(eval(input())) A = sorted(list(map(int, input().split()))) B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) ans = 0 for b in B: a = bisect.bisect_left(A, b) c = n - bisect.bisect_left(C, b + 1) ans += a * c print(ans)
false
4.545455
[ "-n = int(eval(input()))", "-A = list(map(int, input().split()))", "-B = list(map(int, input().split()))", "-C = list(map(int, input().split()))", "-A.sort()", "-B.sort()", "-C.sort()", "-ans = 0", "-for b in B:", "- a = bisect.bisect_left(A, b)", "- c = n - bisect.bisect_left(C, b + 1)", ...
false
0.041896
0.033379
1.255157
[ "s308711554", "s472223311" ]
u557792847
p02584
python
s542187290
s382822965
130
30
27,116
9,100
Accepted
Accepted
76.92
import sys import numpy as np import math import collections import copy from collections import deque from functools import reduce from itertools import product from itertools import combinations # input = sys.stdin.readline Xa, K, D = list(map(int, input().split())) X = abs(Xa) Xs = X // D Xm = X % D if K < Xs: # print("A") print((abs(X-K*D))) elif Xa == 0: if K % 2 == 0: print((0)) else: print(D) elif Xm == 0: if K % 2 == 0: print(D) else: print((0)) elif ((K-Xs) % 2 == 0): print((abs(Xm))) else: print((abs(D-Xm)))
Xa, K, D = list(map(int, input().split())) X = abs(Xa) Xs = X // D Xm = X % D if K < Xs: # print("A") print((abs(X-K*D))) elif Xa == 0: if K % 2 == 0: print((0)) else: print(D) elif Xm == 0: if K % 2 == 0: print(D) else: print((0)) elif ((K-Xs) % 2 == 0): print((abs(Xm))) else: print((abs(D-Xm))) # else:
45
25
631
381
import sys import numpy as np import math import collections import copy from collections import deque from functools import reduce from itertools import product from itertools import combinations # input = sys.stdin.readline Xa, K, D = list(map(int, input().split())) X = abs(Xa) Xs = X // D Xm = X % D if K < Xs: # print("A") print((abs(X - K * D))) elif Xa == 0: if K % 2 == 0: print((0)) else: print(D) elif Xm == 0: if K % 2 == 0: print(D) else: print((0)) elif (K - Xs) % 2 == 0: print((abs(Xm))) else: print((abs(D - Xm)))
Xa, K, D = list(map(int, input().split())) X = abs(Xa) Xs = X // D Xm = X % D if K < Xs: # print("A") print((abs(X - K * D))) elif Xa == 0: if K % 2 == 0: print((0)) else: print(D) elif Xm == 0: if K % 2 == 0: print(D) else: print((0)) elif (K - Xs) % 2 == 0: print((abs(Xm))) else: print((abs(D - Xm))) # else:
false
44.444444
[ "-import sys", "-import numpy as np", "-import math", "-import collections", "-import copy", "-from collections import deque", "-from functools import reduce", "-from itertools import product", "-from itertools import combinations", "-", "-# input = sys.stdin.readline", "+# else:" ]
false
0.079715
0.078965
1.009499
[ "s542187290", "s382822965" ]
u347600233
p02725
python
s849837730
s002827840
124
95
26,436
32,388
Accepted
Accepted
23.39
k, n = list(map(int, input().split())) a = [int(i) for i in input().split()] diff_a = [0] * n diff_a[0] = (a[0] + k) - a[n - 1] for i in range(1, n): diff_a[i] = a[i] - a[i - 1] print((k - max(diff_a)))
k, n = list(map(int, input().split())) a = list(map(int, input().split())) a += [k + a[0]] print((k - max([a[i + 1] - a[i] for i in range(n)])))
7
4
204
139
k, n = list(map(int, input().split())) a = [int(i) for i in input().split()] diff_a = [0] * n diff_a[0] = (a[0] + k) - a[n - 1] for i in range(1, n): diff_a[i] = a[i] - a[i - 1] print((k - max(diff_a)))
k, n = list(map(int, input().split())) a = list(map(int, input().split())) a += [k + a[0]] print((k - max([a[i + 1] - a[i] for i in range(n)])))
false
42.857143
[ "-a = [int(i) for i in input().split()]", "-diff_a = [0] * n", "-diff_a[0] = (a[0] + k) - a[n - 1]", "-for i in range(1, n):", "- diff_a[i] = a[i] - a[i - 1]", "-print((k - max(diff_a)))", "+a = list(map(int, input().split()))", "+a += [k + a[0]]", "+print((k - max([a[i + 1] - a[i] for i in range...
false
0.102587
0.03514
2.919372
[ "s849837730", "s002827840" ]
u905203728
p03007
python
s621014285
s378301265
350
185
69,028
96,956
Accepted
Accepted
47.14
n=int(eval(input())) A=sorted(list(map(int,input().split()))) XY=[] left,right=A[0],A[-1] for i in range(1,n-1): num=A[i] if num<0: XY.append([right,num]) right -=num else: XY.append([left,num]) left -=num XY.append([right,left]) print((right-left)) for x,y in XY:print((x,y))
from collections import deque n=int(eval(input())) A=sorted(list(map(int,input().split()))) A=deque(A) N=[] left,right=A.popleft(),A.pop() for i in A: if i<0: N.append([right,i]) right -=i else: N.append([left,i]) left -=i N.append([right,left]) print((right-left)) for i in N:print((*i))
16
17
326
335
n = int(eval(input())) A = sorted(list(map(int, input().split()))) XY = [] left, right = A[0], A[-1] for i in range(1, n - 1): num = A[i] if num < 0: XY.append([right, num]) right -= num else: XY.append([left, num]) left -= num XY.append([right, left]) print((right - left)) for x, y in XY: print((x, y))
from collections import deque n = int(eval(input())) A = sorted(list(map(int, input().split()))) A = deque(A) N = [] left, right = A.popleft(), A.pop() for i in A: if i < 0: N.append([right, i]) right -= i else: N.append([left, i]) left -= i N.append([right, left]) print((right - left)) for i in N: print((*i))
false
5.882353
[ "+from collections import deque", "+", "-XY = []", "-left, right = A[0], A[-1]", "-for i in range(1, n - 1):", "- num = A[i]", "- if num < 0:", "- XY.append([right, num])", "- right -= num", "+A = deque(A)", "+N = []", "+left, right = A.popleft(), A.pop()", "+for i in A:"...
false
0.039145
0.035844
1.092094
[ "s621014285", "s378301265" ]
u057109575
p03425
python
s981394432
s015647205
190
148
9,776
4,224
Accepted
Accepted
22.11
from itertools import combinations N = int(eval(input())) s = [eval(input()) for _ in range(N)] cnt = [sum(v[0] == c for v in s) for c in 'MARCH'] ans = sum(cnt[i] * cnt[j] * cnt[k] for i, j, k in combinations(list(range(5)), 3)) print(ans)
from itertools import combinations from collections import Counter N = int(eval(input())) cnt = Counter([input()[0] for _ in range(N)]) ans = sum(cnt[i] * cnt[j] * cnt[k] for i, j, k in combinations('MARCH', 3)) print(ans)
8
7
231
223
from itertools import combinations N = int(eval(input())) s = [eval(input()) for _ in range(N)] cnt = [sum(v[0] == c for v in s) for c in "MARCH"] ans = sum(cnt[i] * cnt[j] * cnt[k] for i, j, k in combinations(list(range(5)), 3)) print(ans)
from itertools import combinations from collections import Counter N = int(eval(input())) cnt = Counter([input()[0] for _ in range(N)]) ans = sum(cnt[i] * cnt[j] * cnt[k] for i, j, k in combinations("MARCH", 3)) print(ans)
false
12.5
[ "+from collections import Counter", "-s = [eval(input()) for _ in range(N)]", "-cnt = [sum(v[0] == c for v in s) for c in \"MARCH\"]", "-ans = sum(cnt[i] * cnt[j] * cnt[k] for i, j, k in combinations(list(range(5)), 3))", "+cnt = Counter([input()[0] for _ in range(N)])", "+ans = sum(cnt[i] * cnt[j] * cnt[...
false
0.103398
0.085783
1.205345
[ "s981394432", "s015647205" ]
u536034761
p03610
python
s398298577
s219704988
142
28
73,628
9,016
Accepted
Accepted
80.28
s = eval(input()) S ="" for i in range(0, len(s), 2): S += s[i] print(S)
s = eval(input()) print((s[::2]))
5
2
72
26
s = eval(input()) S = "" for i in range(0, len(s), 2): S += s[i] print(S)
s = eval(input()) print((s[::2]))
false
60
[ "-S = \"\"", "-for i in range(0, len(s), 2):", "- S += s[i]", "-print(S)", "+print((s[::2]))" ]
false
0.147193
0.107931
1.363764
[ "s398298577", "s219704988" ]
u785578220
p03045
python
s352547913
s966929151
501
301
12,780
11,140
Accepted
Accepted
39.92
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)] n,m = list(map(int,input().split())) par = [-1]*n for i in range(m): X,Y,Z = list(map(int,input().split())) unite(X-1,Y-1) tank = set([]) for i in range(n): tank.add(find(i)) print((len(tank)))
n,m = list(map(int,input().split())) par = [-1]*(n) def find(x): if par[x] < 0: return x else: par[x] = find(par[x]) #็ตŒ่ทฏๅœง็ธฎ return par[x] def same(x,y): return find(x) == find(y) def unite(x,y): x = find(x) y = find(y) if x == y: return 0 else: if par[x] > par[y]:x,y = y,x par[x] += par[y] par[y] = x def size(x): return -par[find(x)] for i in range(m): x,y,z = list(map(int,input().split())) unite(x-1,y-1) ans = 0 # print(par) for i in range(n): if par[i] <0: ans += 1 print(ans)
36
36
639
602
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)] n, m = list(map(int, input().split())) par = [-1] * n for i in range(m): X, Y, Z = list(map(int, input().split())) unite(X - 1, Y - 1) tank = set([]) for i in range(n): tank.add(find(i)) print((len(tank)))
n, m = list(map(int, input().split())) par = [-1] * (n) def find(x): if par[x] < 0: return x else: par[x] = find(par[x]) # ็ตŒ่ทฏๅœง็ธฎ return par[x] def same(x, y): return find(x) == find(y) def unite(x, y): x = find(x) y = find(y) if x == y: return 0 else: if par[x] > par[y]: x, y = y, x par[x] += par[y] par[y] = x def size(x): return -par[find(x)] for i in range(m): x, y, z = list(map(int, input().split())) unite(x - 1, y - 1) ans = 0 # print(par) for i in range(n): if par[i] < 0: ans += 1 print(ans)
false
0
[ "+n, m = list(map(int, input().split()))", "+par = [-1] * (n)", "+", "+", "- par[x] = find(par[x])", "+ par[x] = find(par[x]) # ็ตŒ่ทฏๅœง็ธฎ", "+", "+", "+def same(x, y):", "+ return find(x) == find(y)", "- return False", "+ return 0", "- return True", "-", ...
false
0.044209
0.041205
1.072924
[ "s352547913", "s966929151" ]
u912237403
p00118
python
s955092441
s860524256
90
80
6,608
6,608
Accepted
Accepted
11.11
def f(y,x,c0): M.append([y,x]) while M: y,x=M.pop() if A[y][x]==c0: A[y][x]=' ' for i,j in [[0,-1],[-1,0],[0,1],[1,0]]: M.append([y+i,x+j]) return 1 M=[] while 1: H,W=list(map(int,input().split())) if H==W==0: break A=[list(' '*(W+2)) for _ in range(H+2)] for i in range(H): A[i+1][1:W+1]=list(input()) c=0 for i in range(1,H+1): for j in range(1,W+1): c0=A[i][j] if c0!=' ': c+=f(i,j,c0) print(c)
def f(y,x,a): M.append([y,x]) while M: y,x=M.pop() if A[y][x]==a: A[y][x]=' ' for i,j in [[0,-1],[-1,0],[0,1],[1,0]]: M.append([y+i,x+j]) return 1 M=[] while 1: H,W=list(map(int,input().split())) if H==W==0: break A=[list(' '*(W+2)) for _ in range(H+2)] for i in range(H): A[i+1][1:W+1]=list(input()) c=0 for i in range(1,H+1): for j in range(1,W+1): a=A[i][j] if a!=' ': c+=f(i,j,a) print(c)
21
21
475
470
def f(y, x, c0): M.append([y, x]) while M: y, x = M.pop() if A[y][x] == c0: A[y][x] = " " for i, j in [[0, -1], [-1, 0], [0, 1], [1, 0]]: M.append([y + i, x + j]) return 1 M = [] while 1: H, W = list(map(int, input().split())) if H == W == 0: break A = [list(" " * (W + 2)) for _ in range(H + 2)] for i in range(H): A[i + 1][1 : W + 1] = list(input()) c = 0 for i in range(1, H + 1): for j in range(1, W + 1): c0 = A[i][j] if c0 != " ": c += f(i, j, c0) print(c)
def f(y, x, a): M.append([y, x]) while M: y, x = M.pop() if A[y][x] == a: A[y][x] = " " for i, j in [[0, -1], [-1, 0], [0, 1], [1, 0]]: M.append([y + i, x + j]) return 1 M = [] while 1: H, W = list(map(int, input().split())) if H == W == 0: break A = [list(" " * (W + 2)) for _ in range(H + 2)] for i in range(H): A[i + 1][1 : W + 1] = list(input()) c = 0 for i in range(1, H + 1): for j in range(1, W + 1): a = A[i][j] if a != " ": c += f(i, j, a) print(c)
false
0
[ "-def f(y, x, c0):", "+def f(y, x, a):", "- if A[y][x] == c0:", "+ if A[y][x] == a:", "- c0 = A[i][j]", "- if c0 != \" \":", "- c += f(i, j, c0)", "+ a = A[i][j]", "+ if a != \" \":", "+ c += f(i, j, a)" ]
false
0.044575
0.043235
1.030995
[ "s955092441", "s860524256" ]
u670180528
p03425
python
s114798110
s552578666
173
54
3,888
9,876
Accepted
Accepted
68.79
from itertools import combinations n = int(eval(input())) names = [input()[0] for _ in range(n)] li = [0]*5 for i,c in enumerate("MARCH"): cnt = 0 for name in names: if c == name: cnt += 1 li[i] = cnt ans = 0 for i,j,k in combinations(li,3): ans += i*j*k print(ans)
n,*name=open(0) n=int(n) l=[0]*5 for c in name: x=c[0] if x=="M": l[0]+=1 elif x=="A": l[1]+=1 elif x=="R": l[2]+=1 elif x=="C": l[3]+=1 elif x=="H": l[4]+=1 from itertools import combinations ans=0 for c in combinations(list(range(5)),3): ans+=l[c[0]]*l[c[1]]*l[c[2]] print(ans)
14
20
281
309
from itertools import combinations n = int(eval(input())) names = [input()[0] for _ in range(n)] li = [0] * 5 for i, c in enumerate("MARCH"): cnt = 0 for name in names: if c == name: cnt += 1 li[i] = cnt ans = 0 for i, j, k in combinations(li, 3): ans += i * j * k print(ans)
n, *name = open(0) n = int(n) l = [0] * 5 for c in name: x = c[0] if x == "M": l[0] += 1 elif x == "A": l[1] += 1 elif x == "R": l[2] += 1 elif x == "C": l[3] += 1 elif x == "H": l[4] += 1 from itertools import combinations ans = 0 for c in combinations(list(range(5)), 3): ans += l[c[0]] * l[c[1]] * l[c[2]] print(ans)
false
30
[ "+n, *name = open(0)", "+n = int(n)", "+l = [0] * 5", "+for c in name:", "+ x = c[0]", "+ if x == \"M\":", "+ l[0] += 1", "+ elif x == \"A\":", "+ l[1] += 1", "+ elif x == \"R\":", "+ l[2] += 1", "+ elif x == \"C\":", "+ l[3] += 1", "+ elif x =...
false
0.074204
0.036894
2.011289
[ "s114798110", "s552578666" ]
u564589929
p02691
python
s029044813
s068946007
164
151
40,548
40,544
Accepted
Accepted
7.93
import sys sys.setrecursionlimit(10 ** 6) # input = sys.stdin.readline #### def int1(x): return int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())) def LI1(): return list(map(int1, input().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def SI(): return input().split() def printlist(lst, k='\n'): print((k.join(list(map(str, lst))))) INF = float('inf') from math import ceil, floor, log2 from collections import deque from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product def solve(): n = II() A = LI() memo = {} ans = 0 for i in range(n): mae = (i+1) + A[i] ima = (i+1) - A[i] ans += memo.get(ima, 0) memo[mae] = memo.get(mae, 0) + 1 # print(memo) print(ans) if __name__ == '__main__': solve()
import sys sys.setrecursionlimit(10 ** 9) # input = sys.stdin.readline #### def int1(x): return int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())) def LI1(): return list(map(int1, input().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def MS(): return input().split() def LS(): return list(eval(input())) def LLS(rows_number): return [LS() for _ in range(rows_number)] def printlist(lst, k=' '): print((k.join(list(map(str, lst))))) INF = float('inf') # from math import ceil, floor, log2 # from collections import deque # from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations # from heapq import heapify, heappop, heappush # import numpy as np # cumsum # from bisect import bisect_left, bisect_right def solve(): N = II() A = LI() memo = {} ans = 0 for i, a in enumerate(A): i = i + 1 # print(i, a - i, i - a) ans = ans + memo.get(i - a, 0) memo[a + i] = memo.get(a + i, 0) + 1 print(ans) if __name__ == '__main__': solve()
40
38
1,013
1,243
import sys sys.setrecursionlimit(10**6) # input = sys.stdin.readline #### def int1(x): return int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())) def LI1(): return list(map(int1, input().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def SI(): return input().split() def printlist(lst, k="\n"): print((k.join(list(map(str, lst))))) INF = float("inf") from math import ceil, floor, log2 from collections import deque from itertools import ( combinations as comb, combinations_with_replacement as comb_w, accumulate, product, ) def solve(): n = II() A = LI() memo = {} ans = 0 for i in range(n): mae = (i + 1) + A[i] ima = (i + 1) - A[i] ans += memo.get(ima, 0) memo[mae] = memo.get(mae, 0) + 1 # print(memo) print(ans) if __name__ == "__main__": solve()
import sys sys.setrecursionlimit(10**9) # input = sys.stdin.readline #### def int1(x): return int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())) def LI1(): return list(map(int1, input().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def MS(): return input().split() def LS(): return list(eval(input())) def LLS(rows_number): return [LS() for _ in range(rows_number)] def printlist(lst, k=" "): print((k.join(list(map(str, lst))))) INF = float("inf") # from math import ceil, floor, log2 # from collections import deque # from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations # from heapq import heapify, heappop, heappush # import numpy as np # cumsum # from bisect import bisect_left, bisect_right def solve(): N = II() A = LI() memo = {} ans = 0 for i, a in enumerate(A): i = i + 1 # print(i, a - i, i - a) ans = ans + memo.get(i - a, 0) memo[a + i] = memo.get(a + i, 0) + 1 print(ans) if __name__ == "__main__": solve()
false
5
[ "-sys.setrecursionlimit(10**6)", "+sys.setrecursionlimit(10**9)", "-def SI():", "+def MS():", "-def printlist(lst, k=\"\\n\"):", "+def LS():", "+ return list(eval(input()))", "+", "+", "+def LLS(rows_number):", "+ return [LS() for _ in range(rows_number)]", "+", "+", "+def printlist(...
false
0.138833
0.073447
1.890257
[ "s029044813", "s068946007" ]
u525065967
p03637
python
s862010672
s399629077
74
61
11,480
11,100
Accepted
Accepted
17.57
# C - 4-adjacent _ = eval(input()) count1 = count4 = 0 not_exist2 = 1 for a in [int(x)%4 for x in input().split()]: if a==0: count4 += 1 elif a==2: not_exist2 = 0 else: count1 += 1 print(("Yes" if count1 <= count4 + not_exist2 else "No"))
# C - 4-adjacent n = int(eval(input())) count2 = count4 = 0 for a in [int(x)%4 for x in input().split()]: if a==0: count4 += 1 elif a==2: count2 += 1 print(("Yes" if n//2 <= count4 + count2//2 else "No"))
9
7
255
210
# C - 4-adjacent _ = eval(input()) count1 = count4 = 0 not_exist2 = 1 for a in [int(x) % 4 for x in input().split()]: if a == 0: count4 += 1 elif a == 2: not_exist2 = 0 else: count1 += 1 print(("Yes" if count1 <= count4 + not_exist2 else "No"))
# C - 4-adjacent n = int(eval(input())) count2 = count4 = 0 for a in [int(x) % 4 for x in input().split()]: if a == 0: count4 += 1 elif a == 2: count2 += 1 print(("Yes" if n // 2 <= count4 + count2 // 2 else "No"))
false
22.222222
[ "-_ = eval(input())", "-count1 = count4 = 0", "-not_exist2 = 1", "+n = int(eval(input()))", "+count2 = count4 = 0", "- not_exist2 = 0", "- else:", "- count1 += 1", "-print((\"Yes\" if count1 <= count4 + not_exist2 else \"No\"))", "+ count2 += 1", "+print((\"Yes\" if n // ...
false
0.046316
0.047108
0.983199
[ "s862010672", "s399629077" ]
u077291787
p03032
python
s036829482
s558145264
28
25
3,192
3,064
Accepted
Accepted
10.71
# ABC128D - equeue # exhaustive search def main(): N, K = tuple(map(int, input().rstrip().split())) V = tuple(map(int, input().rstrip().split())) lim = min(N, K) ans = set() for l in range(N + 1): for r in range(N + 1): if l + r > lim: break # picked jewels (l from left, r from right) cur = sorted(V[:l] + V[-r:]) if r != 0 else sorted(V[:l]) neg = sum(i < 0 for i in cur) rest = K - (l + r) # return unworthy ones as much as possible if neg > rest: ans |= {sum(cur[rest:])} else: ans |= {sum(i for i in cur if i >= 0)} print((max(ans))) if __name__ == "__main__": main()
# D - equeue def main(): N, K, *V = list(map(int, open(0).read().split())) lim = min(N, K) available_choices = set() for l in range(lim + 1): for r in range(lim + 1): if l + r > lim: break choice = V[:l] + V[-r:] if r else V[:l] cnt_negatives = sum(i < 0 for i in choice) cnt_rest = K - (l + r) if cnt_negatives > cnt_rest: choice.sort() available_choices.add(sum(choice[cnt_rest:])) else: available_choices.add(sum(i for i in choice if i > 0)) print((max(available_choices))) if __name__ == "__main__": main()
25
26
776
702
# ABC128D - equeue # exhaustive search def main(): N, K = tuple(map(int, input().rstrip().split())) V = tuple(map(int, input().rstrip().split())) lim = min(N, K) ans = set() for l in range(N + 1): for r in range(N + 1): if l + r > lim: break # picked jewels (l from left, r from right) cur = sorted(V[:l] + V[-r:]) if r != 0 else sorted(V[:l]) neg = sum(i < 0 for i in cur) rest = K - (l + r) # return unworthy ones as much as possible if neg > rest: ans |= {sum(cur[rest:])} else: ans |= {sum(i for i in cur if i >= 0)} print((max(ans))) if __name__ == "__main__": main()
# D - equeue def main(): N, K, *V = list(map(int, open(0).read().split())) lim = min(N, K) available_choices = set() for l in range(lim + 1): for r in range(lim + 1): if l + r > lim: break choice = V[:l] + V[-r:] if r else V[:l] cnt_negatives = sum(i < 0 for i in choice) cnt_rest = K - (l + r) if cnt_negatives > cnt_rest: choice.sort() available_choices.add(sum(choice[cnt_rest:])) else: available_choices.add(sum(i for i in choice if i > 0)) print((max(available_choices))) if __name__ == "__main__": main()
false
3.846154
[ "-# ABC128D - equeue", "-# exhaustive search", "+# D - equeue", "- N, K = tuple(map(int, input().rstrip().split()))", "- V = tuple(map(int, input().rstrip().split()))", "+ N, K, *V = list(map(int, open(0).read().split()))", "- ans = set()", "- for l in range(N + 1):", "- for r ...
false
0.047396
0.045786
1.035168
[ "s036829482", "s558145264" ]
u506858457
p02837
python
s633236205
s046121638
888
107
9,148
9,264
Accepted
Accepted
87.95
def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) N=II() shogens=[] for i in range(N): a=II() shogens.append([]) for j in range(a): x,y=MI() x-=1 shogens[-1].append((x,y)) def is_honest(i,j): return (i>>j)%2==1 def honest_cnt(i): ans=0 for j in range(N): ans+=is_honest(i,j) return ans ans=0 for i in range(1<<N): ok=True for j in range(N): if not is_honest(i,j): continue for (x,y) in shogens[j]: if y==0 and is_honest(i,x): ok=False if y==1 and not is_honest(i,x): ok=False if ok: ans=max(ans,honest_cnt(i)) print(ans)
def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) N=II() a=[0]*N x=[[0]*N for i in range(N)] y=[[0]*N for i in range(N)] for i in range(N): a[i]=II() for j in range(a[i]): x[i][j],y[i][j]=MI() x[i][j]-=1 def check(honest): for i in range(N): if not honest[i]: continue for j in range(a[i]): if y[i][j]==0 and honest[x[i][j]]: return False if y[i][j]==1 and not honest[x[i][j]]: return False return True def dfs(honest): if len(honest)==N: if check(honest): return sum(honest) else: return 0 return max(dfs(honest+[True]),dfs(honest+[False])) print((dfs([])))
32
29
658
689
def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) N = II() shogens = [] for i in range(N): a = II() shogens.append([]) for j in range(a): x, y = MI() x -= 1 shogens[-1].append((x, y)) def is_honest(i, j): return (i >> j) % 2 == 1 def honest_cnt(i): ans = 0 for j in range(N): ans += is_honest(i, j) return ans ans = 0 for i in range(1 << N): ok = True for j in range(N): if not is_honest(i, j): continue for (x, y) in shogens[j]: if y == 0 and is_honest(i, x): ok = False if y == 1 and not is_honest(i, x): ok = False if ok: ans = max(ans, honest_cnt(i)) print(ans)
def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) N = II() a = [0] * N x = [[0] * N for i in range(N)] y = [[0] * N for i in range(N)] for i in range(N): a[i] = II() for j in range(a[i]): x[i][j], y[i][j] = MI() x[i][j] -= 1 def check(honest): for i in range(N): if not honest[i]: continue for j in range(a[i]): if y[i][j] == 0 and honest[x[i][j]]: return False if y[i][j] == 1 and not honest[x[i][j]]: return False return True def dfs(honest): if len(honest) == N: if check(honest): return sum(honest) else: return 0 return max(dfs(honest + [True]), dfs(honest + [False])) print((dfs([])))
false
9.375
[ "-shogens = []", "+a = [0] * N", "+x = [[0] * N for i in range(N)]", "+y = [[0] * N for i in range(N)]", "- a = II()", "- shogens.append([])", "- for j in range(a):", "- x, y = MI()", "- x -= 1", "- shogens[-1].append((x, y))", "+ a[i] = II()", "+ for j in r...
false
0.03529
0.055263
0.638579
[ "s633236205", "s046121638" ]
u670180528
p04015
python
s608088283
s528462157
25
23
3,188
3,188
Accepted
Accepted
8
n,a=list(map(int,input().split())) y=[a-int(x) for x in input().split()] dp={0:1} for i in y: for k,v in list(dp.items()): dp[i+k]=dp.get(i+k,0)+v print((dp[0]-1))
def main(): n,a=list(map(int,input().split())) y=[a-int(x) for x in input().split()] dp={0:1} for i in y: for k,v in list(dp.items()): dp[i+k]=dp.get(i+k,0)+v print((dp[0]-1)) if __name__=="__main__": main()
7
10
164
219
n, a = list(map(int, input().split())) y = [a - int(x) for x in input().split()] dp = {0: 1} for i in y: for k, v in list(dp.items()): dp[i + k] = dp.get(i + k, 0) + v print((dp[0] - 1))
def main(): n, a = list(map(int, input().split())) y = [a - int(x) for x in input().split()] dp = {0: 1} for i in y: for k, v in list(dp.items()): dp[i + k] = dp.get(i + k, 0) + v print((dp[0] - 1)) if __name__ == "__main__": main()
false
30
[ "-n, a = list(map(int, input().split()))", "-y = [a - int(x) for x in input().split()]", "-dp = {0: 1}", "-for i in y:", "- for k, v in list(dp.items()):", "- dp[i + k] = dp.get(i + k, 0) + v", "-print((dp[0] - 1))", "+def main():", "+ n, a = list(map(int, input().split()))", "+ y ...
false
0.046151
0.043406
1.063243
[ "s608088283", "s528462157" ]
u934442292
p02803
python
s608506884
s459868185
456
152
3,532
9,388
Accepted
Accepted
66.67
import copy from collections import deque def bfs(H, W, maze, dist, sh, sw): queue = deque([[sh, sw]]) dist[sh][sw] = 0 while queue: h, w = queue.popleft() for i, j in [(1, 0), (-1, 0), (0, -1), (0, 1)]: next_h, next_w = h + i, w + j if not ((0 <= next_h <= H - 1) and (0 <= next_w <= W - 1)): continue if (maze[next_h][next_w] == ".") and (dist[next_h][next_w] == -1): dist[next_h][next_w] = dist[h][w] + 1 queue.append([next_h, next_w]) ret = 0 for i in range(H): tmp = max(dist[i]) if tmp > ret: ret = tmp return ret if __name__ == "__main__": H, W = list(map(int, input().split())) S = [eval(input()) for _ in range(H)] dist = [[-1 for _ in range(W)] for _ in range(H)] ans = 0 for sh in range(H): for sw in range(W): if S[sh][sw] == "#": continue d = copy.deepcopy(dist) max_move = bfs(H, W, S, d, sh, sw) if max_move > ans: ans = max_move print(ans)
import sys from collections import deque input = sys.stdin.readline def bfs(S, sh, sw, dist): dist[sh][sw] = 0 queue = deque([(sh, sw)]) while queue: h, w = queue.popleft() for i, j in ((0, 1), (0, -1), (1, 0), (-1, 0)): y, x = h + i, w + j if S[y][x] == "#": continue if dist[y][x] == -1: dist[y][x] = dist[h][w] + 1 queue.append((y, x)) def main(): H, W = list(map(int, input().split())) S = [None] * (H + 2) S[0] = S[-1] = "#" * (W + 2) for i in range(1, H + 1): S[i] = "".join(["#", input().rstrip(), "#"]) ans = 0 for sh in range(1, H + 1): for sw in range(1, W + 1): if S[sh][sw] == "#": continue dist = [[-1] * (W + 2) for _ in range(H + 2)] bfs(S, sh, sw, dist) max_dist = max(list(map(max, dist))) ans = max(ans, max_dist) print(ans) if __name__ == "__main__": main()
39
42
1,151
1,051
import copy from collections import deque def bfs(H, W, maze, dist, sh, sw): queue = deque([[sh, sw]]) dist[sh][sw] = 0 while queue: h, w = queue.popleft() for i, j in [(1, 0), (-1, 0), (0, -1), (0, 1)]: next_h, next_w = h + i, w + j if not ((0 <= next_h <= H - 1) and (0 <= next_w <= W - 1)): continue if (maze[next_h][next_w] == ".") and (dist[next_h][next_w] == -1): dist[next_h][next_w] = dist[h][w] + 1 queue.append([next_h, next_w]) ret = 0 for i in range(H): tmp = max(dist[i]) if tmp > ret: ret = tmp return ret if __name__ == "__main__": H, W = list(map(int, input().split())) S = [eval(input()) for _ in range(H)] dist = [[-1 for _ in range(W)] for _ in range(H)] ans = 0 for sh in range(H): for sw in range(W): if S[sh][sw] == "#": continue d = copy.deepcopy(dist) max_move = bfs(H, W, S, d, sh, sw) if max_move > ans: ans = max_move print(ans)
import sys from collections import deque input = sys.stdin.readline def bfs(S, sh, sw, dist): dist[sh][sw] = 0 queue = deque([(sh, sw)]) while queue: h, w = queue.popleft() for i, j in ((0, 1), (0, -1), (1, 0), (-1, 0)): y, x = h + i, w + j if S[y][x] == "#": continue if dist[y][x] == -1: dist[y][x] = dist[h][w] + 1 queue.append((y, x)) def main(): H, W = list(map(int, input().split())) S = [None] * (H + 2) S[0] = S[-1] = "#" * (W + 2) for i in range(1, H + 1): S[i] = "".join(["#", input().rstrip(), "#"]) ans = 0 for sh in range(1, H + 1): for sw in range(1, W + 1): if S[sh][sw] == "#": continue dist = [[-1] * (W + 2) for _ in range(H + 2)] bfs(S, sh, sw, dist) max_dist = max(list(map(max, dist))) ans = max(ans, max_dist) print(ans) if __name__ == "__main__": main()
false
7.142857
[ "-import copy", "+import sys", "+input = sys.stdin.readline", "-def bfs(H, W, maze, dist, sh, sw):", "- queue = deque([[sh, sw]])", "+", "+def bfs(S, sh, sw, dist):", "+ queue = deque([(sh, sw)])", "- for i, j in [(1, 0), (-1, 0), (0, -1), (0, 1)]:", "- next_h, next_w = h +...
false
0.086749
0.043973
1.972794
[ "s608506884", "s459868185" ]
u471797506
p03994
python
s732410836
s010119107
61
55
5,284
3,588
Accepted
Accepted
9.84
# -*- coding: utf-8 -*- import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll alpha = "abcdefghijklmnopqrstuvwxyz" s = input() K = int(input()) dic = dict([alpha[i], i] for i in range(len(alpha))) ans = [] for si in s: d = 26 - dic[si] if si != "a" else 0 if d <= K: ans.append("a") K -= d else: ans.append(si) if K > 0: ans[-1] = alpha[(dic[ans[-1]] + K) % 26] print("".join(ans))
s = list(input()) K = int(input()) for i in range(len(s)): if s[i] == 'a': continue d = ord('z') - ord(s[i]) + 1 if K >= d: s[i] = 'a' K -= d K %= 26 s[-1] = chr((ord(s[-1]) - ord('a') + K)%26 + ord('a')) print("".join(s))
22
13
486
264
# -*- coding: utf-8 -*- import sys, copy, math, heapq, itertools as it, fractions, re, bisect, collections as coll alpha = "abcdefghijklmnopqrstuvwxyz" s = input() K = int(input()) dic = dict([alpha[i], i] for i in range(len(alpha))) ans = [] for si in s: d = 26 - dic[si] if si != "a" else 0 if d <= K: ans.append("a") K -= d else: ans.append(si) if K > 0: ans[-1] = alpha[(dic[ans[-1]] + K) % 26] print("".join(ans))
s = list(input()) K = int(input()) for i in range(len(s)): if s[i] == "a": continue d = ord("z") - ord(s[i]) + 1 if K >= d: s[i] = "a" K -= d K %= 26 s[-1] = chr((ord(s[-1]) - ord("a") + K) % 26 + ord("a")) print("".join(s))
false
40.909091
[ "-# -*- coding: utf-8 -*-", "-import sys, copy, math, heapq, itertools as it, fractions, re, bisect, collections as coll", "-", "-alpha = \"abcdefghijklmnopqrstuvwxyz\"", "-s = input()", "+s = list(input())", "-dic = dict([alpha[i], i] for i in range(len(alpha)))", "-ans = []", "-for si in s:", "-...
false
0.036376
0.048041
0.757182
[ "s732410836", "s010119107" ]
u863370423
p03633
python
s773678020
s655226333
37
20
5,048
2,940
Accepted
Accepted
45.95
import fractions import functools def lcm(a,b): return a*b//fractions.gcd(a,b) n=int(eval(input())) t=[] for i in range(n): t.append(int(eval(input()))) ans=functools.reduce(lcm,t) print(ans)
def gcd(a, b): return gcd(b, a % b) if b else a n = int(eval(input())) ans = 1 for i in range(n): x = int(eval(input())) ans = ans * x // gcd(ans, x) print(ans)
12
9
194
160
import fractions import functools def lcm(a, b): return a * b // fractions.gcd(a, b) n = int(eval(input())) t = [] for i in range(n): t.append(int(eval(input()))) ans = functools.reduce(lcm, t) print(ans)
def gcd(a, b): return gcd(b, a % b) if b else a n = int(eval(input())) ans = 1 for i in range(n): x = int(eval(input())) ans = ans * x // gcd(ans, x) print(ans)
false
25
[ "-import fractions", "-import functools", "-", "-", "-def lcm(a, b):", "- return a * b // fractions.gcd(a, b)", "+def gcd(a, b):", "+ return gcd(b, a % b) if b else a", "-t = []", "+ans = 1", "- t.append(int(eval(input())))", "-ans = functools.reduce(lcm, t)", "+ x = int(eval(inp...
false
0.099529
0.053355
1.865422
[ "s773678020", "s655226333" ]
u156815136
p03951
python
s988548977
s285284412
50
43
5,660
10,384
Accepted
Accepted
14
from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)ใงๆœ€ๅคงใฎ2ๅ€‹ใจใ‚Šใ ใ›ใ‚‹ใŠ a[0][0] from fractions import gcd from itertools import combinations # (string,3) 3ๅ›ž from collections import deque from collections import defaultdict import bisect # # d = m - k[i] - k[j] # if kk[bisect.bisect_right(kk,d) - 1] == d: # # # # pythonใง็„ก็†ใชใจใใฏใ€pypyใงใ‚„ใ‚‹ใจๆญฃ่งฃใ™ใ‚‹ใ‹ใ‚‚๏ผ๏ผ # # import sys sys.setrecursionlimit(10000000) #mod = 10**9 + 7 mod = 9982443453 def readInts(): return list(map(int,input().split())) def I(): return int(eval(input())) n = int(eval(input())) s = eval(input()) t = eval(input()) cnt = 0 ans = 0 for i in range(len(s)): if s[i] == t[cnt]: cnt += 1 elif s[i] != t[cnt] and s[i] == t[0]: ans = max(ans,cnt) cnt = 1 else: ans = max(ans,cnt) cnt = 0 print((n + n - cnt))
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)ใงๆœ€ๅคงใฎ2ๅ€‹ใจใ‚Šใ ใ›ใ‚‹ใŠ a[0][0] from fractions import gcd from itertools import combinations,permutations,accumulate # (string,3) 3ๅ›ž #from collections import deque from collections import deque,defaultdict,Counter import decimal import re #import bisect # # d = m - k[i] - k[j] # if kk[bisect.bisect_right(kk,d) - 1] == d: # # # # pythonใง็„ก็†ใชใจใใฏใ€pypyใงใ‚„ใ‚‹ใจๆญฃ่งฃใ™ใ‚‹ใ‹ใ‚‚๏ผ๏ผ # # # my_round_int = lambda x:np.round((x*2 + 1)//2) # ๅ››ๆจไบ”ๅ…ฅ import sys sys.setrecursionlimit(10000000) mod = 10**9 + 7 #mod = 9982443453 def readInts(): return list(map(int,input().split())) def I(): return int(eval(input())) n = I() s = eval(input()) t = eval(input()) same = 0 for i in range(n): #print(s[n-i-1:], t[:i+1]) if s[n-i-1:] == t[:i+1]: same = i+1 print((len(s) + len(t) - same))
41
38
891
900
from statistics import median # import collections # aa = collections.Counter(a) # list to list || .most_common(2)ใงๆœ€ๅคงใฎ2ๅ€‹ใจใ‚Šใ ใ›ใ‚‹ใŠ a[0][0] from fractions import gcd from itertools import combinations # (string,3) 3ๅ›ž from collections import deque from collections import defaultdict import bisect # # d = m - k[i] - k[j] # if kk[bisect.bisect_right(kk,d) - 1] == d: # # # # pythonใง็„ก็†ใชใจใใฏใ€pypyใงใ‚„ใ‚‹ใจๆญฃ่งฃใ™ใ‚‹ใ‹ใ‚‚๏ผ๏ผ # # import sys sys.setrecursionlimit(10000000) # mod = 10**9 + 7 mod = 9982443453 def readInts(): return list(map(int, input().split())) def I(): return int(eval(input())) n = int(eval(input())) s = eval(input()) t = eval(input()) cnt = 0 ans = 0 for i in range(len(s)): if s[i] == t[cnt]: cnt += 1 elif s[i] != t[cnt] and s[i] == t[0]: ans = max(ans, cnt) cnt = 1 else: ans = max(ans, cnt) cnt = 0 print((n + n - cnt))
# from statistics import median # import collections # aa = collections.Counter(a) # list to list || .most_common(2)ใงๆœ€ๅคงใฎ2ๅ€‹ใจใ‚Šใ ใ›ใ‚‹ใŠ a[0][0] from fractions import gcd from itertools import combinations, permutations, accumulate # (string,3) 3ๅ›ž # from collections import deque from collections import deque, defaultdict, Counter import decimal import re # import bisect # # d = m - k[i] - k[j] # if kk[bisect.bisect_right(kk,d) - 1] == d: # # # # pythonใง็„ก็†ใชใจใใฏใ€pypyใงใ‚„ใ‚‹ใจๆญฃ่งฃใ™ใ‚‹ใ‹ใ‚‚๏ผ๏ผ # # # my_round_int = lambda x:np.round((x*2 + 1)//2) # ๅ››ๆจไบ”ๅ…ฅ import sys sys.setrecursionlimit(10000000) mod = 10**9 + 7 # mod = 9982443453 def readInts(): return list(map(int, input().split())) def I(): return int(eval(input())) n = I() s = eval(input()) t = eval(input()) same = 0 for i in range(n): # print(s[n-i-1:], t[:i+1]) if s[n - i - 1 :] == t[: i + 1]: same = i + 1 print((len(s) + len(t) - same))
false
7.317073
[ "-from statistics import median", "-", "+# from statistics import median", "-from itertools import combinations # (string,3) 3ๅ›ž", "-from collections import deque", "-from collections import defaultdict", "-import bisect", "+from itertools import combinations, permutations, accumulate # (string,3) 3ๅ›ž...
false
0.038581
0.116078
0.332368
[ "s988548977", "s285284412" ]
u893063840
p02683
python
s893278221
s554495385
151
107
27,232
28,224
Accepted
Accepted
29.14
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline import numpy as np from itertools import product n, m, x = list(map(int, readline().split())) ca = np.array(read().split(), np.int64).reshape((n, m + 1)) INF = 10 ** 9 c = ca[:, 0] a = ca[:, 1:].T ans = INF for p_li in product([1, 0], repeat=n): p = np.array(p_li) rikai = a * p sm = rikai.sum(axis=1) if sm.min() >= x: cost = (c * p).sum() ans = min(ans, cost) if ans == INF: ans = -1 print(ans)
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline import numpy as np from itertools import product n, m, x = list(map(int, readline().split())) ca = np.array(read().split(), np.int64).reshape((n, m + 1)) INF = 10 ** 9 c = ca[:, 0] a = ca[:, 1:] p = np.array([e for e in product([1, 0], repeat=n)], np.int64) rikai = np.dot(p, a) cost = np.dot(p, c) idx = rikai.min(axis=1) >= x if idx.any(): ans = cost[idx].min() else: ans = -1 print(ans)
27
24
536
497
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline import numpy as np from itertools import product n, m, x = list(map(int, readline().split())) ca = np.array(read().split(), np.int64).reshape((n, m + 1)) INF = 10**9 c = ca[:, 0] a = ca[:, 1:].T ans = INF for p_li in product([1, 0], repeat=n): p = np.array(p_li) rikai = a * p sm = rikai.sum(axis=1) if sm.min() >= x: cost = (c * p).sum() ans = min(ans, cost) if ans == INF: ans = -1 print(ans)
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline import numpy as np from itertools import product n, m, x = list(map(int, readline().split())) ca = np.array(read().split(), np.int64).reshape((n, m + 1)) INF = 10**9 c = ca[:, 0] a = ca[:, 1:] p = np.array([e for e in product([1, 0], repeat=n)], np.int64) rikai = np.dot(p, a) cost = np.dot(p, c) idx = rikai.min(axis=1) >= x if idx.any(): ans = cost[idx].min() else: ans = -1 print(ans)
false
11.111111
[ "-a = ca[:, 1:].T", "-ans = INF", "-for p_li in product([1, 0], repeat=n):", "- p = np.array(p_li)", "- rikai = a * p", "- sm = rikai.sum(axis=1)", "- if sm.min() >= x:", "- cost = (c * p).sum()", "- ans = min(ans, cost)", "-if ans == INF:", "+a = ca[:, 1:]", "+p = np...
false
0.6167
0.256689
2.402522
[ "s893278221", "s554495385" ]
u537976628
p02848
python
s861109878
s485541481
23
21
3,060
3,060
Accepted
Accepted
8.7
n = int(eval(input())) s = eval(input()) ns ='' for i in range(len(s)): if ord(s[i]) + n < 91: ns += chr(ord(s[i]) + n) else: ns += chr(ord(s[i]) + n - 26) print(ns)
n = int(eval(input())) s = eval(input()) ns ='' for i in range(len(s)): ns += chr((ord(s[i]) - 65 + n) % 26 + 65) print(ns)
9
6
185
120
n = int(eval(input())) s = eval(input()) ns = "" for i in range(len(s)): if ord(s[i]) + n < 91: ns += chr(ord(s[i]) + n) else: ns += chr(ord(s[i]) + n - 26) print(ns)
n = int(eval(input())) s = eval(input()) ns = "" for i in range(len(s)): ns += chr((ord(s[i]) - 65 + n) % 26 + 65) print(ns)
false
33.333333
[ "- if ord(s[i]) + n < 91:", "- ns += chr(ord(s[i]) + n)", "- else:", "- ns += chr(ord(s[i]) + n - 26)", "+ ns += chr((ord(s[i]) - 65 + n) % 26 + 65)" ]
false
0.03889
0.038851
1.000995
[ "s861109878", "s485541481" ]
u493520238
p03032
python
s157324541
s739382654
84
75
74,108
73,776
Accepted
Accepted
10.71
from bisect import bisect_left, bisect_right n,k = list(map(int, input().split())) vl = list(map(int, input().split())) ans = 0 for get_num in range(0,k+1): rem = k-get_num for l in range(0,get_num+1): r = get_num-l if l+r > n: continue ls = vl[:l] rs = vl[n-r:] curr_l = ls + rs curr_l.sort() minus_cnt = bisect_left(curr_l, 0) if minus_cnt <= rem: curr_ans = sum(curr_l[minus_cnt:]) ans = max(curr_ans,ans) else: curr_ans = sum(curr_l[rem:]) ans = max(curr_ans,ans) print(ans)
n,k = list(map(int, input().split())) vl = list(map(int, input().split())) ans = 0 ab_max = min(n,k) for l in range(ab_max+1): for r in range(ab_max+1): if l+r > k: continue if l > n-r: continue ls = vl[:l] rs = vl[n-r:] # print(ls,rs) vals = ls + rs rem = k-(l+r) # print(rem) vals.sort() curr_sum = sum(vals) for i in range(rem): if i >= len(vals): break if vals[i] < 0: curr_sum -= vals[i] else: break # print(curr_sum) ans = max(ans,curr_sum) print(ans)
24
26
626
635
from bisect import bisect_left, bisect_right n, k = list(map(int, input().split())) vl = list(map(int, input().split())) ans = 0 for get_num in range(0, k + 1): rem = k - get_num for l in range(0, get_num + 1): r = get_num - l if l + r > n: continue ls = vl[:l] rs = vl[n - r :] curr_l = ls + rs curr_l.sort() minus_cnt = bisect_left(curr_l, 0) if minus_cnt <= rem: curr_ans = sum(curr_l[minus_cnt:]) ans = max(curr_ans, ans) else: curr_ans = sum(curr_l[rem:]) ans = max(curr_ans, ans) print(ans)
n, k = list(map(int, input().split())) vl = list(map(int, input().split())) ans = 0 ab_max = min(n, k) for l in range(ab_max + 1): for r in range(ab_max + 1): if l + r > k: continue if l > n - r: continue ls = vl[:l] rs = vl[n - r :] # print(ls,rs) vals = ls + rs rem = k - (l + r) # print(rem) vals.sort() curr_sum = sum(vals) for i in range(rem): if i >= len(vals): break if vals[i] < 0: curr_sum -= vals[i] else: break # print(curr_sum) ans = max(ans, curr_sum) print(ans)
false
7.692308
[ "-from bisect import bisect_left, bisect_right", "-", "-for get_num in range(0, k + 1):", "- rem = k - get_num", "- for l in range(0, get_num + 1):", "- r = get_num - l", "- if l + r > n:", "+ab_max = min(n, k)", "+for l in range(ab_max + 1):", "+ for r in range(ab_max + 1):...
false
0.036218
0.08628
0.419774
[ "s157324541", "s739382654" ]
u673981655
p03160
python
s457331794
s648101623
235
124
52,208
13,928
Accepted
Accepted
47.23
n = int(eval(input())) h = list(map(int, input().split())) dp = [float('inf')]*n dp[0] = 0 dp[1] = dp[0]+abs(h[1]-h[0]) for i in range(2, n): dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2])) print((dp[n-1]))
n = int(eval(input())) h = list(map(int, input().split())) dp = [float('inf')]*n dp[0] = 0 dp[1] = dp[0]+abs(h[0]-h[1]) for i in range(2, n): dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2])) print((dp[-1]))
12
11
231
230
n = int(eval(input())) h = list(map(int, input().split())) dp = [float("inf")] * n dp[0] = 0 dp[1] = dp[0] + abs(h[1] - h[0]) for i in range(2, n): dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])) print((dp[n - 1]))
n = int(eval(input())) h = list(map(int, input().split())) dp = [float("inf")] * n dp[0] = 0 dp[1] = dp[0] + abs(h[0] - h[1]) for i in range(2, n): dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])) print((dp[-1]))
false
8.333333
[ "-dp[1] = dp[0] + abs(h[1] - h[0])", "+dp[1] = dp[0] + abs(h[0] - h[1])", "-print((dp[n - 1]))", "+print((dp[-1]))" ]
false
0.04534
0.045157
1.004056
[ "s457331794", "s648101623" ]
u729133443
p02726
python
s940511590
s992176558
1,427
1,260
3,444
3,444
Accepted
Accepted
11.7
n,x,y=list(map(int,input().split())) l=[0]*~-n for i in range(1,n): for j in range(i):l[min(~j+i,abs(~j+x)+abs(~i+y))]+=1 print((*l))
n,x,y=list(map(int,input().split())) c=[0]*~-n for i in range(n): for j in range(i):c[min(~j+i,abs(~j+x)+abs(~i+y))]+=1 print((*c))
5
5
130
128
n, x, y = list(map(int, input().split())) l = [0] * ~-n for i in range(1, n): for j in range(i): l[min(~j + i, abs(~j + x) + abs(~i + y))] += 1 print((*l))
n, x, y = list(map(int, input().split())) c = [0] * ~-n for i in range(n): for j in range(i): c[min(~j + i, abs(~j + x) + abs(~i + y))] += 1 print((*c))
false
0
[ "-l = [0] * ~-n", "-for i in range(1, n):", "+c = [0] * ~-n", "+for i in range(n):", "- l[min(~j + i, abs(~j + x) + abs(~i + y))] += 1", "-print((*l))", "+ c[min(~j + i, abs(~j + x) + abs(~i + y))] += 1", "+print((*c))" ]
false
0.043406
0.108466
0.400181
[ "s940511590", "s992176558" ]
u172773620
p03636
python
s878448024
s234705136
19
17
2,940
2,940
Accepted
Accepted
10.53
s = eval(input()) s_s = s[0] s_e = s[-1] s = s[1:-1] nw = s_s + str(len(s)) + s_e print(nw)
s = eval(input()) w = s[0]+str(len(s[:-2]))+s[-1] print(w)
7
3
92
54
s = eval(input()) s_s = s[0] s_e = s[-1] s = s[1:-1] nw = s_s + str(len(s)) + s_e print(nw)
s = eval(input()) w = s[0] + str(len(s[:-2])) + s[-1] print(w)
false
57.142857
[ "-s_s = s[0]", "-s_e = s[-1]", "-s = s[1:-1]", "-nw = s_s + str(len(s)) + s_e", "-print(nw)", "+w = s[0] + str(len(s[:-2])) + s[-1]", "+print(w)" ]
false
0.063229
0.06808
0.928741
[ "s878448024", "s234705136" ]
u875291233
p02624
python
s447255362
s445110102
171
28
63,260
9,448
Accepted
Accepted
83.63
# coding: utf-8 # Your code here! import sys read = sys.stdin.read readline = sys.stdin.readline n, = list(map(int,readline().split())) ans = 0 for i in range(1,n+1): ans += (i+i*(n//i))*(n//i)//2 print(ans)
def F(N): r = int(N**0.5) # x >= 10^9 ใฎใจใใฏๆณจๆ„ ans = 0 for d in range(1,N//r+1): ans += d*(1+(N//d))*(N//d)//2 #print(ans) for c in range(1,r): a = N//(c+1) b = N//c """ (a,b] ไธŠใง d ใฎๅ’Œใ‚’ๆฑ‚ใ‚ใ‚‹ """ s = b*(b+1)//2-a*(a+1)//2 ans += s*(c*c+c)//2 #ans %= MOD return ans # coding: utf-8 # Your code here! import sys read = sys.stdin.read readline = sys.stdin.readline n, = list(map(int,readline().split())) print((F(n)))
12
30
219
538
# coding: utf-8 # Your code here! import sys read = sys.stdin.read readline = sys.stdin.readline (n,) = list(map(int, readline().split())) ans = 0 for i in range(1, n + 1): ans += (i + i * (n // i)) * (n // i) // 2 print(ans)
def F(N): r = int(N**0.5) # x >= 10^9 ใฎใจใใฏๆณจๆ„ ans = 0 for d in range(1, N // r + 1): ans += d * (1 + (N // d)) * (N // d) // 2 # print(ans) for c in range(1, r): a = N // (c + 1) b = N // c """ (a,b] ไธŠใง d ใฎๅ’Œใ‚’ๆฑ‚ใ‚ใ‚‹ """ s = b * (b + 1) // 2 - a * (a + 1) // 2 ans += s * (c * c + c) // 2 # ans %= MOD return ans # coding: utf-8 # Your code here! import sys read = sys.stdin.read readline = sys.stdin.readline (n,) = list(map(int, readline().split())) print((F(n)))
false
60
[ "+def F(N):", "+ r = int(N**0.5) # x >= 10^9 ใฎใจใใฏๆณจๆ„", "+ ans = 0", "+ for d in range(1, N // r + 1):", "+ ans += d * (1 + (N // d)) * (N // d) // 2", "+ # print(ans)", "+ for c in range(1, r):", "+ a = N // (c + 1)", "+ b = N // c", "+ \"\"\"", "+ ...
false
0.006217
0.045169
0.137633
[ "s447255362", "s445110102" ]
u546285759
p00009
python
s830504892
s969064627
1,400
400
22,984
23,108
Accepted
Accepted
71.43
primes = [0, 0] + [1]*999999 for i in range(2, 1001): if primes[i]: for j in range(i*i, 1000001, i): primes[j] = 0 while True: try: data = int(eval(input())) except: break print((sum(1 for i in range(data, 1, -1) if primes[i])))
import bisect primes = [0, 0] + [1]*999999 for i in range(2, 1001): if primes[i]: for j in range(i*i, 1000001, i): primes[j] = 0 primes = [i for i, v in enumerate(primes) if v] while True: try: n = int(eval(input())) except: break print((len(primes[:bisect.bisect(primes, n)])))
11
14
282
336
primes = [0, 0] + [1] * 999999 for i in range(2, 1001): if primes[i]: for j in range(i * i, 1000001, i): primes[j] = 0 while True: try: data = int(eval(input())) except: break print((sum(1 for i in range(data, 1, -1) if primes[i])))
import bisect primes = [0, 0] + [1] * 999999 for i in range(2, 1001): if primes[i]: for j in range(i * i, 1000001, i): primes[j] = 0 primes = [i for i, v in enumerate(primes) if v] while True: try: n = int(eval(input())) except: break print((len(primes[: bisect.bisect(primes, n)])))
false
21.428571
[ "+import bisect", "+", "+primes = [i for i, v in enumerate(primes) if v]", "- data = int(eval(input()))", "+ n = int(eval(input()))", "- print((sum(1 for i in range(data, 1, -1) if primes[i])))", "+ print((len(primes[: bisect.bisect(primes, n)])))" ]
false
0.422913
2.052796
0.206018
[ "s830504892", "s969064627" ]
u392029857
p03611
python
s523639870
s974113843
101
80
14,564
13,964
Accepted
Accepted
20.79
from collections import Counter N = int(eval(input())) A = Counter(list(map(int, input().split()))) cnt = 0 for i in A: sums = A[i] + A[i+1] + A[i+2] if sums > cnt: cnt = sums print(cnt)
N = int(eval(input())) a = list(map(int, input().split())) x = [0]*((10**5) + 2) for i in a: x[i+1] += 1 x[i] += 1 x[i+2] += 1 print((max(x)))
9
8
205
153
from collections import Counter N = int(eval(input())) A = Counter(list(map(int, input().split()))) cnt = 0 for i in A: sums = A[i] + A[i + 1] + A[i + 2] if sums > cnt: cnt = sums print(cnt)
N = int(eval(input())) a = list(map(int, input().split())) x = [0] * ((10**5) + 2) for i in a: x[i + 1] += 1 x[i] += 1 x[i + 2] += 1 print((max(x)))
false
11.111111
[ "-from collections import Counter", "-", "-A = Counter(list(map(int, input().split())))", "-cnt = 0", "-for i in A:", "- sums = A[i] + A[i + 1] + A[i + 2]", "- if sums > cnt:", "- cnt = sums", "-print(cnt)", "+a = list(map(int, input().split()))", "+x = [0] * ((10**5) + 2)", "+for...
false
0.041782
0.046769
0.893366
[ "s523639870", "s974113843" ]
u298297089
p03835
python
s039520599
s977527616
1,284
245
3,060
40,940
Accepted
Accepted
80.92
K,S = list(map(int,input().split())) ans = 0 for i in range(K+1): if i > K: break for j in range(K+1): if 0 <= S - i - j <= K: ans += 1 print(ans)
k,s = list(map(int, input().split())) ans = 0 for i in range(k+1): for j in range(k+1): if 0 <= s - i - j <= k: ans += 1 print(ans)
9
7
184
156
K, S = list(map(int, input().split())) ans = 0 for i in range(K + 1): if i > K: break for j in range(K + 1): if 0 <= S - i - j <= K: ans += 1 print(ans)
k, s = list(map(int, input().split())) ans = 0 for i in range(k + 1): for j in range(k + 1): if 0 <= s - i - j <= k: ans += 1 print(ans)
false
22.222222
[ "-K, S = list(map(int, input().split()))", "+k, s = list(map(int, input().split()))", "-for i in range(K + 1):", "- if i > K:", "- break", "- for j in range(K + 1):", "- if 0 <= S - i - j <= K:", "+for i in range(k + 1):", "+ for j in range(k + 1):", "+ if 0 <= s - i ...
false
0.072252
0.050586
1.428293
[ "s039520599", "s977527616" ]
u190405389
p02711
python
s231657339
s711446210
67
60
61,752
61,688
Accepted
Accepted
10.45
print((['No','Yes']['7'in eval(input())]))
print(('NYoe s'['7'in eval(input())::2]))
1
1
35
33
print((["No", "Yes"]["7" in eval(input())]))
print(("NYoe s"["7" in eval(input()) :: 2]))
false
0
[ "-print(([\"No\", \"Yes\"][\"7\" in eval(input())]))", "+print((\"NYoe s\"[\"7\" in eval(input()) :: 2]))" ]
false
0.051694
0.052909
0.977034
[ "s231657339", "s711446210" ]
u791091424
p02947
python
s587448085
s307292401
1,021
657
120,452
73,176
Accepted
Accepted
35.65
n = int(eval(input())) arr = [eval(input()) for _ in range(n)] dict = {} alpha = "abcdefghijklmnopqrstuvwxyz" for s in arr: count = [0]*26 for i in range(10): for j in range(26): if s[i] == alpha[j]: count[j] += 1 break count = tuple(count) if count not in dict: dict[count] = 1 else: dict[count] += 1 ans = 0 for val in list(dict.values()): ans += val * ( val - 1 ) / 2 print((int(ans)))
n = int(eval(input())) arr = [eval(input()) for _ in range(n)] ans_dict = {} for s in arr: samp = sorted(s) tmp = "" for i in samp: tmp = tmp + i if tmp in ans_dict: ans_dict[tmp] += 1 else: ans_dict[tmp] = 1 ans = 0 for i in list(ans_dict.values()): ans += i * ( i - 1) / 2 print(( int(ans) ))
21
19
482
347
n = int(eval(input())) arr = [eval(input()) for _ in range(n)] dict = {} alpha = "abcdefghijklmnopqrstuvwxyz" for s in arr: count = [0] * 26 for i in range(10): for j in range(26): if s[i] == alpha[j]: count[j] += 1 break count = tuple(count) if count not in dict: dict[count] = 1 else: dict[count] += 1 ans = 0 for val in list(dict.values()): ans += val * (val - 1) / 2 print((int(ans)))
n = int(eval(input())) arr = [eval(input()) for _ in range(n)] ans_dict = {} for s in arr: samp = sorted(s) tmp = "" for i in samp: tmp = tmp + i if tmp in ans_dict: ans_dict[tmp] += 1 else: ans_dict[tmp] = 1 ans = 0 for i in list(ans_dict.values()): ans += i * (i - 1) / 2 print((int(ans)))
false
9.52381
[ "-dict = {}", "-alpha = \"abcdefghijklmnopqrstuvwxyz\"", "+ans_dict = {}", "- count = [0] * 26", "- for i in range(10):", "- for j in range(26):", "- if s[i] == alpha[j]:", "- count[j] += 1", "- break", "- count = tuple(count)", "- if c...
false
0.037169
0.036122
1.028981
[ "s587448085", "s307292401" ]
u801049006
p02796
python
s896692338
s928289283
513
325
42,792
25,516
Accepted
Accepted
36.65
n = int(eval(input())) xl = [list(map(int, input().split())) for _ in range(n)] le = [[p[0]-p[1], p[0]+p[1]] for p in xl] le.sort(key = lambda x : x[1]) ans = 0 right = -(10 ** 9) - 1 for i in range(n): if right <= le[i][0]: ans += 1 right = le[i][1] print(ans)
n = int(eval(input())) ls = [] for _ in range(n): x, l = list(map(int, input().split())) ls.append([x-l, x+l]) ls.sort(key=lambda x: x[1]) ans = n for i in range(1, n): if ls[i][0] < ls[i-1][1]: ls[i][1] = ls[i-1][1] ans -= 1 print(ans)
13
14
289
268
n = int(eval(input())) xl = [list(map(int, input().split())) for _ in range(n)] le = [[p[0] - p[1], p[0] + p[1]] for p in xl] le.sort(key=lambda x: x[1]) ans = 0 right = -(10**9) - 1 for i in range(n): if right <= le[i][0]: ans += 1 right = le[i][1] print(ans)
n = int(eval(input())) ls = [] for _ in range(n): x, l = list(map(int, input().split())) ls.append([x - l, x + l]) ls.sort(key=lambda x: x[1]) ans = n for i in range(1, n): if ls[i][0] < ls[i - 1][1]: ls[i][1] = ls[i - 1][1] ans -= 1 print(ans)
false
7.142857
[ "-xl = [list(map(int, input().split())) for _ in range(n)]", "-le = [[p[0] - p[1], p[0] + p[1]] for p in xl]", "-le.sort(key=lambda x: x[1])", "-ans = 0", "-right = -(10**9) - 1", "-for i in range(n):", "- if right <= le[i][0]:", "- ans += 1", "- right = le[i][1]", "+ls = []", "...
false
0.040992
0.066537
0.616077
[ "s896692338", "s928289283" ]
u800058906
p03544
python
s938555095
s055072864
29
26
9,176
9,172
Accepted
Accepted
10.34
N=int(eval(input())) lst=[2,1] for i in range(2,N+1): lst.append(lst[i-1]+lst[i-2]) print((lst[N]))
N=int(eval(input())) lucas=[2,1] for i in range(2,N+1): lucas.append(lucas[i-1]+lucas[i-2]) print((lucas[N]))
5
6
99
111
N = int(eval(input())) lst = [2, 1] for i in range(2, N + 1): lst.append(lst[i - 1] + lst[i - 2]) print((lst[N]))
N = int(eval(input())) lucas = [2, 1] for i in range(2, N + 1): lucas.append(lucas[i - 1] + lucas[i - 2]) print((lucas[N]))
false
16.666667
[ "-lst = [2, 1]", "+lucas = [2, 1]", "- lst.append(lst[i - 1] + lst[i - 2])", "-print((lst[N]))", "+ lucas.append(lucas[i - 1] + lucas[i - 2])", "+print((lucas[N]))" ]
false
0.134625
0.089521
1.503837
[ "s938555095", "s055072864" ]
u057109575
p03495
python
s125521916
s922306270
239
95
39,352
32,572
Accepted
Accepted
60.25
from collections import Counter N, K = list(map(int, input().split())) A = list(map(int, input().split())) c = Counter(A).most_common() c.sort(key=lambda x: -x[1]) ans = 0 while len(c) > K: ans += c.pop()[1] print(ans)
from collections import Counter N, K = list(map(int, input().split())) A = list(map(int, input().split())) print((sum(sorted(Counter(A).values())[:-K])))
10
4
226
148
from collections import Counter N, K = list(map(int, input().split())) A = list(map(int, input().split())) c = Counter(A).most_common() c.sort(key=lambda x: -x[1]) ans = 0 while len(c) > K: ans += c.pop()[1] print(ans)
from collections import Counter N, K = list(map(int, input().split())) A = list(map(int, input().split())) print((sum(sorted(Counter(A).values())[:-K])))
false
60
[ "-c = Counter(A).most_common()", "-c.sort(key=lambda x: -x[1])", "-ans = 0", "-while len(c) > K:", "- ans += c.pop()[1]", "-print(ans)", "+print((sum(sorted(Counter(A).values())[:-K])))" ]
false
0.03195
0.07243
0.441113
[ "s125521916", "s922306270" ]
u790710233
p03732
python
s102845343
s216585450
499
304
3,316
3,316
Accepted
Accepted
39.08
from collections import defaultdict n, W = map(int, input().split()) dd = defaultdict(list) for i in range(n): weight, value = map(int, input().split()) dd[weight].append(value) for k in dd.keys(): dd[k].sort(reverse=True) a = min(dd.keys()) b, c, d = a+1, a+2, a+3 ans = 0 for w in range(len(dd[a])+1): for x in range(len(dd[b])+1): for y in range(len(dd[c])+1): for z in range(len(dd[d])+1): if W < a*w+b*x+c*y+d*z: continue val = sum(dd[a][:w])+sum(dd[b][:x]) + \ sum(dd[c][:y])+sum(dd[d][:z]) ans = max(ans, val) print(ans)
from collections import defaultdict n, W = list(map(int, input().split())) dd = defaultdict(list) for i in range(n): weight, value = list(map(int, input().split())) dd[weight].append(value) a = min(dd.keys()) b, c, d = a+1, a+2, a+3 Vcum = defaultdict(lambda: [0]) for k in [a, b, c, d]: s = 0 dd[k].sort(reverse=True) for val in dd[k]: s += val Vcum[k].append(s) ans = 0 for w in range(len(dd[a])+1): for x in range(len(dd[b])+1): for y in range(len(dd[c])+1): for z in range(len(dd[d])+1): if W < a*w+b*x+c*y+d*z: continue val = Vcum[a][w]+Vcum[b][x]+Vcum[c][y]+Vcum[d][z] ans = max(ans, val) print(ans)
23
27
676
750
from collections import defaultdict n, W = map(int, input().split()) dd = defaultdict(list) for i in range(n): weight, value = map(int, input().split()) dd[weight].append(value) for k in dd.keys(): dd[k].sort(reverse=True) a = min(dd.keys()) b, c, d = a + 1, a + 2, a + 3 ans = 0 for w in range(len(dd[a]) + 1): for x in range(len(dd[b]) + 1): for y in range(len(dd[c]) + 1): for z in range(len(dd[d]) + 1): if W < a * w + b * x + c * y + d * z: continue val = sum(dd[a][:w]) + sum(dd[b][:x]) + sum(dd[c][:y]) + sum(dd[d][:z]) ans = max(ans, val) print(ans)
from collections import defaultdict n, W = list(map(int, input().split())) dd = defaultdict(list) for i in range(n): weight, value = list(map(int, input().split())) dd[weight].append(value) a = min(dd.keys()) b, c, d = a + 1, a + 2, a + 3 Vcum = defaultdict(lambda: [0]) for k in [a, b, c, d]: s = 0 dd[k].sort(reverse=True) for val in dd[k]: s += val Vcum[k].append(s) ans = 0 for w in range(len(dd[a]) + 1): for x in range(len(dd[b]) + 1): for y in range(len(dd[c]) + 1): for z in range(len(dd[d]) + 1): if W < a * w + b * x + c * y + d * z: continue val = Vcum[a][w] + Vcum[b][x] + Vcum[c][y] + Vcum[d][z] ans = max(ans, val) print(ans)
false
14.814815
[ "-n, W = map(int, input().split())", "+n, W = list(map(int, input().split()))", "- weight, value = map(int, input().split())", "+ weight, value = list(map(int, input().split()))", "-for k in dd.keys():", "- dd[k].sort(reverse=True)", "+Vcum = defaultdict(lambda: [0])", "+for k in [a, b, c, d]...
false
0.065085
0.039559
1.645255
[ "s102845343", "s216585450" ]
u976225138
p03598
python
s537437414
s249639555
30
26
9,048
9,100
Accepted
Accepted
13.33
_ = eval(input()) k = int(eval(input())) x = [int(x) for x in input().split()] ans = 0 for i in x: ans += min(i, k - i) * 2 else: print(ans)
_ = eval(input()) k = int(eval(input())) x = [int(x) for x in input().split()] ans = 0 for i in x: ans += min(i, k - i) else: print((ans * 2))
9
9
145
145
_ = eval(input()) k = int(eval(input())) x = [int(x) for x in input().split()] ans = 0 for i in x: ans += min(i, k - i) * 2 else: print(ans)
_ = eval(input()) k = int(eval(input())) x = [int(x) for x in input().split()] ans = 0 for i in x: ans += min(i, k - i) else: print((ans * 2))
false
0
[ "- ans += min(i, k - i) * 2", "+ ans += min(i, k - i)", "- print(ans)", "+ print((ans * 2))" ]
false
0.033405
0.032349
1.032653
[ "s537437414", "s249639555" ]