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
u814265211
p03543
python
s245025930
s119469061
166
29
38,384
9,016
Accepted
Accepted
82.53
s = eval(input()) cnt = 1 prev = '' for c in s: if prev == c: cnt += 1 else: cnt = 1 if cnt >= 3: print('Yes') exit() prev = c print('No')
s = eval(input()) if s[0] == s[1] == s[2] or s[1] == s[2] == s[3]: print('Yes') else: print('No')
16
5
202
103
s = eval(input()) cnt = 1 prev = "" for c in s: if prev == c: cnt += 1 else: cnt = 1 if cnt >= 3: print("Yes") exit() prev = c print("No")
s = eval(input()) if s[0] == s[1] == s[2] or s[1] == s[2] == s[3]: print("Yes") else: print("No")
false
68.75
[ "-cnt = 1", "-prev = \"\"", "-for c in s:", "- if prev == c:", "- cnt += 1", "- else:", "- cnt = 1", "- if cnt >= 3:", "- print(\"Yes\")", "- exit()", "- prev = c", "-print(\"No\")", "+if s[0] == s[1] == s[2] or s[1] == s[2] == s[3]:", "+ print(\"...
false
0.111695
0.046068
2.424592
[ "s245025930", "s119469061" ]
u656341025
p02996
python
s700190757
s612636709
1,065
957
41,240
41,240
Accepted
Accepted
10.14
N = int(eval(input())) res = 'Yes' A = [[0 for j in range(2)] for i in range(N)] for i in range(N): A[i][0], A[i][1] = list(map(int, input().split(' '))) A.sort(key=lambda x: x[1]) A.append([0, 0]) total = 0 i = 0 while i < N: while True: total += A[i][0] if A[i][1] != A[i + 1][1]: break ...
N = int(eval(input())) A_B = [[0 for _ in range(2)] for _ in range(N)] total = 0 res = 'Yes' for i in range(N): A_B[i][0], A_B[i][1] = list(map(int, input().split(' '))) A_B.sort(key=lambda x: x[1]) for i in range(N): total += A_B[i][0] if total > A_B[i][1]: res = 'No' break print(res)
20
13
391
300
N = int(eval(input())) res = "Yes" A = [[0 for j in range(2)] for i in range(N)] for i in range(N): A[i][0], A[i][1] = list(map(int, input().split(" "))) A.sort(key=lambda x: x[1]) A.append([0, 0]) total = 0 i = 0 while i < N: while True: total += A[i][0] if A[i][1] != A[i + 1][1]: b...
N = int(eval(input())) A_B = [[0 for _ in range(2)] for _ in range(N)] total = 0 res = "Yes" for i in range(N): A_B[i][0], A_B[i][1] = list(map(int, input().split(" "))) A_B.sort(key=lambda x: x[1]) for i in range(N): total += A_B[i][0] if total > A_B[i][1]: res = "No" break print(res)
false
35
[ "+A_B = [[0 for _ in range(2)] for _ in range(N)]", "+total = 0", "-A = [[0 for j in range(2)] for i in range(N)]", "- A[i][0], A[i][1] = list(map(int, input().split(\" \")))", "-A.sort(key=lambda x: x[1])", "-A.append([0, 0])", "-total = 0", "-i = 0", "-while i < N:", "- while True:", "- ...
false
0.066781
0.066594
1.002807
[ "s700190757", "s612636709" ]
u802963389
p03325
python
s792883354
s852555219
102
90
4,148
4,148
Accepted
Accepted
11.76
N = int(eval(input())) a = list(map(int, input().split())) cnt = 0 for i in a: num = i while num % 2 == 0: cnt += 1 num /= 2 print(cnt)
# C - *3 or /2 # https://atcoder.jp/contests/abc100/tasks/abc100_c n = int(eval(input())) A = list(map(int, input().split())) ans = 0 for a in A: while a % 2 == 0: a //= 2 ans += 1 print(ans)
9
13
149
210
N = int(eval(input())) a = list(map(int, input().split())) cnt = 0 for i in a: num = i while num % 2 == 0: cnt += 1 num /= 2 print(cnt)
# C - *3 or /2 # https://atcoder.jp/contests/abc100/tasks/abc100_c n = int(eval(input())) A = list(map(int, input().split())) ans = 0 for a in A: while a % 2 == 0: a //= 2 ans += 1 print(ans)
false
30.769231
[ "-N = int(eval(input()))", "-a = list(map(int, input().split()))", "-cnt = 0", "-for i in a:", "- num = i", "- while num % 2 == 0:", "- cnt += 1", "- num /= 2", "-print(cnt)", "+# C - *3 or /2", "+# https://atcoder.jp/contests/abc100/tasks/abc100_c", "+n = int(eval(input())...
false
0.033912
0.058697
0.577748
[ "s792883354", "s852555219" ]
u057109575
p02996
python
s543957016
s594602368
1,713
579
91,864
112,588
Accepted
Accepted
66.2
N = int(eval(input())) X = [list(map(int, input().split())) for _ in range(N)] X.sort(key=lambda x: (x[1], x[0])) cnt = 0 for a, b in X: if cnt + a <= b: cnt += a else: print('No') break else: print('Yes')
N = int(eval(input())) X = [list(map(int, input().split())) for _ in range(N)] X.sort(key=lambda x: x[1]) t = 0 ans = "No" for a, b in X: if t + a > b: break t += a else: ans = "Yes" print(ans)
13
14
249
223
N = int(eval(input())) X = [list(map(int, input().split())) for _ in range(N)] X.sort(key=lambda x: (x[1], x[0])) cnt = 0 for a, b in X: if cnt + a <= b: cnt += a else: print("No") break else: print("Yes")
N = int(eval(input())) X = [list(map(int, input().split())) for _ in range(N)] X.sort(key=lambda x: x[1]) t = 0 ans = "No" for a, b in X: if t + a > b: break t += a else: ans = "Yes" print(ans)
false
7.142857
[ "-X.sort(key=lambda x: (x[1], x[0]))", "-cnt = 0", "+X.sort(key=lambda x: x[1])", "+t = 0", "+ans = \"No\"", "- if cnt + a <= b:", "- cnt += a", "- else:", "- print(\"No\")", "+ if t + a > b:", "+ t += a", "- print(\"Yes\")", "+ ans = \"Yes\"", "+print(ans)"...
false
0.035757
0.042516
0.84102
[ "s543957016", "s594602368" ]
u060793972
p02732
python
s842232850
s428704073
1,588
235
38,040
38,044
Accepted
Accepted
85.2
import math from collections import Counter def mycounter(d,i): if i in d: d[i]+=1 else: d[i]=1 return d def ABC159D(a): if a<2: return 0 else: return math.factorial(a)//math.factorial(a-2)//2 n=int(eval(input())) a=list(map(int,input().split()...
import math from collections import Counter def mycounter(d,i): if i in d: d[i]+=1 else: d[i]=1 return d def ABC159D(a): if a<2: return 0 else: return (a*(a-1))//2 n=int(eval(input())) a=list(map(int,input().split())) d = dict() #for i in a: ...
26
26
483
454
import math from collections import Counter def mycounter(d, i): if i in d: d[i] += 1 else: d[i] = 1 return d def ABC159D(a): if a < 2: return 0 else: return math.factorial(a) // math.factorial(a - 2) // 2 n = int(eval(input())) a = list(map(int, input().split()...
import math from collections import Counter def mycounter(d, i): if i in d: d[i] += 1 else: d[i] = 1 return d def ABC159D(a): if a < 2: return 0 else: return (a * (a - 1)) // 2 n = int(eval(input())) a = list(map(int, input().split())) d = dict() # for i in a: #...
false
0
[ "- return math.factorial(a) // math.factorial(a - 2) // 2", "+ return (a * (a - 1)) // 2" ]
false
0.038231
0.042426
0.901121
[ "s842232850", "s428704073" ]
u980322611
p02936
python
s876003835
s289268033
1,232
1,073
88,396
130,372
Accepted
Accepted
12.91
def main(): from collections import defaultdict from collections import deque import sys input = sys.stdin.readline dd = defaultdict(list) pq = defaultdict(int) N, Q = list(map(int, input().split())) for _ in range(N-1): a,b = list(map(int, input().split())) ...
def main(): from collections import defaultdict from collections import deque import sys input = sys.stdin.readline dd = defaultdict(list) pq = defaultdict(int) N, Q = list(map(int, input().split())) for _ in range(N-1): a,b = list(map(int, input().split())) ...
33
38
749
886
def main(): from collections import defaultdict from collections import deque import sys input = sys.stdin.readline dd = defaultdict(list) pq = defaultdict(int) N, Q = list(map(int, input().split())) for _ in range(N - 1): a, b = list(map(int, input().split())) dd[a].app...
def main(): from collections import defaultdict from collections import deque import sys input = sys.stdin.readline dd = defaultdict(list) pq = defaultdict(int) N, Q = list(map(int, input().split())) for _ in range(N - 1): a, b = list(map(int, input().split())) dd[a].app...
false
13.157895
[ "+ dd[b].append(a)", "+ visited = {}", "+ visited[1] = 1", "- queue.append(i)", "- answer[i - 1] += answer[tmp - 1]", "+ if not i in visited:", "+ visited[i] = 1", "+ queue.append(i)", "+ answer[i - 1] += answ...
false
0.09797
0.120812
0.810928
[ "s876003835", "s289268033" ]
u690536347
p02995
python
s960215590
s019692508
35
32
5,048
9,180
Accepted
Accepted
8.57
from fractions import gcd A, B, C, D = list(map(int, input().split())) E = (C*D)//gcd(C, D) a = B//C-(A-1)//C b = B//D-(A-1)//D c = B//E-(A-1)//E print((B-A+1-a-b+c))
from math import gcd A, B, C, D = list(map(int, input().split())) E = C*D//gcd(C, D) c1 = (B//C)-((A+C-1)//C)+1 c2 = (B//D)-((A+D-1)//D)+1 c3 = (B//E)-((A+E-1)//E)+1 ans = B-A+1-c1-c2+c3 print(ans)
9
10
168
203
from fractions import gcd A, B, C, D = list(map(int, input().split())) E = (C * D) // gcd(C, D) a = B // C - (A - 1) // C b = B // D - (A - 1) // D c = B // E - (A - 1) // E print((B - A + 1 - a - b + c))
from math import gcd A, B, C, D = list(map(int, input().split())) E = C * D // gcd(C, D) c1 = (B // C) - ((A + C - 1) // C) + 1 c2 = (B // D) - ((A + D - 1) // D) + 1 c3 = (B // E) - ((A + E - 1) // E) + 1 ans = B - A + 1 - c1 - c2 + c3 print(ans)
false
10
[ "-from fractions import gcd", "+from math import gcd", "-E = (C * D) // gcd(C, D)", "-a = B // C - (A - 1) // C", "-b = B // D - (A - 1) // D", "-c = B // E - (A - 1) // E", "-print((B - A + 1 - a - b + c))", "+E = C * D // gcd(C, D)", "+c1 = (B // C) - ((A + C - 1) // C) + 1", "+c2 = (B // D) - (...
false
0.047991
0.047124
1.018409
[ "s960215590", "s019692508" ]
u703950586
p02722
python
s266196839
s786631168
425
123
47,960
70,888
Accepted
Accepted
71.06
import sys,math,copy,queue,itertools,bisect NI = lambda : int(sys.stdin.readline()) INF = 10**18 N = NI() if N == 2: print((1)) exit (0) ans = 0 max_b = int(math.log(N,2)) for x in range(2,int(math.sqrt(N-1))+1): if (N-1) % x == 0: if (N-1) == x**2: ans += 1 else: ...
import sys,queue,math,copy,itertools,bisect,collections,heapq def main(): NI = lambda : int(sys.stdin.readline()) N = NI() max_i = int(math.log2(N)) div = [] for i in range(1,int(math.sqrt(N))+1): if N % i == 0: div.append((i,N//i)); div.append((N//i,i)) ans = ...
32
28
817
770
import sys, math, copy, queue, itertools, bisect NI = lambda: int(sys.stdin.readline()) INF = 10**18 N = NI() if N == 2: print((1)) exit(0) ans = 0 max_b = int(math.log(N, 2)) for x in range(2, int(math.sqrt(N - 1)) + 1): if (N - 1) % x == 0: if (N - 1) == x**2: ans += 1 else: ...
import sys, queue, math, copy, itertools, bisect, collections, heapq def main(): NI = lambda: int(sys.stdin.readline()) N = NI() max_i = int(math.log2(N)) div = [] for i in range(1, int(math.sqrt(N)) + 1): if N % i == 0: div.append((i, N // i)) div.append((N // i, i...
false
12.5
[ "-import sys, math, copy, queue, itertools, bisect", "+import sys, queue, math, copy, itertools, bisect, collections, heapq", "-NI = lambda: int(sys.stdin.readline())", "-INF = 10**18", "-N = NI()", "-if N == 2:", "- print((1))", "- exit(0)", "-ans = 0", "-max_b = int(math.log(N, 2))", "-f...
false
0.123276
0.100017
1.232555
[ "s266196839", "s786631168" ]
u673361376
p03013
python
s603631723
s397192941
590
189
468,676
7,832
Accepted
Accepted
67.97
MOD_NUM = 1000000007 N, M = list(map(int, input().split())) alist = [int(eval(input())) for _ in range(M)] cases = [1] + [0 for _ in range(N)] for a in alist:cases[a] = None for i in range(1,N+1): if cases[i] is None:continue if cases[i-1] is not None:cases[i] += cases[i-1] if i >= 2 and cases[i-2] is ...
MOD = 10 ** 9 + 7 N, M = list(map(int, input().split())) A = [True for _ in range(N+1)] for _ in range(M): A[int(eval(input()))] = False dp = [1 for _ in range(N + 1)] for i in range(1, N+1): if A[i] == True: if i - 2 >= 0: dp[i] = (dp[i-1] + dp[i-2]) % MOD else: ...
11
16
368
389
MOD_NUM = 1000000007 N, M = list(map(int, input().split())) alist = [int(eval(input())) for _ in range(M)] cases = [1] + [0 for _ in range(N)] for a in alist: cases[a] = None for i in range(1, N + 1): if cases[i] is None: continue if cases[i - 1] is not None: cases[i] += cases[i - 1] if ...
MOD = 10**9 + 7 N, M = list(map(int, input().split())) A = [True for _ in range(N + 1)] for _ in range(M): A[int(eval(input()))] = False dp = [1 for _ in range(N + 1)] for i in range(1, N + 1): if A[i] == True: if i - 2 >= 0: dp[i] = (dp[i - 1] + dp[i - 2]) % MOD else: dp...
false
31.25
[ "-MOD_NUM = 1000000007", "+MOD = 10**9 + 7", "-alist = [int(eval(input())) for _ in range(M)]", "-cases = [1] + [0 for _ in range(N)]", "-for a in alist:", "- cases[a] = None", "+A = [True for _ in range(N + 1)]", "+for _ in range(M):", "+ A[int(eval(input()))] = False", "+dp = [1 for _ in r...
false
0.041664
0.095201
0.437642
[ "s603631723", "s397192941" ]
u813098295
p03244
python
s706626361
s653301352
131
117
20,968
20,916
Accepted
Accepted
10.69
n = int(eval(input())) v = list(map(int, input().split())) d1, d2 = {}, {} for i, a in enumerate(v): if i % 2 == 0: d1[a] = d1.get(a, 0) + 1 if i % 2 == 1: d2[a] = d2.get(a, 0) + 1 d1[-1] = 0 d2[-1] = 0 s = (sorted(list(d1.items()), key=lambda x: x[1], reverse=True)) t = (so...
n = int(eval(input())) v = list(map(int, input().split())) d1, d2 = {}, {} for i, a in enumerate(v): if i % 2 == 0: d1[a] = d1.get(a, 0) + 1 else: d2[a] = d2.get(a, 0) + 1 d1[-1] = 0 d2[-1] = 0 s = (sorted(list(d1.items()), key=lambda x: -x[1])) t = (sorted(list(d2.items()), k...
23
21
499
440
n = int(eval(input())) v = list(map(int, input().split())) d1, d2 = {}, {} for i, a in enumerate(v): if i % 2 == 0: d1[a] = d1.get(a, 0) + 1 if i % 2 == 1: d2[a] = d2.get(a, 0) + 1 d1[-1] = 0 d2[-1] = 0 s = sorted(list(d1.items()), key=lambda x: x[1], reverse=True) t = sorted(list(d2.items()), k...
n = int(eval(input())) v = list(map(int, input().split())) d1, d2 = {}, {} for i, a in enumerate(v): if i % 2 == 0: d1[a] = d1.get(a, 0) + 1 else: d2[a] = d2.get(a, 0) + 1 d1[-1] = 0 d2[-1] = 0 s = sorted(list(d1.items()), key=lambda x: -x[1]) t = sorted(list(d2.items()), key=lambda x: -x[1]) if...
false
8.695652
[ "- if i % 2 == 1:", "+ else:", "-s = sorted(list(d1.items()), key=lambda x: x[1], reverse=True)", "-t = sorted(list(d2.items()), key=lambda x: x[1], reverse=True)", "-# print (s)", "-# print (t)", "+s = sorted(list(d1.items()), key=lambda x: -x[1])", "+t = sorted(list(d2.items()), key=lambda x: ...
false
0.084386
0.034606
2.438453
[ "s706626361", "s653301352" ]
u682997551
p03730
python
s998800837
s921084317
40
17
5,348
2,940
Accepted
Accepted
57.5
import fractions A, B, C = list(map(int, input().split())) gcd = fractions.gcd(A, B) if gcd == 1 and C != 0 or gcd != 1 and fractions.gcd(gcd, C) != 1: print('YES') else: print('NO')
import sys A, B, C = list(map(int, input().split())) for i in range(1, B+1): if (A * i) % B == C: print('YES') sys.exit() print('NO')
9
10
194
159
import fractions A, B, C = list(map(int, input().split())) gcd = fractions.gcd(A, B) if gcd == 1 and C != 0 or gcd != 1 and fractions.gcd(gcd, C) != 1: print("YES") else: print("NO")
import sys A, B, C = list(map(int, input().split())) for i in range(1, B + 1): if (A * i) % B == C: print("YES") sys.exit() print("NO")
false
10
[ "-import fractions", "+import sys", "-gcd = fractions.gcd(A, B)", "-if gcd == 1 and C != 0 or gcd != 1 and fractions.gcd(gcd, C) != 1:", "- print(\"YES\")", "-else:", "- print(\"NO\")", "+for i in range(1, B + 1):", "+ if (A * i) % B == C:", "+ print(\"YES\")", "+ sys.exit...
false
0.08429
0.007068
11.92621
[ "s998800837", "s921084317" ]
u729133443
p02930
python
s010563297
s921094602
129
57
2,820
2,820
Accepted
Accepted
55.81
n=eval(input()) while n: n-=1 for j in range(n):print(-~bin(j+1)[::-1].find('1'))
n=eval(input()) while n: n-=1 for j in range(n):print((j+1&~j).bit_length())
4
4
78
73
n = eval(input()) while n: n -= 1 for j in range(n): print(-~bin(j + 1)[::-1].find("1"))
n = eval(input()) while n: n -= 1 for j in range(n): print((j + 1 & ~j).bit_length())
false
0
[ "- print(-~bin(j + 1)[::-1].find(\"1\"))", "+ print((j + 1 & ~j).bit_length())" ]
false
0.045937
0.104561
0.43933
[ "s010563297", "s921094602" ]
u079022693
p03449
python
s159171842
s520211477
23
17
3,064
3,064
Accepted
Accepted
26.09
from sys import stdin def main(): #入力 readline=stdin.readline N=int(readline()) A=[] for i in range(2): li=list(map(int,readline().split())) A.append(li) up=[0]*N up[0]=A[0][0] down=[0]*N down[-1]=A[1][-1] for i in range(1,N): up[i]+=up...
from sys import stdin def main(): #入力 readline=stdin.readline n=int(readline()) a=list(map(int,readline().split())) b=list(map(int,readline().split())) for i in range(1,n): a[i]+=a[i-1] for i in range(n-2,-1,-1): b[i]+=b[i+1] ans=0 for i in range(n): ...
27
20
536
406
from sys import stdin def main(): # 入力 readline = stdin.readline N = int(readline()) A = [] for i in range(2): li = list(map(int, readline().split())) A.append(li) up = [0] * N up[0] = A[0][0] down = [0] * N down[-1] = A[1][-1] for i in range(1, N): up[i...
from sys import stdin def main(): # 入力 readline = stdin.readline n = int(readline()) a = list(map(int, readline().split())) b = list(map(int, readline().split())) for i in range(1, n): a[i] += a[i - 1] for i in range(n - 2, -1, -1): b[i] += b[i + 1] ans = 0 for i in...
false
25.925926
[ "- N = int(readline())", "- A = []", "- for i in range(2):", "- li = list(map(int, readline().split()))", "- A.append(li)", "- up = [0] * N", "- up[0] = A[0][0]", "- down = [0] * N", "- down[-1] = A[1][-1]", "- for i in range(1, N):", "- up[i] += up[i...
false
0.041354
0.042107
0.982131
[ "s159171842", "s520211477" ]
u914797917
p03338
python
s308537426
s881704060
19
17
3,064
3,060
Accepted
Accepted
10.53
N=int(eval(input())) S=list(eval(input())) a=[] b=[] max=0 for i in range(1,(N)): a=[] b=[] for j in range(i): #print(i,j,S[j]) a.append(S[j]) #print(a,len(set(a))) for j in range(i,N): #print(i,j,S[j]) b.append(S[j]) #print(b,len(set(b))) if len(set(a)&set(b))>max: ...
N=int(eval(input())) S=list(eval(input())) max=0 for i in range(1,(N)): a=S[:i] b=S[i:] L= len(set(a)&set(b)) if L>max: max=L print(max)
21
12
344
149
N = int(eval(input())) S = list(eval(input())) a = [] b = [] max = 0 for i in range(1, (N)): a = [] b = [] for j in range(i): # print(i,j,S[j]) a.append(S[j]) # print(a,len(set(a))) for j in range(i, N): # print(i,j,S[j]) b.append(S[j]) # print(b,len(set(b))) ...
N = int(eval(input())) S = list(eval(input())) max = 0 for i in range(1, (N)): a = S[:i] b = S[i:] L = len(set(a) & set(b)) if L > max: max = L print(max)
false
42.857143
[ "-a = []", "-b = []", "- a = []", "- b = []", "- for j in range(i):", "- # print(i,j,S[j])", "- a.append(S[j])", "- # print(a,len(set(a)))", "- for j in range(i, N):", "- # print(i,j,S[j])", "- b.append(S[j])", "- # print(b,len(set(b)))", "- i...
false
0.046938
0.047592
0.986247
[ "s308537426", "s881704060" ]
u581187895
p02937
python
s380374968
s716386993
162
135
8,044
7,904
Accepted
Accepted
16.67
from collections import defaultdict from bisect import bisect_left S = input().rstrip() T = input().rstrip() LS = len(S) index = defaultdict(list) for i, s in enumerate(S): index[s].append(i) x = -1 for t in T: arr = index[t] if len(arr) == 0: print((-1)) exit() y = (x+1)%LS i...
from collections import defaultdict from bisect import * S = input().rstrip() T = input().rstrip() LS = len(S) index = defaultdict(list) for i, s in enumerate(S): index[s].append(i) x = -1 loop = 0 for t in T: arr = index[t] if len(arr) == 0: print((-1)) exit() i = bisect(a...
27
27
477
425
from collections import defaultdict from bisect import bisect_left S = input().rstrip() T = input().rstrip() LS = len(S) index = defaultdict(list) for i, s in enumerate(S): index[s].append(i) x = -1 for t in T: arr = index[t] if len(arr) == 0: print((-1)) exit() y = (x + 1) % LS i =...
from collections import defaultdict from bisect import * S = input().rstrip() T = input().rstrip() LS = len(S) index = defaultdict(list) for i, s in enumerate(S): index[s].append(i) x = -1 loop = 0 for t in T: arr = index[t] if len(arr) == 0: print((-1)) exit() i = bisect(arr, x) if...
false
0
[ "-from bisect import bisect_left", "+from bisect import *", "+loop = 0", "- y = (x + 1) % LS", "- i = bisect_left(arr, y)", "- if i < len(arr):", "- next_x = (x + 1) + arr[i] - y", "+ i = bisect(arr, x)", "+ if i == len(arr):", "+ loop += 1", "+ x = arr[0]", ...
false
0.125663
0.048949
2.56721
[ "s380374968", "s716386993" ]
u796942881
p03127
python
s066608959
s876916622
174
66
14,252
14,652
Accepted
Accepted
62.07
N = int(eval(input())) A = [int(i) for i in input().split()] A.sort() num = 0 if N == A.count(A[0]): num = 1 else: l = A x = [] while True: x = [] x.append(l[0]) for i in range(1, len(l)): if 0 < l[i] % l[0]: x.append(l[i] % l[0])...
from functools import reduce def gcd(a, b): while b: a, b = b, a % b return a def gcd_n(numbers): return reduce(gcd, numbers) def main(): N, *A = list(map(int, open(0).read().split())) print((gcd_n(A))) return main()
28
20
435
268
N = int(eval(input())) A = [int(i) for i in input().split()] A.sort() num = 0 if N == A.count(A[0]): num = 1 else: l = A x = [] while True: x = [] x.append(l[0]) for i in range(1, len(l)): if 0 < l[i] % l[0]: x.append(l[i] % l[0]) if len(x) == ...
from functools import reduce def gcd(a, b): while b: a, b = b, a % b return a def gcd_n(numbers): return reduce(gcd, numbers) def main(): N, *A = list(map(int, open(0).read().split())) print((gcd_n(A))) return main()
false
28.571429
[ "-N = int(eval(input()))", "-A = [int(i) for i in input().split()]", "-A.sort()", "-num = 0", "-if N == A.count(A[0]):", "- num = 1", "-else:", "- l = A", "- x = []", "- while True:", "- x = []", "- x.append(l[0])", "- for i in range(1, len(l)):", "- ...
false
0.03525
0.057187
0.616406
[ "s066608959", "s876916622" ]
u730769327
p02559
python
s478435501
s790727674
1,136
1,044
158,168
151,856
Accepted
Accepted
8.1
def segfunc(x,y):return x+y ide_ele=0 class segtree(): def __init__(self,init_val,segfunc=segfunc,ide_ele=ide_ele): n=len(init_val) self.segfunc=segfunc self.ide_ele=ide_ele self.num=1<<(n-1).bit_length() self.tree=[ide_ele]*2*self.num for i in range(n): self.tree[self.num+i]=i...
class binaryindexedtree(): def __init__(self,n): self.n=n self.tree=[0]*n def add(self,a,w): x=a while x<=self.n: self.tree[x-1]+=w x+=x&(-x) def sums(self,a): x=a S=0 while x!=0: S+=self.tree[x-1] x-=x&(-x) return S n,q=map(int,input().split...
40
27
1,078
573
def segfunc(x, y): return x + y ide_ele = 0 class segtree: def __init__(self, init_val, segfunc=segfunc, ide_ele=ide_ele): n = len(init_val) self.segfunc = segfunc self.ide_ele = ide_ele self.num = 1 << (n - 1).bit_length() self.tree = [ide_ele] * 2 * self.num ...
class binaryindexedtree: def __init__(self, n): self.n = n self.tree = [0] * n def add(self, a, w): x = a while x <= self.n: self.tree[x - 1] += w x += x & (-x) def sums(self, a): x = a S = 0 while x != 0: S += sel...
false
32.5
[ "-def segfunc(x, y):", "- return x + y", "+class binaryindexedtree:", "+ def __init__(self, n):", "+ self.n = n", "+ self.tree = [0] * n", "+ def add(self, a, w):", "+ x = a", "+ while x <= self.n:", "+ self.tree[x - 1] += w", "+ x += x ...
false
0.032988
0.037144
0.888096
[ "s478435501", "s790727674" ]
u562935282
p03017
python
s801101554
s870109597
188
20
40,560
3,572
Accepted
Accepted
89.36
N, A, B, C, D = list(map(int, input().split())) A -= 1 B -= 1 C -= 1 D -= 1 s = eval(input()) for i in range(A + 1, C - 2 + 1): if s[i] == '#' and s[i + 1] == '#': print('No') exit() for i in range(B + 1, D - 2 + 1): if s[i] == '#' and s[i + 1] == '#': print('No') ...
def solve(): if '##' in s[a:c + 1] or '##' in s[b:d + 1]: return False if b < c < d: return True # sfsf if c < b < d: return True # ssff return '...' in s[b - 1:d + 2] # sffs n, a, b, c, d = list(map(int, input().split())) a -= 1 b -= 1 c -= 1 d -= 1 s = eva...
40
19
783
356
N, A, B, C, D = list(map(int, input().split())) A -= 1 B -= 1 C -= 1 D -= 1 s = eval(input()) for i in range(A + 1, C - 2 + 1): if s[i] == "#" and s[i + 1] == "#": print("No") exit() for i in range(B + 1, D - 2 + 1): if s[i] == "#" and s[i + 1] == "#": print("No") exit() if A < C...
def solve(): if "##" in s[a : c + 1] or "##" in s[b : d + 1]: return False if b < c < d: return True # sfsf if c < b < d: return True # ssff return "..." in s[b - 1 : d + 2] # sffs n, a, b, c, d = list(map(int, input().split())) a -= 1 b -= 1 c -= 1 d -= 1 s = eval(input()) ...
false
52.5
[ "-N, A, B, C, D = list(map(int, input().split()))", "-A -= 1", "-B -= 1", "-C -= 1", "-D -= 1", "+def solve():", "+ if \"##\" in s[a : c + 1] or \"##\" in s[b : d + 1]:", "+ return False", "+ if b < c < d:", "+ return True # sfsf", "+ if c < b < d:", "+ return Tr...
false
0.046556
0.092114
0.505423
[ "s801101554", "s870109597" ]
u371763408
p03329
python
s479019457
s522811940
977
751
6,296
6,296
Accepted
Accepted
23.13
n=int(eval(input())) ls=set([1]) i=1 while 6**i<=100000: ls.add(6**i) i+=1 i=1 while 9**i<=100000: ls.add(9**i) i+=1 dp = [float("inf") for i in range(n+2)] dp[0] = 0 ls=list(ls) #円の総合計 for i in range(n+2): #額面のコインの種類 for j in range(len(ls)): if i+ls[j]<=n: dp[i+ls[j]] = min(...
n=int(eval(input())) ls=[1] for i in range(1,7): ls.append(6**i) ls.append(9**i) dp = [float('inf') for i in range(n+2)] dp[0] = 0 #円の総合計 for i in range(1,n+1): for j in ls: if i-j>=0: dp[i] = min(dp[i-1]+1, dp[i-j]+1,dp[i]) else: dp[i] = min(dp[i-1]+1,dp[i]) print((dp[n]))
22
17
365
310
n = int(eval(input())) ls = set([1]) i = 1 while 6**i <= 100000: ls.add(6**i) i += 1 i = 1 while 9**i <= 100000: ls.add(9**i) i += 1 dp = [float("inf") for i in range(n + 2)] dp[0] = 0 ls = list(ls) # 円の総合計 for i in range(n + 2): # 額面のコインの種類 for j in range(len(ls)): if i + ls[j] <= n: ...
n = int(eval(input())) ls = [1] for i in range(1, 7): ls.append(6**i) ls.append(9**i) dp = [float("inf") for i in range(n + 2)] dp[0] = 0 # 円の総合計 for i in range(1, n + 1): for j in ls: if i - j >= 0: dp[i] = min(dp[i - 1] + 1, dp[i - j] + 1, dp[i]) else: dp[i] = min(d...
false
22.727273
[ "-ls = set([1])", "-i = 1", "-while 6**i <= 100000:", "- ls.add(6**i)", "- i += 1", "-i = 1", "-while 9**i <= 100000:", "- ls.add(9**i)", "- i += 1", "+ls = [1]", "+for i in range(1, 7):", "+ ls.append(6**i)", "+ ls.append(9**i)", "-ls = list(ls)", "-for i in range(n + ...
false
0.19298
0.202776
0.951694
[ "s479019457", "s522811940" ]
u816631826
p03323
python
s863793967
s904453464
166
17
38,432
2,940
Accepted
Accepted
89.76
a, b = list(map(int, input().split())) if(a <= 8 and b <= 8): print("Yay!") else: print(":(")
line = eval(input()) A, B = [int(n) for n in line.split()] if A > 8 or B > 8: print(":(") else: print("Yay!")
5
6
100
116
a, b = list(map(int, input().split())) if a <= 8 and b <= 8: print("Yay!") else: print(":(")
line = eval(input()) A, B = [int(n) for n in line.split()] if A > 8 or B > 8: print(":(") else: print("Yay!")
false
16.666667
[ "-a, b = list(map(int, input().split()))", "-if a <= 8 and b <= 8:", "+line = eval(input())", "+A, B = [int(n) for n in line.split()]", "+if A > 8 or B > 8:", "+ print(\":(\")", "+else:", "-else:", "- print(\":(\")" ]
false
0.100365
0.036361
2.760276
[ "s863793967", "s904453464" ]
u267325300
p03088
python
s752550951
s812747104
122
93
3,872
3,864
Accepted
Accepted
23.77
N, MOD = int(eval(input())), 10 ** 9 + 7 memo = [{} for i in range(N + 1)] def ok(last4): for i in range(4): t = list(last4) if i >= 1: t[i - 1], t[i] = t[i], t[i - 1] if ''.join(t).count('AGC') >= 1: return False return True def dfs(cur, last3):...
N = int(eval(input())) def is_valid(last_4): cand = [last_4] for i in range(3): cand.append(last_4[:i] + last_4[i + 1] + last_4[i] + last_4[i + 2:]) for m in cand: if "AGC" in m: return False return True memo = [{} for i in range(N + 1)] mod = 10**9 + 7 ...
28
33
605
686
N, MOD = int(eval(input())), 10**9 + 7 memo = [{} for i in range(N + 1)] def ok(last4): for i in range(4): t = list(last4) if i >= 1: t[i - 1], t[i] = t[i], t[i - 1] if "".join(t).count("AGC") >= 1: return False return True def dfs(cur, last3): if last3 in...
N = int(eval(input())) def is_valid(last_4): cand = [last_4] for i in range(3): cand.append(last_4[:i] + last_4[i + 1] + last_4[i] + last_4[i + 2 :]) for m in cand: if "AGC" in m: return False return True memo = [{} for i in range(N + 1)] mod = 10**9 + 7 def dfs(index, ...
false
15.151515
[ "-N, MOD = int(eval(input())), 10**9 + 7", "-memo = [{} for i in range(N + 1)]", "+N = int(eval(input()))", "-def ok(last4):", "- for i in range(4):", "- t = list(last4)", "- if i >= 1:", "- t[i - 1], t[i] = t[i], t[i - 1]", "- if \"\".join(t).count(\"AGC\") >= 1:"...
false
0.183368
0.06481
2.829329
[ "s752550951", "s812747104" ]
u732870425
p02947
python
s083097595
s486926669
410
351
25,328
24,976
Accepted
Accepted
14.39
from collections import Counter N = int(eval(input())) S = [eval(input()) for _ in range(N)] ctr = Counter() ans = 0 for Si in S: x = "".join(sorted(list(Si))) if x in ctr: ans += ctr[x] ctr[x] += 1 print(ans)
N = int(eval(input())) S = [eval(input()) for _ in range(N)] cnt = {} ans = 0 for Si in S: x = "".join(sorted(list(Si))) if x not in cnt: cnt[x] = 0 ans += cnt[x] cnt[x] += 1 print(ans)
14
14
233
213
from collections import Counter N = int(eval(input())) S = [eval(input()) for _ in range(N)] ctr = Counter() ans = 0 for Si in S: x = "".join(sorted(list(Si))) if x in ctr: ans += ctr[x] ctr[x] += 1 print(ans)
N = int(eval(input())) S = [eval(input()) for _ in range(N)] cnt = {} ans = 0 for Si in S: x = "".join(sorted(list(Si))) if x not in cnt: cnt[x] = 0 ans += cnt[x] cnt[x] += 1 print(ans)
false
0
[ "-from collections import Counter", "-", "-ctr = Counter()", "+cnt = {}", "- if x in ctr:", "- ans += ctr[x]", "- ctr[x] += 1", "+ if x not in cnt:", "+ cnt[x] = 0", "+ ans += cnt[x]", "+ cnt[x] += 1" ]
false
0.040998
0.040798
1.004914
[ "s083097595", "s486926669" ]
u633355062
p03854
python
s287977199
s401848893
80
61
3,188
9,124
Accepted
Accepted
23.75
er = ["dreamer", "eraser"] noter = ["dream", "erase"] words = er + noter s = eval(input()) while len(s) > 0: flag = True for word in words: if s.endswith(word): s = s[:-len(word)] flag = False if flag: print("NO") exit() print("YES")
S = eval(input()) words = ["dream", "dreamer", "erase", "eraser"] while len(S) > 0: flag = True for word in words: if S.endswith(word): flag = False S = S[:-len(word)] if flag: print("NO") exit(0) print("YES")
14
12
270
274
er = ["dreamer", "eraser"] noter = ["dream", "erase"] words = er + noter s = eval(input()) while len(s) > 0: flag = True for word in words: if s.endswith(word): s = s[: -len(word)] flag = False if flag: print("NO") exit() print("YES")
S = eval(input()) words = ["dream", "dreamer", "erase", "eraser"] while len(S) > 0: flag = True for word in words: if S.endswith(word): flag = False S = S[: -len(word)] if flag: print("NO") exit(0) print("YES")
false
14.285714
[ "-er = [\"dreamer\", \"eraser\"]", "-noter = [\"dream\", \"erase\"]", "-words = er + noter", "-s = eval(input())", "-while len(s) > 0:", "+S = eval(input())", "+words = [\"dream\", \"dreamer\", \"erase\", \"eraser\"]", "+while len(S) > 0:", "- if s.endswith(word):", "- s = s[: -l...
false
0.138148
0.038311
3.605961
[ "s287977199", "s401848893" ]
u156815136
p03103
python
s952233005
s411337244
700
424
65,752
21,972
Accepted
Accepted
39.43
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] #from itertools import combinations # (string,3) 3回 #from collections import deque #import collections.defaultdict(list) #import bisect # # # pythonで無理なときは、pypyでやると正解するかも!! # ...
# Aiでソートしてあげたほうがいいね? n,m = list(map(int,input().split())) drink = [] for i in range(n): a,b = list(map(int,input().split())) drink.append([a,b]) drink = sorted(drink,key = lambda x:x[0]) #print(drink) total = 0 cnt = 0 for price,num in drink: if cnt == m: break if cnt + num <= m: ...
39
23
920
537
# from statistics import median # import collections # aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] # from itertools import combinations # (string,3) 3回 # from collections import deque # import collections.defaultdict(list) # import bisect # # # pythonで無理なときは、pypyでやると正解するかも!! # # mo...
# Aiでソートしてあげたほうがいいね? n, m = list(map(int, input().split())) drink = [] for i in range(n): a, b = list(map(int, input().split())) drink.append([a, b]) drink = sorted(drink, key=lambda x: x[0]) # print(drink) total = 0 cnt = 0 for price, num in drink: if cnt == m: break if cnt + num <= m: ...
false
41.025641
[ "-# from statistics import median", "-# import collections", "-# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]", "-# from itertools import combinations # (string,3) 3回", "-# from collections import deque", "-# import collections.defaultdict(list)", "-# import bisect",...
false
0.038605
0.087742
0.43998
[ "s952233005", "s411337244" ]
u216015528
p02642
python
s932973114
s993495707
594
486
51,380
32,180
Accepted
Accepted
18.18
import numpy as np n = int(eval(input())) a = list(map(int, input().split())) a_max = max(a) lst = [0] * (a_max + 1) cnt = 0 # if len(a) <= 1: # print(0) # else: for i in a: if lst[i] > 1: # 配列中のカウントが2以上なら以降の処理を省略 continue for j in range(a_max // i + 1): # Aiの倍数にインクリメント(配列の上限はa[-1]) ...
n = int(eval(input())) a = list(map(int, input().split())) a_max = max(a) lst = [0] * (a_max + 1) cnt = 0 for i in a: if lst[i] > 1: # 配列中のカウントが2以上なら以降の処理を省略 continue for j in range(a_max // i + 1): # Aiの倍数にインクリメント(配列の上限はa[-1]) lst[i * j] += 1 # lst[1::i] += 1 for i in a: i...
20
15
424
358
import numpy as np n = int(eval(input())) a = list(map(int, input().split())) a_max = max(a) lst = [0] * (a_max + 1) cnt = 0 # if len(a) <= 1: # print(0) # else: for i in a: if lst[i] > 1: # 配列中のカウントが2以上なら以降の処理を省略 continue for j in range(a_max // i + 1): # Aiの倍数にインクリメント(配列の上限はa[-1]) lst[i...
n = int(eval(input())) a = list(map(int, input().split())) a_max = max(a) lst = [0] * (a_max + 1) cnt = 0 for i in a: if lst[i] > 1: # 配列中のカウントが2以上なら以降の処理を省略 continue for j in range(a_max // i + 1): # Aiの倍数にインクリメント(配列の上限はa[-1]) lst[i * j] += 1 # lst[1::i] += 1 for i in a: if lst[i] == ...
false
25
[ "-import numpy as np", "-", "-# if len(a) <= 1:", "-# print(0)", "-# else:" ]
false
0.035093
0.035655
0.984217
[ "s932973114", "s993495707" ]
u279266699
p02832
python
s006720756
s627036593
140
95
26,772
26,780
Accepted
Accepted
32.14
from collections import deque n = int(eval(input())) a = list(map(int, input().split())) if 1 in a: d = deque(a) count = 0 num = 1 pick = 0 while d: pick = d.popleft() count += 1 if pick == num: count -= 1 num += 1 print(count) e...
from collections import deque n = int(eval(input())) a = list(map(int, input().split())) if 1 in a: count = 0 num = 1 for i in a: if num == i: num += 1 else: count += 1 print(count) else: print((-1))
19
16
334
269
from collections import deque n = int(eval(input())) a = list(map(int, input().split())) if 1 in a: d = deque(a) count = 0 num = 1 pick = 0 while d: pick = d.popleft() count += 1 if pick == num: count -= 1 num += 1 print(count) else: print((-1...
from collections import deque n = int(eval(input())) a = list(map(int, input().split())) if 1 in a: count = 0 num = 1 for i in a: if num == i: num += 1 else: count += 1 print(count) else: print((-1))
false
15.789474
[ "- d = deque(a)", "- pick = 0", "- while d:", "- pick = d.popleft()", "- count += 1", "- if pick == num:", "- count -= 1", "+ for i in a:", "+ if num == i:", "+ else:", "+ count += 1" ]
false
0.036086
0.033781
1.068238
[ "s006720756", "s627036593" ]
u174394352
p03546
python
s067319270
s504410420
226
196
42,844
40,668
Accepted
Accepted
13.27
H,W=list(map(int,input().split())) c=[list(map(int,input().split())) for _ in range(10)] A=[list(map(int,input().split())) for _ in range(H)] mincost=[0 for i in range(10)] for i in range(10): if i!=1: res = {i:0} path = [(j,c[i][j]) for j in range(10) if j not in list(res.keys())] ...
H,W=list(map(int,input().split())) c=[list(map(int,input().split())) for _ in range(10)] A=[list(map(int,input().split())) for _ in range(H)] from itertools import product for k,i,j in product(list(range(10)),repeat=3): if c[i][j] > c[i][k]+c[k][j]: c[i][j] = c[i][k]+c[k][j] ans=0 for i,j in p...
24
15
759
396
H, W = list(map(int, input().split())) c = [list(map(int, input().split())) for _ in range(10)] A = [list(map(int, input().split())) for _ in range(H)] mincost = [0 for i in range(10)] for i in range(10): if i != 1: res = {i: 0} path = [(j, c[i][j]) for j in range(10) if j not in list(res.keys())] ...
H, W = list(map(int, input().split())) c = [list(map(int, input().split())) for _ in range(10)] A = [list(map(int, input().split())) for _ in range(H)] from itertools import product for k, i, j in product(list(range(10)), repeat=3): if c[i][j] > c[i][k] + c[k][j]: c[i][j] = c[i][k] + c[k][j] ans = 0 for i,...
false
37.5
[ "-mincost = [0 for i in range(10)]", "-for i in range(10):", "- if i != 1:", "- res = {i: 0}", "- path = [(j, c[i][j]) for j in range(10) if j not in list(res.keys())]", "- while 1 not in list(res.keys()):", "- path.sort(key=lambda x: x[1])", "- node, cost...
false
0.042607
0.041309
1.031442
[ "s067319270", "s504410420" ]
u106971015
p02732
python
s294536954
s795585790
474
412
26,780
26,772
Accepted
Accepted
13.08
from collections import Counter N = int(eval(input())) A = list(map(int,input().split())) countdic = Counter(A) goukei = 0 ans = '' for key,value in list(countdic.items()): goukei += (value*(value-1))//2 for i in A: ans = goukei -(countdic[i]*(countdic[i]-1))//2 + ((countdic[i]-1)*(countdic[i]-2))//2...
from collections import Counter import sys def input(): return sys.stdin.readline().strip() def combi(num): return num * (num - 1) // 2 def main(): N = int(eval(input())) A = list(map(int,input().split())) counterdic = Counter(A) ma = 0 for value in list(counterdic.values()): ...
12
18
324
453
from collections import Counter N = int(eval(input())) A = list(map(int, input().split())) countdic = Counter(A) goukei = 0 ans = "" for key, value in list(countdic.items()): goukei += (value * (value - 1)) // 2 for i in A: ans = ( goukei - (countdic[i] * (countdic[i] - 1)) // 2 + ((cou...
from collections import Counter import sys def input(): return sys.stdin.readline().strip() def combi(num): return num * (num - 1) // 2 def main(): N = int(eval(input())) A = list(map(int, input().split())) counterdic = Counter(A) ma = 0 for value in list(counterdic.values()): ...
false
33.333333
[ "+import sys", "-N = int(eval(input()))", "-A = list(map(int, input().split()))", "-countdic = Counter(A)", "-goukei = 0", "-ans = \"\"", "-for key, value in list(countdic.items()):", "- goukei += (value * (value - 1)) // 2", "-for i in A:", "- ans = (", "- goukei", "- - (c...
false
0.047722
0.045526
1.048247
[ "s294536954", "s795585790" ]
u796942881
p03266
python
s225026993
s490533471
65
17
4,596
2,940
Accepted
Accepted
73.85
# 整数全体をある数で割った余りで分類 # 余りが同じ整数はすべて同じ(合同≡)とみなす # 加法、減法、乗法を行っても合同を保つことから # (1) a + b ≡ 0 mod K # (2) b + c ≡ 0 mod K # (3) c + a ≡ 0 mod K # (1) - (2) + (3) 2a ≡ 0 mod K # Kが偶数の場合、mod K / 2 もゼロと合同になる # Kが8の場合、mod 4 もゼロとなるものも対象となる # Kで割った余りはKより小さい # Kで割った余りの数が等しくなるものがいくつあるか数え # a mod Kで全探索する N, K = list(map(int...
def main(): N, K = list(map(int, input().split())) if K % 2: print(((N // K) ** 3)) elif N // K * K + K // 2 <= N: print(((N // K) ** 3 + (N // K + 1) ** 3)) else: print((2 * (N // K) ** 3)) return main()
41
12
707
250
# 整数全体をある数で割った余りで分類 # 余りが同じ整数はすべて同じ(合同≡)とみなす # 加法、減法、乗法を行っても合同を保つことから # (1) a + b ≡ 0 mod K # (2) b + c ≡ 0 mod K # (3) c + a ≡ 0 mod K # (1) - (2) + (3) 2a ≡ 0 mod K # Kが偶数の場合、mod K / 2 もゼロと合同になる # Kが8の場合、mod 4 もゼロとなるものも対象となる # Kで割った余りはKより小さい # Kで割った余りの数が等しくなるものがいくつあるか数え # a mod Kで全探索する N, K = list(map(int, input().sp...
def main(): N, K = list(map(int, input().split())) if K % 2: print(((N // K) ** 3)) elif N // K * K + K // 2 <= N: print(((N // K) ** 3 + (N // K + 1) ** 3)) else: print((2 * (N // K) ** 3)) return main()
false
70.731707
[ "-# 整数全体をある数で割った余りで分類", "-# 余りが同じ整数はすべて同じ(合同≡)とみなす", "-# 加法、減法、乗法を行っても合同を保つことから", "-# (1) a + b ≡ 0 mod K", "-# (2) b + c ≡ 0 mod K", "-# (3) c + a ≡ 0 mod K", "-# (1) - (2) + (3) 2a ≡ 0 mod K", "-# Kが偶数の場合、mod K / 2 もゼロと合同になる", "-# Kが8の場合、mod 4 もゼロとなるものも対象となる", "-# Kで割った余りはKより小さい", "-# Kで割った余りの...
false
0.085615
0.082335
1.039837
[ "s225026993", "s490533471" ]
u497952650
p02824
python
s905076604
s797201335
745
306
14,480
14,964
Accepted
Accepted
58.93
def check(n): if n <= P-1: return True if A[n]+M < A[P-1]: return False votes = (P+N-1-n)*M + sum([A[n]+M-A[i] for i in range(P-1,n)]) if votes < M*V: return False else: return True N,M,V,P = list(map(int,input().split())) A = list(map(int...
def check(n): if n <= P-1: return True if A[n]+M < A[P-1]: return False votes = (P+N-1-n)*M + sum([A[n]+M-A[i] for i in range(P-1,n)]) if votes < M*V: return False else: return True N,M,V,P = list(map(int,input().split())) A = list(map(int...
37
37
614
578
def check(n): if n <= P - 1: return True if A[n] + M < A[P - 1]: return False votes = (P + N - 1 - n) * M + sum([A[n] + M - A[i] for i in range(P - 1, n)]) if votes < M * V: return False else: return True N, M, V, P = list(map(int, input().split())) A = list(map(int...
def check(n): if n <= P - 1: return True if A[n] + M < A[P - 1]: return False votes = (P + N - 1 - n) * M + sum([A[n] + M - A[i] for i in range(P - 1, n)]) if votes < M * V: return False else: return True N, M, V, P = list(map(int, input().split())) A = list(map(int...
false
0
[ "-while abs(right - left) > 1 and check(left) and not check(right):", "+while abs(right - left) > 1:" ]
false
0.088951
0.071151
1.25017
[ "s905076604", "s797201335" ]
u581187895
p02850
python
s232030809
s460115963
568
319
85,652
18,676
Accepted
Accepted
43.84
import sys sys.setrecursionlimit(10 ** 7) N = int(eval(input())) E = [[] for _ in range(N+1)] for i in range(N-1): a, b = list(map(int, input().split())) E[a].append((b, i)) E[b].append((a, i)) K = max(len(e) for e in E) # 使用する色の最大数 print(K) ans = [-1]*(N-1) def dfs(v=1, p=0, p_col=-1): col...
import sys sys.setrecursionlimit(10 ** 7) read = sys.stdin.buffer.read inp = sys.stdin.buffer.readline def inpS(): return inp().rstrip().decode() readlines = sys.stdin.buffer.readlines from collections import deque N = int(inp()) graph = [[] for _ in range(N+1)] nextEdege = [] for _ in range(N-1): ...
25
36
525
673
import sys sys.setrecursionlimit(10**7) N = int(eval(input())) E = [[] for _ in range(N + 1)] for i in range(N - 1): a, b = list(map(int, input().split())) E[a].append((b, i)) E[b].append((a, i)) K = max(len(e) for e in E) # 使用する色の最大数 print(K) ans = [-1] * (N - 1) def dfs(v=1, p=0, p_col=-1): col = ...
import sys sys.setrecursionlimit(10**7) read = sys.stdin.buffer.read inp = sys.stdin.buffer.readline def inpS(): return inp().rstrip().decode() readlines = sys.stdin.buffer.readlines from collections import deque N = int(inp()) graph = [[] for _ in range(N + 1)] nextEdege = [] for _ in range(N - 1): a, b ...
false
30.555556
[ "-N = int(eval(input()))", "-E = [[] for _ in range(N + 1)]", "-for i in range(N - 1):", "- a, b = list(map(int, input().split()))", "- E[a].append((b, i))", "- E[b].append((a, i))", "-K = max(len(e) for e in E) # 使用する色の最大数", "-print(K)", "-ans = [-1] * (N - 1)", "+read = sys.stdin.buffe...
false
0.045506
0.037473
1.214362
[ "s232030809", "s460115963" ]
u785989355
p02889
python
s802683724
s659383817
1,763
1,202
126,684
72,284
Accepted
Accepted
31.82
import sys def input(): return sys.stdin.readline()[:-1] N,M,L = list(map(int,input().split())) e_list = [[] for i in range(N)] def warshall_floyd(d): #d[i][j]: iからjへの最短距離 for k in range(N): for i in range(N): for j in range(N): d[i][j] = min(d[i][j],d[i...
import sys sys.setrecursionlimit(500000) def input(): return sys.stdin.readline()[:-1] def main(): N,M,L = list(map(int,input().split())) e_list = [[] for i in range(N)] for i in range(M): A,B,C = list(map(int,input().split())) A,B = A-1,B-1 e_list[A].append((B,C)) ...
50
52
1,085
1,267
import sys def input(): return sys.stdin.readline()[:-1] N, M, L = list(map(int, input().split())) e_list = [[] for i in range(N)] def warshall_floyd(d): # d[i][j]: iからjへの最短距離 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] + ...
import sys sys.setrecursionlimit(500000) def input(): return sys.stdin.readline()[:-1] def main(): N, M, L = list(map(int, input().split())) e_list = [[] for i in range(N)] for i in range(M): A, B, C = list(map(int, input().split())) A, B = A - 1, B - 1 e_list[A].append((B, ...
false
3.846154
[ "+", "+sys.setrecursionlimit(500000)", "-N, M, L = list(map(int, input().split()))", "-e_list = [[] for i in range(N)]", "-", "-", "-def warshall_floyd(d):", "- # d[i][j]: iからjへの最短距離", "+def main():", "+ N, M, L = list(map(int, input().split()))", "+ e_list = [[] for i in range(N)]", ...
false
0.066332
0.061667
1.075657
[ "s802683724", "s659383817" ]
u072053884
p02279
python
s958770397
s208753076
1,660
1,440
55,456
61,852
Accepted
Accepted
13.25
class Node: def __init__(self, num, parent, leftmostChild, rightSibling): self.id = num self.parent = parent self.leftmostChild = leftmostChild self.rightSibling = rightSibling self.depth = 0 def show_info(self): print('node {0}: '.format(self.id...
"""Rooted Trees.""" class Node: def __init__(self, num, parent, *children): self.id = num self.parent = parent self.children = list(children) self.depth = 0 def show_info(self): print('node {0}: '.format(self.id), end = '') print('parent = {0}...
67
60
2,010
1,500
class Node: def __init__(self, num, parent, leftmostChild, rightSibling): self.id = num self.parent = parent self.leftmostChild = leftmostChild self.rightSibling = rightSibling self.depth = 0 def show_info(self): print("node {0}: ".format(self.id), end="") ...
"""Rooted Trees.""" class Node: def __init__(self, num, parent, *children): self.id = num self.parent = parent self.children = list(children) self.depth = 0 def show_info(self): print("node {0}: ".format(self.id), end="") print("parent = {0}, ".format(self.pare...
false
10.447761
[ "+\"\"\"Rooted Trees.\"\"\"", "+", "+", "- def __init__(self, num, parent, leftmostChild, rightSibling):", "+ def __init__(self, num, parent, *children):", "- self.leftmostChild = leftmostChild", "- self.rightSibling = rightSibling", "+ self.children = list(children)", "- ...
false
0.119575
0.006977
17.137797
[ "s958770397", "s208753076" ]
u528470578
p03295
python
s732133205
s028417136
719
429
65,544
29,852
Accepted
Accepted
40.33
# ABC103 D-Islands War N, M = list(map(int, input().split())) ab = [] for i in range(M): ab.append(list(map(int, input().split()))) ab = sorted(ab, key=lambda x:x[1]) ans = 0 lastremoved = 0 for i, j in enumerate(ab): if i == 0: ans += 1 temp = j[1] - 1 else: i...
N, M = list(map(int, input().split())) box = [list(map(int, input().split())) for _ in range(M)] box = sorted(box, key= lambda x: x[1]) rmax = box[0][1] ans = 1 for i in range(1, M): if box[i][0] >= rmax: rmax = box[i][1] ans += 1 else: continue print(ans)
23
12
443
293
# ABC103 D-Islands War N, M = list(map(int, input().split())) ab = [] for i in range(M): ab.append(list(map(int, input().split()))) ab = sorted(ab, key=lambda x: x[1]) ans = 0 lastremoved = 0 for i, j in enumerate(ab): if i == 0: ans += 1 temp = j[1] - 1 else: if j[0] <= temp: ...
N, M = list(map(int, input().split())) box = [list(map(int, input().split())) for _ in range(M)] box = sorted(box, key=lambda x: x[1]) rmax = box[0][1] ans = 1 for i in range(1, M): if box[i][0] >= rmax: rmax = box[i][1] ans += 1 else: continue print(ans)
false
47.826087
[ "-# ABC103 D-Islands War", "-ab = []", "-for i in range(M):", "- ab.append(list(map(int, input().split())))", "-ab = sorted(ab, key=lambda x: x[1])", "-ans = 0", "-lastremoved = 0", "-for i, j in enumerate(ab):", "- if i == 0:", "+box = [list(map(int, input().split())) for _ in range(M)]", ...
false
0.035405
0.040893
0.865791
[ "s732133205", "s028417136" ]
u753803401
p02990
python
s680859298
s718060374
406
221
70,744
42,224
Accepted
Accepted
45.57
import sys import sys import bisect import collections import fractions import heapq import math from operator import mul from functools import reduce from functools import lru_cache def combination(n, r): r = min(n - r, r) if r == 0: return 1 else: return reduce(mul, list...
import sys def alg_combination_mod(n, r, mod): r = min(n - r, r) if r == 0: return 1 else: denominator = 1 for i in range(n, n - r, -1): denominator = (denominator * i) % mod molecule = 1 for i in range(1, r + 1): molecule = (mol...
33
31
736
794
import sys import sys import bisect import collections import fractions import heapq import math from operator import mul from functools import reduce from functools import lru_cache def combination(n, r): r = min(n - r, r) if r == 0: return 1 else: return reduce(mul, list(range(n, n - r, ...
import sys def alg_combination_mod(n, r, mod): r = min(n - r, r) if r == 0: return 1 else: denominator = 1 for i in range(n, n - r, -1): denominator = (denominator * i) % mod molecule = 1 for i in range(1, r + 1): molecule = (molecule * i) % ...
false
6.060606
[ "-import sys", "-import bisect", "-import collections", "-import fractions", "-import heapq", "-import math", "-from operator import mul", "-from functools import reduce", "-from functools import lru_cache", "-def combination(n, r):", "+def alg_combination_mod(n, r, mod):", "- return re...
false
0.044042
0.037848
1.163662
[ "s680859298", "s718060374" ]
u006326793
p02390
python
s571314746
s622849497
50
20
7,652
5,592
Accepted
Accepted
60
# -*- coding utf-8 -*- S = int(eval(input())) h = S // (60 * 60) m = (S % 3600) // 60 s = (S % 3600) % 60 desc = "{0}:{1}:{2}".format(h,m,s) print(desc)
# -*- coding: utf-8 -*- S = int(eval(input())) hour = int(S / (60 * 60)) minutes = int((S % (60 * 60)) / 60) seconds = int((S % (60 * 60)) % 60) watch = str(hour) + ":" + str(minutes) + ":" + str(seconds) print(watch)
7
10
152
224
# -*- coding utf-8 -*- S = int(eval(input())) h = S // (60 * 60) m = (S % 3600) // 60 s = (S % 3600) % 60 desc = "{0}:{1}:{2}".format(h, m, s) print(desc)
# -*- coding: utf-8 -*- S = int(eval(input())) hour = int(S / (60 * 60)) minutes = int((S % (60 * 60)) / 60) seconds = int((S % (60 * 60)) % 60) watch = str(hour) + ":" + str(minutes) + ":" + str(seconds) print(watch)
false
30
[ "-# -*- coding utf-8 -*-", "+# -*- coding: utf-8 -*-", "-h = S // (60 * 60)", "-m = (S % 3600) // 60", "-s = (S % 3600) % 60", "-desc = \"{0}:{1}:{2}\".format(h, m, s)", "-print(desc)", "+hour = int(S / (60 * 60))", "+minutes = int((S % (60 * 60)) / 60)", "+seconds = int((S % (60 * 60)) % 60)", ...
false
0.073036
0.162525
0.449382
[ "s571314746", "s622849497" ]
u588341295
p03546
python
s365054005
s705128062
288
38
17,452
3,444
Accepted
Accepted
86.81
# -*- coding: utf-8 -*- from scipy.sparse.csgraph import dijkstra H, W = list(map(int, input().split())) C = [None] * 10 for i in range(10): C[i] = list(map(int, input().split())) field = [None] * H for i in range(H): field[i] = list(map(int, input().split())) # ちょうどデータの持ち方が隣接行列なので、そのままscipyのダイクス...
# -*- coding: utf-8 -*- H, W = list(map(int, input().split())) C = [None] * 10 for i in range(10): C[i] = list(map(int, input().split())) field = [None] * H for i in range(H): field[i] = list(map(int, input().split())) # ワーシャルフロイドで全頂点の最短距離 for k in range(10): for i in range(10): for j...
22
23
524
558
# -*- coding: utf-8 -*- from scipy.sparse.csgraph import dijkstra H, W = list(map(int, input().split())) C = [None] * 10 for i in range(10): C[i] = list(map(int, input().split())) field = [None] * H for i in range(H): field[i] = list(map(int, input().split())) # ちょうどデータの持ち方が隣接行列なので、そのままscipyのダイクストラ使ってみる dist =...
# -*- coding: utf-8 -*- H, W = list(map(int, input().split())) C = [None] * 10 for i in range(10): C[i] = list(map(int, input().split())) field = [None] * H for i in range(H): field[i] = list(map(int, input().split())) # ワーシャルフロイドで全頂点の最短距離 for k in range(10): for i in range(10): for j in range(10): ...
false
4.347826
[ "-from scipy.sparse.csgraph import dijkstra", "-", "-# ちょうどデータの持ち方が隣接行列なので、そのままscipyのダイクストラ使ってみる", "-dist = dijkstra(C)", "+# ワーシャルフロイドで全頂点の最短距離", "+for k in range(10):", "+ for i in range(10):", "+ for j in range(10):", "+ C[i][j] = min(C[i][j], C[i][k] + C[k][j])", "- ...
false
0.721864
0.035022
20.611665
[ "s365054005", "s705128062" ]
u828455902
p02408
python
s534742823
s194625308
20
10
4,196
4,196
Accepted
Accepted
50
a=[];b="SHCD" for i in range(4*13):a.append(b[i/13]+" "+str(i%13+1)) for i in range(eval(input())):a.remove(input()) for i in a:print(i)
a=[] for i in range(4*13):a.append("SHCD"[i/13]+" "+str(i%13+1)) for i in range(eval(input())):a.remove(input()) for i in a:print(i)
4
4
136
132
a = [] b = "SHCD" for i in range(4 * 13): a.append(b[i / 13] + " " + str(i % 13 + 1)) for i in range(eval(input())): a.remove(input()) for i in a: print(i)
a = [] for i in range(4 * 13): a.append("SHCD"[i / 13] + " " + str(i % 13 + 1)) for i in range(eval(input())): a.remove(input()) for i in a: print(i)
false
0
[ "-b = \"SHCD\"", "- a.append(b[i / 13] + \" \" + str(i % 13 + 1))", "+ a.append(\"SHCD\"[i / 13] + \" \" + str(i % 13 + 1))" ]
false
0.045693
0.111858
0.408488
[ "s534742823", "s194625308" ]
u626881915
p02695
python
s157792267
s223675381
907
94
9,216
68,536
Accepted
Accepted
89.64
import itertools n, m , q = list(map(int, input().split())) l = [] for i in range(q): a,b,c,d = list(map(int, input().split())) l.append((a,b,c,d)) comb = itertools.combinations_with_replacement(list(range(1,m+1)), n) max_score = 0 for e in comb: score = 0 for j in l: if e[j[1]-1]-e[j[0]-...
n, m , q = list(map(int, input().split())) l = [] for i in range(q): a,b,c,d = list(map(int, input().split())) l.append((a,b,c,d)) max_score = 0 comb = [[1]] while len(comb) > 0: seed = comb.pop() if len(seed) == n: score = 0 for j in l: if seed[j[1]-1]-seed[j[0]-1]==j[2]: ...
20
24
406
505
import itertools n, m, q = list(map(int, input().split())) l = [] for i in range(q): a, b, c, d = list(map(int, input().split())) l.append((a, b, c, d)) comb = itertools.combinations_with_replacement(list(range(1, m + 1)), n) max_score = 0 for e in comb: score = 0 for j in l: if e[j[1] - 1] - e...
n, m, q = list(map(int, input().split())) l = [] for i in range(q): a, b, c, d = list(map(int, input().split())) l.append((a, b, c, d)) max_score = 0 comb = [[1]] while len(comb) > 0: seed = comb.pop() if len(seed) == n: score = 0 for j in l: if seed[j[1] - 1] - seed[j[0] - 1...
false
16.666667
[ "-import itertools", "-", "-comb = itertools.combinations_with_replacement(list(range(1, m + 1)), n)", "-for e in comb:", "- score = 0", "- for j in l:", "- if e[j[1] - 1] - e[j[0] - 1] == j[2]:", "- score += j[3]", "- if score > max_score:", "- max_score = score"...
false
0.051018
0.062592
0.815086
[ "s157792267", "s223675381" ]
u890570193
p02711
python
s443703896
s639297155
24
22
8,968
8,920
Accepted
Accepted
8.33
N = eval(input()) if '7' in N: print("Yes") else: print("No")
s = eval(input()) if "7" in s: print("Yes") else:print("No")
5
4
63
59
N = eval(input()) if "7" in N: print("Yes") else: print("No")
s = eval(input()) if "7" in s: print("Yes") else: print("No")
false
20
[ "-N = eval(input())", "-if \"7\" in N:", "+s = eval(input())", "+if \"7\" in s:" ]
false
0.033774
0.036939
0.914326
[ "s443703896", "s639297155" ]
u909643606
p03379
python
s327290067
s724173042
359
311
27,252
26,016
Accepted
Accepted
13.37
from statistics import mean, median,variance,stdev n=int(eval(input())) nn=n//2 x=[int(i) for i in input().split()] y=x[:] x.sort() low_median=median(x[:n-1]) high_median=median(x[1:]) for i in range(n): if y[i]<high_median: print(high_median) else: print(low_median)
n=int(eval(input())) nn=n//2 x=[int(i) for i in input().split()] y=x[:] x.sort() low_median=x[nn-1] high_median=x[nn] for i in range(n): if y[i]<high_median: print(high_median) else: print(low_median)
15
14
289
224
from statistics import mean, median, variance, stdev n = int(eval(input())) nn = n // 2 x = [int(i) for i in input().split()] y = x[:] x.sort() low_median = median(x[: n - 1]) high_median = median(x[1:]) for i in range(n): if y[i] < high_median: print(high_median) else: print(low_median)
n = int(eval(input())) nn = n // 2 x = [int(i) for i in input().split()] y = x[:] x.sort() low_median = x[nn - 1] high_median = x[nn] for i in range(n): if y[i] < high_median: print(high_median) else: print(low_median)
false
6.666667
[ "-from statistics import mean, median, variance, stdev", "-", "-low_median = median(x[: n - 1])", "-high_median = median(x[1:])", "+low_median = x[nn - 1]", "+high_median = x[nn]" ]
false
0.05314
0.044833
1.185279
[ "s327290067", "s724173042" ]
u114648678
p03059
python
s166548765
s544770919
21
17
3,316
2,940
Accepted
Accepted
19.05
a,b,t=list(map(int,input().split())) print((t//a*b))
a,b,t=list(map(int,input().split())) print((int(((t+0.5)//a)*b)))
2
2
45
58
a, b, t = list(map(int, input().split())) print((t // a * b))
a, b, t = list(map(int, input().split())) print((int(((t + 0.5) // a) * b)))
false
0
[ "-print((t // a * b))", "+print((int(((t + 0.5) // a) * b)))" ]
false
0.099577
0.047917
2.078128
[ "s166548765", "s544770919" ]
u296150111
p02787
python
s070293919
s514012274
495
372
126,960
171,136
Accepted
Accepted
24.85
h,n=list(map(int,input().split())) ab=[] p=0 for i in range(n): a,b=list(map(int,input().split())) p=max(p,a) ab.append([a,b]) dp=[[10**9]*(p+1+h) for _ in range(n+1)] for i in range(n+1): dp[i][0]=0 for i in range(n): for j in range(p+h): if j+1-ab[i][0]>=0: dp[i+1][j+1]=min(dp[i][j+1],dp[i+1]...
def main(): inf=10**9 h,n=list(map(int,input().split())) ab=[] r=0 for i in range(n): a,b=list(map(int,input().split())) ab.append((a,b)) r=max(r,a) #dp[number][damage] dp=[[inf for _ in range(r+h)]for _ in range(n+1)] for i in range(n+1): dp[i][0]=0 for i in range(n): for j in range(r+...
21
24
441
526
h, n = list(map(int, input().split())) ab = [] p = 0 for i in range(n): a, b = list(map(int, input().split())) p = max(p, a) ab.append([a, b]) dp = [[10**9] * (p + 1 + h) for _ in range(n + 1)] for i in range(n + 1): dp[i][0] = 0 for i in range(n): for j in range(p + h): if j + 1 - ab[i][0] ...
def main(): inf = 10**9 h, n = list(map(int, input().split())) ab = [] r = 0 for i in range(n): a, b = list(map(int, input().split())) ab.append((a, b)) r = max(r, a) # dp[number][damage] dp = [[inf for _ in range(r + h)] for _ in range(n + 1)] for i in range(n + ...
false
12.5
[ "-h, n = list(map(int, input().split()))", "-ab = []", "-p = 0", "-for i in range(n):", "- a, b = list(map(int, input().split()))", "- p = max(p, a)", "- ab.append([a, b])", "-dp = [[10**9] * (p + 1 + h) for _ in range(n + 1)]", "-for i in range(n + 1):", "- dp[i][0] = 0", "-for i in...
false
0.107846
0.125701
0.85795
[ "s070293919", "s514012274" ]
u413165887
p02823
python
s511588544
s964130339
172
17
38,384
2,940
Accepted
Accepted
90.12
n, a, b = list(map(int, input().split())) if (b-a)%2==0: print(((b-a)//2)) else: print((min(n-b+1+(b-a-1)//2,a+(b-a)//2)))
n,a,b=map(int,input().split()) x=b-a p=print if (b-a)%2==0:p((b-a)//2) else:p(min(n-b+1+(x-1)//2,a+x//2))
5
5
124
109
n, a, b = list(map(int, input().split())) if (b - a) % 2 == 0: print(((b - a) // 2)) else: print((min(n - b + 1 + (b - a - 1) // 2, a + (b - a) // 2)))
n, a, b = map(int, input().split()) x = b - a p = print if (b - a) % 2 == 0: p((b - a) // 2) else: p(min(n - b + 1 + (x - 1) // 2, a + x // 2))
false
0
[ "-n, a, b = list(map(int, input().split()))", "+n, a, b = map(int, input().split())", "+x = b - a", "+p = print", "- print(((b - a) // 2))", "+ p((b - a) // 2)", "- print((min(n - b + 1 + (b - a - 1) // 2, a + (b - a) // 2)))", "+ p(min(n - b + 1 + (x - 1) // 2, a + x // 2))" ]
false
0.03714
0.047335
0.784618
[ "s511588544", "s964130339" ]
u941438707
p03146
python
s475900173
s169791900
20
17
3,060
2,940
Accepted
Accepted
15
s=int(eval(input())) def f(i): if i%2==0: return i//2 else: return 3*i+1 a=[] a.append(s) for i in range(1,pow(10,7)): b=f(a[i-1]) if b in a: print((i+1)) break a.append(b)
s=int(eval(input())) if s<3: print((4)) exit() for i in range(10**7+1): if s==4: print((i+4)) exit() if s%2: s=3*s+1 else: s//=2
14
12
229
181
s = int(eval(input())) def f(i): if i % 2 == 0: return i // 2 else: return 3 * i + 1 a = [] a.append(s) for i in range(1, pow(10, 7)): b = f(a[i - 1]) if b in a: print((i + 1)) break a.append(b)
s = int(eval(input())) if s < 3: print((4)) exit() for i in range(10**7 + 1): if s == 4: print((i + 4)) exit() if s % 2: s = 3 * s + 1 else: s //= 2
false
14.285714
[ "-", "-", "-def f(i):", "- if i % 2 == 0:", "- return i // 2", "+if s < 3:", "+ print((4))", "+ exit()", "+for i in range(10**7 + 1):", "+ if s == 4:", "+ print((i + 4))", "+ exit()", "+ if s % 2:", "+ s = 3 * s + 1", "- return 3 * i + 1"...
false
0.064899
0.038015
1.707187
[ "s475900173", "s169791900" ]
u426764965
p02918
python
s206693514
s672109398
68
49
16,268
9,220
Accepted
Accepted
27.94
N, K = list(map(int, input().split())) S = str(eval(input())) def run_length_encoding(text:str)->list: text += '_' c = text[0] x = 1 res = [] for i in range(1, len(text)): if c == text[i]: x += 1 else: res.append((c, x)) c = text[i] ...
# 解説配信の模範解答 N, K = list(map(int, input().split())) S = str(eval(input())) score = 0 for i in range(N-1): if S[i] == S[i+1]: score += 1 ans = min(score + 2*K, N-1) print(ans)
33
8
619
172
N, K = list(map(int, input().split())) S = str(eval(input())) def run_length_encoding(text: str) -> list: text += "_" c = text[0] x = 1 res = [] for i in range(1, len(text)): if c == text[i]: x += 1 else: res.append((c, x)) c = text[i] ...
# 解説配信の模範解答 N, K = list(map(int, input().split())) S = str(eval(input())) score = 0 for i in range(N - 1): if S[i] == S[i + 1]: score += 1 ans = min(score + 2 * K, N - 1) print(ans)
false
75.757576
[ "+# 解説配信の模範解答", "-", "-", "-def run_length_encoding(text: str) -> list:", "- text += \"_\"", "- c = text[0]", "- x = 1", "- res = []", "- for i in range(1, len(text)):", "- if c == text[i]:", "- x += 1", "- else:", "- res.append((c, x))", ...
false
0.061481
0.118293
0.519736
[ "s206693514", "s672109398" ]
u461993794
p02785
python
s746341020
s724506746
623
146
121,320
104,760
Accepted
Accepted
76.57
n, k = list(map(int, input().split())) h = list(map(int, input().split())) h.sort(reverse=True) if k > n: print((0)) else: print((sum(h[k:])))
n, k = list(map(int, input().split())) h = list(map(int, input().split())) h.sort(reverse=True) print((sum(h[k:])))
8
5
149
113
n, k = list(map(int, input().split())) h = list(map(int, input().split())) h.sort(reverse=True) if k > n: print((0)) else: print((sum(h[k:])))
n, k = list(map(int, input().split())) h = list(map(int, input().split())) h.sort(reverse=True) print((sum(h[k:])))
false
37.5
[ "-if k > n:", "- print((0))", "-else:", "- print((sum(h[k:])))", "+print((sum(h[k:])))" ]
false
0.088886
0.08202
1.083711
[ "s746341020", "s724506746" ]
u540761833
p03937
python
s318862779
s386651819
23
17
3,444
2,940
Accepted
Accepted
26.09
import copy from collections import deque H,W = list(map(int,input().split())) A = [] for i in range(H): A.append(list(eval(input()))) now = [0,0] goal = [H-1,W-1] x1 = [0,1] y1 = [1,0] alr = copy.deepcopy(A) alr[0][0] = 1 que = deque() que.append(now) while que: q = que.popleft() for i in r...
H,W = list(map(int,input().split())) suma = 0 for i in range(H): a = eval(input()) suma += a.count('#') if suma == H+W-1: print('Possible') else: print('Impossible')
41
9
1,009
178
import copy from collections import deque H, W = list(map(int, input().split())) A = [] for i in range(H): A.append(list(eval(input()))) now = [0, 0] goal = [H - 1, W - 1] x1 = [0, 1] y1 = [1, 0] alr = copy.deepcopy(A) alr[0][0] = 1 que = deque() que.append(now) while que: q = que.popleft() for i in range(...
H, W = list(map(int, input().split())) suma = 0 for i in range(H): a = eval(input()) suma += a.count("#") if suma == H + W - 1: print("Possible") else: print("Impossible")
false
78.04878
[ "-import copy", "-from collections import deque", "-", "-A = []", "+suma = 0", "- A.append(list(eval(input())))", "-now = [0, 0]", "-goal = [H - 1, W - 1]", "-x1 = [0, 1]", "-y1 = [1, 0]", "-alr = copy.deepcopy(A)", "-alr[0][0] = 1", "-que = deque()", "-que.append(now)", "-while que:"...
false
0.007834
0.17172
0.045619
[ "s318862779", "s386651819" ]
u843175622
p02598
python
s304349934
s620445241
231
188
52,664
52,636
Accepted
Accepted
18.61
from sys import stdin import numpy as np n, k = list(map(int, stdin.readline().split())) a = np.array(stdin.readline().split(), dtype=np.int64) ng = 0 ok = 10 ** 9 + 1 while ok - ng > 1: mid = (ok + ng) >> 1 if np.sum(0 - - a // mid - 1) <= k: ok = mid else: ng = mid print(ok)
from sys import stdin import numpy as np n, k = list(map(int, stdin.readline().split())) a = np.array(stdin.readline().split(), dtype=np.int64) ng = 0 ok = 10 ** 9 + 1 while ok - ng > 1: mid = (ok + ng) >> 1 if np.sum(np.ceil(a / mid) - 1) <= k: ok = mid else: ng = mid print(ok...
14
14
314
316
from sys import stdin import numpy as np n, k = list(map(int, stdin.readline().split())) a = np.array(stdin.readline().split(), dtype=np.int64) ng = 0 ok = 10**9 + 1 while ok - ng > 1: mid = (ok + ng) >> 1 if np.sum(0 - -a // mid - 1) <= k: ok = mid else: ng = mid print(ok)
from sys import stdin import numpy as np n, k = list(map(int, stdin.readline().split())) a = np.array(stdin.readline().split(), dtype=np.int64) ng = 0 ok = 10**9 + 1 while ok - ng > 1: mid = (ok + ng) >> 1 if np.sum(np.ceil(a / mid) - 1) <= k: ok = mid else: ng = mid print(ok)
false
0
[ "- if np.sum(0 - -a // mid - 1) <= k:", "+ if np.sum(np.ceil(a / mid) - 1) <= k:" ]
false
0.333765
0.620662
0.537756
[ "s304349934", "s620445241" ]
u923270446
p02947
python
s671421185
s885127807
467
292
24,560
28,768
Accepted
Accepted
37.47
import collections n=int(eval(input())) s=[str(sorted(eval(input())))for i in range(n)] c=collections.Counter(s) l=sum((i*(i-1)/2)for i in list(c.values())) print((int(l)))
import collections n=int(eval(input())) print((int(sum((i*(i-1)/2)for i in list(collections.Counter([str(sorted(eval(input())))for i in range(n)]).values())))))
6
3
157
142
import collections n = int(eval(input())) s = [str(sorted(eval(input()))) for i in range(n)] c = collections.Counter(s) l = sum((i * (i - 1) / 2) for i in list(c.values())) print((int(l)))
import collections n = int(eval(input())) print( ( int( sum( (i * (i - 1) / 2) for i in list( collections.Counter( [str(sorted(eval(input()))) for i in range(n)] ).values() ) ...
false
50
[ "-s = [str(sorted(eval(input()))) for i in range(n)]", "-c = collections.Counter(s)", "-l = sum((i * (i - 1) / 2) for i in list(c.values()))", "-print((int(l)))", "+print(", "+ (", "+ int(", "+ sum(", "+ (i * (i - 1) / 2)", "+ for i in list(", "...
false
0.102167
0.079634
1.282955
[ "s671421185", "s885127807" ]
u905582793
p02965
python
s118269750
s086311311
1,342
838
115,684
115,556
Accepted
Accepted
37.56
n,m=list(map(int,input().split())) w,u=3*m,n-1 o,f,i=998244353,[1],1 while i<w+n:f+=[f[-1]*i%o];i+=1 c=lambda n,k=u:f[n]*pow(f[n-k],o-2,o)*pow(f[k],o-2,o) a=c(w+u)-n*c(n+m-2) while~-n>m<w:m+=2;a-=c(n,m)*c(2*u+w-m>>1) print((a%o))
n,m=list(map(int,input().split())) o,f,i=998244353,[1],1 while i<3*m+n:f+=[f[-1]*i%o];i+=1 c=lambda x,y=n-1:f[x]*pow(f[x-y]*f[y]%o,o-2,o) a=c(-1)-n*c(n+m-2) while~-n>m<i-n:m+=2;a-=c(n,m)*c(n-1+i-m>>1) print((a%o))
8
7
228
211
n, m = list(map(int, input().split())) w, u = 3 * m, n - 1 o, f, i = 998244353, [1], 1 while i < w + n: f += [f[-1] * i % o] i += 1 c = lambda n, k=u: f[n] * pow(f[n - k], o - 2, o) * pow(f[k], o - 2, o) a = c(w + u) - n * c(n + m - 2) while ~-n > m < w: m += 2 a -= c(n, m) * c(2 * u + w - m >> 1) print...
n, m = list(map(int, input().split())) o, f, i = 998244353, [1], 1 while i < 3 * m + n: f += [f[-1] * i % o] i += 1 c = lambda x, y=n - 1: f[x] * pow(f[x - y] * f[y] % o, o - 2, o) a = c(-1) - n * c(n + m - 2) while ~-n > m < i - n: m += 2 a -= c(n, m) * c(n - 1 + i - m >> 1) print((a % o))
false
12.5
[ "-w, u = 3 * m, n - 1", "-while i < w + n:", "+while i < 3 * m + n:", "-c = lambda n, k=u: f[n] * pow(f[n - k], o - 2, o) * pow(f[k], o - 2, o)", "-a = c(w + u) - n * c(n + m - 2)", "-while ~-n > m < w:", "+c = lambda x, y=n - 1: f[x] * pow(f[x - y] * f[y] % o, o - 2, o)", "+a = c(-1) - n * c(n + m - ...
false
0.149721
0.23651
0.633041
[ "s118269750", "s086311311" ]
u744034042
p02714
python
s806650415
s571051554
1,506
1,016
9,388
9,216
Accepted
Accepted
32.54
n = int(eval(input())) s = list(eval(input())) cnt = 0 for i in range(1,n-1): if s[i] == 'R': cnt += (s[:i].count('G'))*(s[i+1:].count('B')) + (s[:i].count('B'))*(s[i+1:].count('G')) if s[i] == 'G': cnt += (s[:i].count('R'))*(s[i+1:].count('B')) + (s[:i].count('B'))*(s[i+1:].count('R')) ...
n = int(eval(input())) s = list(eval(input())) cnt = 0 cnt += s.count('R')*s.count('G')*s.count('B') for i in range(1,n-1): if s[i] == 'R': for j in range(1,min(i,n-i-1)+1): if s[i-j] == 'G' and s[i+j]=='B': cnt -=1 if s[i-j] == 'B' and s[i+j]=='G': ...
30
24
1,085
751
n = int(eval(input())) s = list(eval(input())) cnt = 0 for i in range(1, n - 1): if s[i] == "R": cnt += (s[:i].count("G")) * (s[i + 1 :].count("B")) + (s[:i].count("B")) * ( s[i + 1 :].count("G") ) if s[i] == "G": cnt += (s[:i].count("R")) * (s[i + 1 :].count("B")) + (s[:i].c...
n = int(eval(input())) s = list(eval(input())) cnt = 0 cnt += s.count("R") * s.count("G") * s.count("B") for i in range(1, n - 1): if s[i] == "R": for j in range(1, min(i, n - i - 1) + 1): if s[i - j] == "G" and s[i + j] == "B": cnt -= 1 if s[i - j] == "B" and s[i + j...
false
20
[ "-for i in range(1, n - 1):", "- if s[i] == \"R\":", "- cnt += (s[:i].count(\"G\")) * (s[i + 1 :].count(\"B\")) + (s[:i].count(\"B\")) * (", "- s[i + 1 :].count(\"G\")", "- )", "- if s[i] == \"G\":", "- cnt += (s[:i].count(\"R\")) * (s[i + 1 :].count(\"B\")) + (s[:i...
false
0.081781
0.076178
1.073555
[ "s806650415", "s571051554" ]
u888092736
p02972
python
s984160115
s394468349
659
240
14,132
17,200
Accepted
Accepted
63.58
N = int(eval(input())) A = list(map(int, input().split())) res = [0] * N for i in range(N, 0, -1): tmp = 0 for j in range(i * (N // i), i, -i): tmp += res[j - 1] if A[i - 1] != (tmp + res[i - 1]) % 2: res[i - 1] ^= 1 print((sum(res))) ans = [i + 1 for i, v in enumerate(res) if v ==...
N = int(eval(input())) A = [0] + list(map(int, input().split())) for i in range(N, 0, -1): A[i] = sum(A[i::i]) % 2 print((sum(A))) ans = [i for i, v in enumerate(A) if v] print((*[i for i, v in enumerate(A) if v]))
13
7
342
215
N = int(eval(input())) A = list(map(int, input().split())) res = [0] * N for i in range(N, 0, -1): tmp = 0 for j in range(i * (N // i), i, -i): tmp += res[j - 1] if A[i - 1] != (tmp + res[i - 1]) % 2: res[i - 1] ^= 1 print((sum(res))) ans = [i + 1 for i, v in enumerate(res) if v == 1] if ans...
N = int(eval(input())) A = [0] + list(map(int, input().split())) for i in range(N, 0, -1): A[i] = sum(A[i::i]) % 2 print((sum(A))) ans = [i for i, v in enumerate(A) if v] print((*[i for i, v in enumerate(A) if v]))
false
46.153846
[ "-A = list(map(int, input().split()))", "-res = [0] * N", "+A = [0] + list(map(int, input().split()))", "- tmp = 0", "- for j in range(i * (N // i), i, -i):", "- tmp += res[j - 1]", "- if A[i - 1] != (tmp + res[i - 1]) % 2:", "- res[i - 1] ^= 1", "-print((sum(res)))", "-ans ...
false
0.037675
0.041689
0.90371
[ "s984160115", "s394468349" ]
u841531687
p02983
python
s498778356
s113204386
683
424
3,060
129,228
Accepted
Accepted
37.92
L, R = list(map(int, input().split())) if R - L >= 2019: mn = 0 else: l, r = L % 2019, R % 2019 mn = 2018 ** 2 for i in range(l, r + 1): for j in range(i + 1, r + 1): mn = min(mn, i * j % 2019) print(mn)
from itertools import combinations l, r = list(map(int, input().split())) ans = 2020 if r - l >= 2019: ans = 0 else: for i, j in list(combinations(list(range(l, r+1)), 2)): ans = min(ans, (i*j)%2019) print(ans)
10
12
242
236
L, R = list(map(int, input().split())) if R - L >= 2019: mn = 0 else: l, r = L % 2019, R % 2019 mn = 2018**2 for i in range(l, r + 1): for j in range(i + 1, r + 1): mn = min(mn, i * j % 2019) print(mn)
from itertools import combinations l, r = list(map(int, input().split())) ans = 2020 if r - l >= 2019: ans = 0 else: for i, j in list(combinations(list(range(l, r + 1)), 2)): ans = min(ans, (i * j) % 2019) print(ans)
false
16.666667
[ "-L, R = list(map(int, input().split()))", "-if R - L >= 2019:", "- mn = 0", "+from itertools import combinations", "+", "+l, r = list(map(int, input().split()))", "+ans = 2020", "+if r - l >= 2019:", "+ ans = 0", "- l, r = L % 2019, R % 2019", "- mn = 2018**2", "- for i in rang...
false
0.098586
0.196393
0.501984
[ "s498778356", "s113204386" ]
u057109575
p02720
python
s608314828
s669685503
448
212
100,856
45,148
Accepted
Accepted
52.68
K = int(eval(input())) def dfs(d, val, x): x.append(val) if d == 10: return for i in range(-1, 2): add = (val % 10) + i if 0 <= add <= 9: dfs(d + 1, val * 10 + add, x) x = [] for i in range(1, 10): dfs(0, i, x) print((sorted(x)[K - 1]))
from collections import deque K = int(eval(input())) q = deque(list(range(1, 10))) ctr = 0 while ctr < K: val = q.popleft() ctr += 1 for i in range(-1, 2): add = (val % 10) + i if 0 <= add <= 9: q.append(val * 10 + add) print(val)
17
15
309
294
K = int(eval(input())) def dfs(d, val, x): x.append(val) if d == 10: return for i in range(-1, 2): add = (val % 10) + i if 0 <= add <= 9: dfs(d + 1, val * 10 + add, x) x = [] for i in range(1, 10): dfs(0, i, x) print((sorted(x)[K - 1]))
from collections import deque K = int(eval(input())) q = deque(list(range(1, 10))) ctr = 0 while ctr < K: val = q.popleft() ctr += 1 for i in range(-1, 2): add = (val % 10) + i if 0 <= add <= 9: q.append(val * 10 + add) print(val)
false
11.764706
[ "+from collections import deque", "+", "-", "-", "-def dfs(d, val, x):", "- x.append(val)", "- if d == 10:", "- return", "+q = deque(list(range(1, 10)))", "+ctr = 0", "+while ctr < K:", "+ val = q.popleft()", "+ ctr += 1", "- dfs(d + 1, val * 10 + add, x)", ...
false
0.925704
0.101772
9.095844
[ "s608314828", "s669685503" ]
u200887663
p03611
python
s153336335
s156287678
143
127
14,008
20,892
Accepted
Accepted
11.19
n=int(eval(input())) al=list(map(int,input().split())) dic={} for v in al: if not v in list(dic.keys()): dic[v]=1 else: dic[v]=dic[v]+1 count_l=[] for v in range(min(al)-1,max(al)+2): count=0 count=dic.get(v-1,0)+dic.get(v,0)+dic.get(v+1,0) count_l.append(count) print(...
n = int(eval(input())) #a, b = map(int,input().split()) al = list(map(int, input().split())) #l = [list(map(int,input().split())) for i in range(n)] dic = {} for a in al: dic[a] = dic.get(a, 0)+1 mx = max(al) mn = min(al) ans = 0 for x in range(mn, mx+1): ans = max(ans, dic.get(x+1, 0)+dic.get(x,...
15
15
321
347
n = int(eval(input())) al = list(map(int, input().split())) dic = {} for v in al: if not v in list(dic.keys()): dic[v] = 1 else: dic[v] = dic[v] + 1 count_l = [] for v in range(min(al) - 1, max(al) + 2): count = 0 count = dic.get(v - 1, 0) + dic.get(v, 0) + dic.get(v + 1, 0) count_l....
n = int(eval(input())) # a, b = map(int,input().split()) al = list(map(int, input().split())) # l = [list(map(int,input().split())) for i in range(n)] dic = {} for a in al: dic[a] = dic.get(a, 0) + 1 mx = max(al) mn = min(al) ans = 0 for x in range(mn, mx + 1): ans = max(ans, dic.get(x + 1, 0) + dic.get(x, 0) +...
false
0
[ "+# a, b = map(int,input().split())", "+# l = [list(map(int,input().split())) for i in range(n)]", "-for v in al:", "- if not v in list(dic.keys()):", "- dic[v] = 1", "- else:", "- dic[v] = dic[v] + 1", "-count_l = []", "-for v in range(min(al) - 1, max(al) + 2):", "- count ...
false
0.046656
0.035799
1.30327
[ "s153336335", "s156287678" ]
u285891772
p02685
python
s705215511
s867046840
1,040
670
25,588
25,436
Accepted
Accepted
35.58
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby from operator import itemge...
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby from operator import itemge...
50
41
1,371
1,254
import sys, re from collections import deque, defaultdict, Counter from math import ( ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd, ) from itertools import ( accumulate, permutations, combinations, ...
import sys, re from collections import deque, defaultdict, Counter from math import ( ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd, ) from itertools import ( accumulate, permutations, combinations, ...
false
18
[ "-", "-", "-def power(x, n, p):", "- ans = 1", "- while n:", "- if n % 2:", "- ans = ans * x % p", "- x = x * x % p", "- n >>= 1", "- return ans", "-", "-", "-fact_inv[lim] = power(fact[lim], mod - 2, mod)", "+fact_inv[lim] = pow(fact[lim], mod - 2,...
false
0.639854
0.593838
1.077489
[ "s705215511", "s867046840" ]
u633068244
p00173
python
s426937269
s269049459
20
10
4,192
4,192
Accepted
Accepted
50
for i in range(9): a,b,c = list(map(str, input().split())) print(a,int(b)+int(c),200*int(b)+300*int(c))
for i in range(9): a,b,c = list(map(str, input().split())) b,c = int(b),int(c) print(a,b+c,200*b+300*c)
3
4
110
115
for i in range(9): a, b, c = list(map(str, input().split())) print(a, int(b) + int(c), 200 * int(b) + 300 * int(c))
for i in range(9): a, b, c = list(map(str, input().split())) b, c = int(b), int(c) print(a, b + c, 200 * b + 300 * c)
false
25
[ "- print(a, int(b) + int(c), 200 * int(b) + 300 * int(c))", "+ b, c = int(b), int(c)", "+ print(a, b + c, 200 * b + 300 * c)" ]
false
0.049973
0.116112
0.430388
[ "s426937269", "s269049459" ]
u207850265
p02770
python
s621272648
s028443551
1,442
833
21,788
14,816
Accepted
Accepted
42.23
import numpy as np k, q = list(map(int, input().split())) d = np.array(list(map(int, input().split())), dtype=np.int64) queries = [tuple(map(int, input().split())) for _ in range(q)] for n, x, m in queries: d_mod = d % m rem_d_mod = d_mod[: (n - 1) % k] print((n - 1 - (x % m + ((n - 1) // k) * ...
import numpy as np k, q = list(map(int, input().split())) d = np.array(list(map(int, input().split()))).astype(np.int64) queries = [tuple(map(int, input().split())) for _ in range(q)] for n, x, m in queries: d_mod = d % m quotient, rem = divmod(n - 1, k) rem_d_mod = d_mod[:rem] print((n - ...
12
13
448
466
import numpy as np k, q = list(map(int, input().split())) d = np.array(list(map(int, input().split())), dtype=np.int64) queries = [tuple(map(int, input().split())) for _ in range(q)] for n, x, m in queries: d_mod = d % m rem_d_mod = d_mod[: (n - 1) % k] print( ( n - 1 ...
import numpy as np k, q = list(map(int, input().split())) d = np.array(list(map(int, input().split()))).astype(np.int64) queries = [tuple(map(int, input().split())) for _ in range(q)] for n, x, m in queries: d_mod = d % m quotient, rem = divmod(n - 1, k) rem_d_mod = d_mod[:rem] print( ( ...
false
7.692308
[ "-d = np.array(list(map(int, input().split())), dtype=np.int64)", "+d = np.array(list(map(int, input().split()))).astype(np.int64)", "- rem_d_mod = d_mod[: (n - 1) % k]", "+ quotient, rem = divmod(n - 1, k)", "+ rem_d_mod = d_mod[:rem]", "- - (x % m + ((n - 1) // k) * np.sum(d_mod) + n...
false
0.532442
0.445631
1.194804
[ "s621272648", "s028443551" ]
u530606147
p03262
python
s574598510
s702376420
98
90
14,224
14,252
Accepted
Accepted
8.16
n, X = list(map(int, input().split())) x = list(map(int, input().split())) d = [abs(e - X) for e in x] import fractions g=0 for e in d: g=fractions.gcd(e,g) print(g)
n, X = list(map(int, input().split())) x = list(map(int, input().split())) d = [abs(e - X) for e in x] import fractions from functools import reduce # g=0 # for e in d: # g=fractions.gcd(e,g) # print(g) print((reduce(fractions.gcd, d)))
10
13
179
252
n, X = list(map(int, input().split())) x = list(map(int, input().split())) d = [abs(e - X) for e in x] import fractions g = 0 for e in d: g = fractions.gcd(e, g) print(g)
n, X = list(map(int, input().split())) x = list(map(int, input().split())) d = [abs(e - X) for e in x] import fractions from functools import reduce # g=0 # for e in d: # g=fractions.gcd(e,g) # print(g) print((reduce(fractions.gcd, d)))
false
23.076923
[ "+from functools import reduce", "-g = 0", "-for e in d:", "- g = fractions.gcd(e, g)", "-print(g)", "+# g=0", "+# for e in d:", "+# g=fractions.gcd(e,g)", "+# print(g)", "+print((reduce(fractions.gcd, d)))" ]
false
0.047566
0.046464
1.023706
[ "s574598510", "s702376420" ]
u273345915
p02726
python
s435664636
s490882799
1,673
1,184
3,572
3,444
Accepted
Accepted
29.23
import itertools N,X,Y=list(map(int, input().split())) l=list(range(1,N+1)) cnt=[0]*(N-1) for p in itertools.combinations(l, 2): a=p[1]-p[0] b=abs(p[1]-Y)+abs(p[0]-X)+1 cnt[min(a,b)-1]+=1 for k in cnt: print(k)
N,X,Y=list(map(int, input().split())) ans=[0]*(N-1) for i in range(1,N): for j in range(i+1, N+1): ans[min(j-i, abs(j-Y)+abs(i-X)+1)-1]+=1 for a in ans: print(a)
14
7
237
177
import itertools N, X, Y = list(map(int, input().split())) l = list(range(1, N + 1)) cnt = [0] * (N - 1) for p in itertools.combinations(l, 2): a = p[1] - p[0] b = abs(p[1] - Y) + abs(p[0] - X) + 1 cnt[min(a, b) - 1] += 1 for k in cnt: print(k)
N, X, Y = list(map(int, input().split())) ans = [0] * (N - 1) for i in range(1, N): for j in range(i + 1, N + 1): ans[min(j - i, abs(j - Y) + abs(i - X) + 1) - 1] += 1 for a in ans: print(a)
false
50
[ "-import itertools", "-", "-l = list(range(1, N + 1))", "-cnt = [0] * (N - 1)", "-for p in itertools.combinations(l, 2):", "- a = p[1] - p[0]", "- b = abs(p[1] - Y) + abs(p[0] - X) + 1", "- cnt[min(a, b) - 1] += 1", "-for k in cnt:", "- print(k)", "+ans = [0] * (N - 1)", "+for i in...
false
0.036686
0.064355
0.570062
[ "s435664636", "s490882799" ]
u353895424
p03107
python
s554765778
s788068012
191
56
48,240
3,188
Accepted
Accepted
70.68
import sys input = sys.stdin.readline S=[] s=eval(input()) for c in s: S.append(c) S.pop(-1) print((2*min(S.count("0"), S.count("1"))))
s = eval(input()) n = len(s) r = 0 b = 0 ans = 0 for i in range(n): if s[i] == "0": r += 1 elif s[i] == "1": b += 1 if 0 < r and 0 < b: r -= 1 b -= 1 ans += 2 print(ans)
9
20
144
247
import sys input = sys.stdin.readline S = [] s = eval(input()) for c in s: S.append(c) S.pop(-1) print((2 * min(S.count("0"), S.count("1"))))
s = eval(input()) n = len(s) r = 0 b = 0 ans = 0 for i in range(n): if s[i] == "0": r += 1 elif s[i] == "1": b += 1 if 0 < r and 0 < b: r -= 1 b -= 1 ans += 2 print(ans)
false
55
[ "-import sys", "-", "-input = sys.stdin.readline", "-S = []", "-for c in s:", "- S.append(c)", "-S.pop(-1)", "-print((2 * min(S.count(\"0\"), S.count(\"1\"))))", "+n = len(s)", "+r = 0", "+b = 0", "+ans = 0", "+for i in range(n):", "+ if s[i] == \"0\":", "+ r += 1", "+ ...
false
0.054612
0.037068
1.473292
[ "s554765778", "s788068012" ]
u864197622
p02737
python
s831345748
s352343910
1,469
619
78,112
69,808
Accepted
Accepted
57.86
def calc(): def mex(i): D = {} for j in X[i]: D[G[j]] = 1 for g in range(N + 1): if g not in D: return g M = int(eval(input())) X = [[] for _ in range(N)] for _ in range(M): a, b = list(map(int, input().split())) ...
import sys input = lambda: sys.stdin.readline().rstrip() def calc(): def mex(i): t = 0 for j in X[i]: t |= 1 << G[j] t = ~t return (t & -t).bit_length() - 1 M = int(eval(input())) X = [[] for _ in range(N)] for _ in range(M): a, b = list(...
35
37
824
859
def calc(): def mex(i): D = {} for j in X[i]: D[G[j]] = 1 for g in range(N + 1): if g not in D: return g M = int(eval(input())) X = [[] for _ in range(N)] for _ in range(M): a, b = list(map(int, input().split())) X[N - min(...
import sys input = lambda: sys.stdin.readline().rstrip() def calc(): def mex(i): t = 0 for j in X[i]: t |= 1 << G[j] t = ~t return (t & -t).bit_length() - 1 M = int(eval(input())) X = [[] for _ in range(N)] for _ in range(M): a, b = list(map(int, i...
false
5.405405
[ "+import sys", "+", "+input = lambda: sys.stdin.readline().rstrip()", "+", "+", "- D = {}", "+ t = 0", "- D[G[j]] = 1", "- for g in range(N + 1):", "- if g not in D:", "- return g", "+ t |= 1 << G[j]", "+ t = ~t", ...
false
0.515673
0.306263
1.683761
[ "s831345748", "s352343910" ]
u064505481
p03178
python
s558784640
s190125815
1,477
1,189
130,012
44,988
Accepted
Accepted
19.5
from sys import stdin, stdout from collections import deque, defaultdict from functools import lru_cache rl = lambda: stdin.readline() rll = lambda: stdin.readline().split() rli = lambda: list(map(int, stdin.readline().split())) INF, NINF = float('inf'), float('-inf') def main(): MOD = 10**9 + 7 x = []...
from sys import stdin, stdout from collections import deque, defaultdict from functools import lru_cache rl = lambda: stdin.readline() rll = lambda: stdin.readline().split() rli = lambda: list(map(int, stdin.readline().split())) INF, NINF = float('inf'), float('-inf') def main(): MOD = 10**9 + 7 x = []...
35
37
879
866
from sys import stdin, stdout from collections import deque, defaultdict from functools import lru_cache rl = lambda: stdin.readline() rll = lambda: stdin.readline().split() rli = lambda: list(map(int, stdin.readline().split())) INF, NINF = float("inf"), float("-inf") def main(): MOD = 10**9 + 7 x = [] f...
from sys import stdin, stdout from collections import deque, defaultdict from functools import lru_cache rl = lambda: stdin.readline() rll = lambda: stdin.readline().split() rli = lambda: list(map(int, stdin.readline().split())) INF, NINF = float("inf"), float("-inf") def main(): MOD = 10**9 + 7 x = [] f...
false
5.405405
[ "- dp = [[[0] * 2 for j in range(d)] for i in range(len(x) + 1)]", "- dp[0][0][1] = 1", "+ dp = [[0] * 2 for _ in range(d)]", "+ dp[0][1] = 1", "+ ndp = [[0] * 2 for _ in range(d)]", "- for dig in range(x[i] + 1 if tight else 10):", "- ns = (digsum + ...
false
0.049227
0.048099
1.023449
[ "s558784640", "s190125815" ]
u941753895
p03329
python
s178552057
s597136205
415
363
3,828
3,828
Accepted
Accepted
12.53
N=int(eval(input())) l=[1,6,9,36,81,216,729,1296,6561,7776,46656,59049] l2=[0]*100001 for i in range(1,100001): mn=100000000000000000 for x in l: if i-x>=0 and l2[i-x]<mn: mn=l2[i-x]+1 l2[i]=mn print((l2[N]))
l=[1,6,9,36,81,216,729,1296,6561,7776,46656,59049] l2=[0]*100001 N=int(eval(input())) for i in range(1,N+1): mn=100000000000000000 for x in l: if i-x>=0 and l2[i-x]<mn: mn=l2[i-x]+1 l2[i]=mn print((l2[N]))
11
13
227
228
N = int(eval(input())) l = [1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049] l2 = [0] * 100001 for i in range(1, 100001): mn = 100000000000000000 for x in l: if i - x >= 0 and l2[i - x] < mn: mn = l2[i - x] + 1 l2[i] = mn print((l2[N]))
l = [1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049] l2 = [0] * 100001 N = int(eval(input())) for i in range(1, N + 1): mn = 100000000000000000 for x in l: if i - x >= 0 and l2[i - x] < mn: mn = l2[i - x] + 1 l2[i] = mn print((l2[N]))
false
15.384615
[ "-N = int(eval(input()))", "-for i in range(1, 100001):", "+N = int(eval(input()))", "+for i in range(1, N + 1):" ]
false
1.194839
0.085844
13.918659
[ "s178552057", "s597136205" ]
u241159583
p03745
python
s078419596
s693857167
95
74
14,228
14,252
Accepted
Accepted
22.11
N = int(eval(input())) A = list(map(int, input().split())) ans = 0 plus = "" for i in range(N): if plus != "": if plus: if A[i-1] > A[i]: ans += 1 plus = "" else: if A[i-1] < A[i]: ans += 1 plus = "" if i < N-1 and plus == "": if A[i] < A[i+1]...
n = int(eval(input())) a = list(map(int, input().split())) before = a[0] ok = "" #増加ならTrue cnt = 0 for i in range(1,n): if ok == "": if before < a[i]: ok = True elif before > a[i]: ok = False elif ok: if before > a[i]: cnt += 1 ok = "" elif not ok: if befo...
21
22
393
386
N = int(eval(input())) A = list(map(int, input().split())) ans = 0 plus = "" for i in range(N): if plus != "": if plus: if A[i - 1] > A[i]: ans += 1 plus = "" else: if A[i - 1] < A[i]: ans += 1 plus = "" if i...
n = int(eval(input())) a = list(map(int, input().split())) before = a[0] ok = "" # 増加ならTrue cnt = 0 for i in range(1, n): if ok == "": if before < a[i]: ok = True elif before > a[i]: ok = False elif ok: if before > a[i]: cnt += 1 ok = "" ...
false
4.545455
[ "-N = int(eval(input()))", "-A = list(map(int, input().split()))", "-ans = 0", "-plus = \"\"", "-for i in range(N):", "- if plus != \"\":", "- if plus:", "- if A[i - 1] > A[i]:", "- ans += 1", "- plus = \"\"", "- else:", "- i...
false
0.042288
0.11242
0.376164
[ "s078419596", "s693857167" ]
u671060652
p03211
python
s125161966
s592245961
264
99
63,980
61,416
Accepted
Accepted
62.5
import itertools import math import fractions import functools import copy n = eval(input()) minimum = 1000 for i in range(len(n)-2): num = int(n[i:i+3]) minimum = min(minimum,abs(num-753)) print(minimum)
def main(): # n = int(input()) # t, a = map(int, input().split()) # h = list(map(int, input().split())) s = eval(input()) mini = 10**10 for i in range(len(s)-2): mini = min(mini, abs(int(s[i:i+3]) - 753)) print(mini) if __name__ == '__main__': main()
12
14
219
301
import itertools import math import fractions import functools import copy n = eval(input()) minimum = 1000 for i in range(len(n) - 2): num = int(n[i : i + 3]) minimum = min(minimum, abs(num - 753)) print(minimum)
def main(): # n = int(input()) # t, a = map(int, input().split()) # h = list(map(int, input().split())) s = eval(input()) mini = 10**10 for i in range(len(s) - 2): mini = min(mini, abs(int(s[i : i + 3]) - 753)) print(mini) if __name__ == "__main__": main()
false
14.285714
[ "-import itertools", "-import math", "-import fractions", "-import functools", "-import copy", "+def main():", "+ # n = int(input())", "+ # t, a = map(int, input().split())", "+ # h = list(map(int, input().split()))", "+ s = eval(input())", "+ mini = 10**10", "+ for i in rang...
false
0.036264
0.03553
1.020665
[ "s125161966", "s592245961" ]
u189023301
p02960
python
s829896305
s306860907
1,590
1,120
44,892
61,532
Accepted
Accepted
29.56
from collections import defaultdict s = input()[::-1] mod = 13 p = 10 ** 9 + 7 dic = defaultdict(int) dic[0] = 1 for i in range(len(s)): tmp = defaultdict(int) if s[i] == "?": for j in range(10): d = j * pow(10, i, mod) for k, v in list(dic.items()): ...
s = input()[::-1] mod = 13 p = 10 ** 9 + 7 dp = [[0] * 13 for _ in range(len(s) + 1)] dp[0][0] = 1 for i in range(len(s)): if s[i] == "?": for j in range(10): d = j * pow(10, i, mod) for k in range(13): dp[i + 1][(k + d) % mod] += dp[i][k] ...
21
18
536
500
from collections import defaultdict s = input()[::-1] mod = 13 p = 10**9 + 7 dic = defaultdict(int) dic[0] = 1 for i in range(len(s)): tmp = defaultdict(int) if s[i] == "?": for j in range(10): d = j * pow(10, i, mod) for k, v in list(dic.items()): tmp[(k + d) % ...
s = input()[::-1] mod = 13 p = 10**9 + 7 dp = [[0] * 13 for _ in range(len(s) + 1)] dp[0][0] = 1 for i in range(len(s)): if s[i] == "?": for j in range(10): d = j * pow(10, i, mod) for k in range(13): dp[i + 1][(k + d) % mod] += dp[i][k] dp[i + 1][(k +...
false
14.285714
[ "-from collections import defaultdict", "-", "-dic = defaultdict(int)", "-dic[0] = 1", "+dp = [[0] * 13 for _ in range(len(s) + 1)]", "+dp[0][0] = 1", "- tmp = defaultdict(int)", "- for k, v in list(dic.items()):", "- tmp[(k + d) % mod] += v", "- tmp[(k ...
false
0.044157
0.070503
0.626312
[ "s829896305", "s306860907" ]
u083960235
p03680
python
s760930476
s197211745
123
107
9,152
15,272
Accepted
Accepted
13.01
# 要復習 import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase...
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii...
44
41
1,057
1,125
# 要復習 import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii...
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_upper...
false
6.818182
[ "-# 要復習", "-from bisect import bisect", "+from bisect import bisect, bisect_left, bisect_right", "-", "-", "-def main():", "- N = INT()", "- A = [INT() for i in range(N)]", "- visited = []", "- n = 0", "- ans = 0", "- while ans < N:", "- n = A[n] - 1", "- an...
false
0.037133
0.037368
0.993706
[ "s760930476", "s197211745" ]
u600402037
p04045
python
s572588784
s952926367
76
17
2,940
3,064
Accepted
Accepted
77.63
N, K = list(map(int, input().split())) D = set(input().split()) while True: l = list(str(N)) for x in l: if x in D: N += 1 break else: print(N) exit()
N, K = list(map(int, input().split())) D = set(map(int, input().split())) safe = set(range(10)) - D def test(N): return set((int(x) for x in str(N))) <= safe def F(N): while N % 10: if test(N): return N N += 1 N //= 10 x = F(N) y = min(safe) return 10...
12
20
217
357
N, K = list(map(int, input().split())) D = set(input().split()) while True: l = list(str(N)) for x in l: if x in D: N += 1 break else: print(N) exit()
N, K = list(map(int, input().split())) D = set(map(int, input().split())) safe = set(range(10)) - D def test(N): return set((int(x) for x in str(N))) <= safe def F(N): while N % 10: if test(N): return N N += 1 N //= 10 x = F(N) y = min(safe) return 10 * x + y an...
false
40
[ "-D = set(input().split())", "-while True:", "- l = list(str(N))", "- for x in l:", "- if x in D:", "- N += 1", "- break", "- else:", "- print(N)", "- exit()", "+D = set(map(int, input().split()))", "+safe = set(range(10)) - D", "+", "+",...
false
0.083745
0.08299
1.009097
[ "s572588784", "s952926367" ]
u139614630
p02661
python
s880567855
s497155565
589
378
101,276
101,432
Accepted
Accepted
35.82
#!/usr/bin/env python3 import sys from itertools import chain import numpy as np # from itertools import combinations as comb # form bisect import bisect_left, bisect_right, insort_left, insort_right # from collections import Counter def solve(N: int, A: "List[int]", B: "List[int]"): A = sorted(A) ...
#!/usr/bin/env python3 import sys from itertools import chain import numpy as np # from itertools import combinations as comb # form bisect import bisect_left, bisect_right, insort_left, insort_right # from collections import Counter def solve(N: int, A: "List[int]", B: "List[int]"): A = np.sort(A) ...
36
36
890
892
#!/usr/bin/env python3 import sys from itertools import chain import numpy as np # from itertools import combinations as comb # form bisect import bisect_left, bisect_right, insort_left, insort_right # from collections import Counter def solve(N: int, A: "List[int]", B: "List[int]"): A = sorted(A) B = sorted(B...
#!/usr/bin/env python3 import sys from itertools import chain import numpy as np # from itertools import combinations as comb # form bisect import bisect_left, bisect_right, insort_left, insort_right # from collections import Counter def solve(N: int, A: "List[int]", B: "List[int]"): A = np.sort(A) B = np.sort...
false
0
[ "- A = sorted(A)", "- B = sorted(B)", "+ A = np.sort(A)", "+ B = np.sort(B)" ]
false
0.338457
0.207793
1.628815
[ "s880567855", "s497155565" ]
u072717685
p02548
python
s848754927
s081204397
1,707
103
109,200
67,700
Accepted
Accepted
93.97
import sys read = sys.stdin.read readlines = sys.stdin.readlines from math import ceil from numba import njit def main(): n = int(eval(input())) @njit def s(n): res = 0 for i1 in range(1, n + 1): for i2 in range(1, n + 1): if i1 * i2 >= n: ...
import sys read = sys.stdin.read readlines = sys.stdin.readlines def main(): n = int(eval(input())) r = 0 for i1 in range(1, n+1): for i2 in range(1, n+1): if i1 * i2 >= n: break else: r += 1 print(r) if __name__ == '__main__...
22
16
472
329
import sys read = sys.stdin.read readlines = sys.stdin.readlines from math import ceil from numba import njit def main(): n = int(eval(input())) @njit def s(n): res = 0 for i1 in range(1, n + 1): for i2 in range(1, n + 1): if i1 * i2 >= n: ...
import sys read = sys.stdin.read readlines = sys.stdin.readlines def main(): n = int(eval(input())) r = 0 for i1 in range(1, n + 1): for i2 in range(1, n + 1): if i1 * i2 >= n: break else: r += 1 print(r) if __name__ == "__main__": ...
false
27.272727
[ "-from math import ceil", "-from numba import njit", "-", "- @njit", "- def s(n):", "- res = 0", "- for i1 in range(1, n + 1):", "- for i2 in range(1, n + 1):", "- if i1 * i2 >= n:", "- break", "- else:", "- ...
false
0.040957
0.290292
0.141091
[ "s848754927", "s081204397" ]
u536034761
p03644
python
s139071853
s949008849
63
27
62,028
8,940
Accepted
Accepted
57.14
N = int(eval(input())) result = 1 count = 0 for i in range(1, N + 1): a = i n = 0 while a % 2 == 0: a /= 2 n += 1 if n > count: result = i count = n print(result)
n = int(eval(input())) ans = 1 while ans <= n: ans *= 2 print((ans // 2))
13
5
194
74
N = int(eval(input())) result = 1 count = 0 for i in range(1, N + 1): a = i n = 0 while a % 2 == 0: a /= 2 n += 1 if n > count: result = i count = n print(result)
n = int(eval(input())) ans = 1 while ans <= n: ans *= 2 print((ans // 2))
false
61.538462
[ "-N = int(eval(input()))", "-result = 1", "-count = 0", "-for i in range(1, N + 1):", "- a = i", "- n = 0", "- while a % 2 == 0:", "- a /= 2", "- n += 1", "- if n > count:", "- result = i", "- count = n", "-print(result)", "+n = int(eval(input()))", ...
false
0.034931
0.037174
0.93968
[ "s139071853", "s949008849" ]
u457802431
p02608
python
s420204076
s024088619
1,281
291
118,312
19,824
Accepted
Accepted
77.28
import itertools import math import collections def func(x,y,z): return x**2+y**2+z**2+x*y+y*z+z*x n = int(eval(input())) s = int(math.sqrt(n)) nums = list(range(1,s)) arr = [] com = list(itertools.product(nums, repeat=3)) for i in range(len(com)): # print(com) ans = func(com[i][0],com[i][1...
import itertools import math import collections def func(x,y,z): return x**2+y**2+z**2+x*y+y*z+z*x n = int(eval(input())) ans = 0 arr = [] for x in range(1,100): for y in range(1,100): for z in range(1,100): ans = func(x,y,z) arr.append(ans) if an...
21
23
421
417
import itertools import math import collections def func(x, y, z): return x**2 + y**2 + z**2 + x * y + y * z + z * x n = int(eval(input())) s = int(math.sqrt(n)) nums = list(range(1, s)) arr = [] com = list(itertools.product(nums, repeat=3)) for i in range(len(com)): # print(com) ans = func(com[i][0], c...
import itertools import math import collections def func(x, y, z): return x**2 + y**2 + z**2 + x * y + y * z + z * x n = int(eval(input())) ans = 0 arr = [] for x in range(1, 100): for y in range(1, 100): for z in range(1, 100): ans = func(x, y, z) arr.append(ans) ...
false
8.695652
[ "-s = int(math.sqrt(n))", "-nums = list(range(1, s))", "+ans = 0", "-com = list(itertools.product(nums, repeat=3))", "-for i in range(len(com)):", "- # print(com)", "- ans = func(com[i][0], com[i][1], com[i][2])", "- arr.append(ans)", "+for x in range(1, 100):", "+ for y in range(1, 10...
false
0.109589
0.117198
0.935074
[ "s420204076", "s024088619" ]
u678167152
p02820
python
s583251823
s138379203
55
50
3,316
9,972
Accepted
Accepted
9.09
N, K = list(map(int, input().split())) S, P, R = list(map(int, input().split())) T = eval(input()) dic = {'s':S,'p':P,'r':R} def solve(T): ans = 0 for i in range(K): ans += dic[T[i]] serial = 1 for j in range(i+K,N,K): if T[j]==T[j-K]: serial += 1 ...
def solve(): N, K = list(map(int, input().split())) R, S, P = list(map(int, input().split())) dic = {'r':P,'s':R,'p':S} T = eval(input()) point = [0]*N for i in range(N): if i<K: point[i] = dic[T[i]] else: if T[i]!=T[i-K] or point[i-K]==0: point[i]=dic[T[i]] ans = s...
19
15
446
341
N, K = list(map(int, input().split())) S, P, R = list(map(int, input().split())) T = eval(input()) dic = {"s": S, "p": P, "r": R} def solve(T): ans = 0 for i in range(K): ans += dic[T[i]] serial = 1 for j in range(i + K, N, K): if T[j] == T[j - K]: serial +=...
def solve(): N, K = list(map(int, input().split())) R, S, P = list(map(int, input().split())) dic = {"r": P, "s": R, "p": S} T = eval(input()) point = [0] * N for i in range(N): if i < K: point[i] = dic[T[i]] else: if T[i] != T[i - K] or point[i - K] == 0:...
false
21.052632
[ "-N, K = list(map(int, input().split()))", "-S, P, R = list(map(int, input().split()))", "-T = eval(input())", "-dic = {\"s\": S, \"p\": P, \"r\": R}", "-", "-", "-def solve(T):", "- ans = 0", "- for i in range(K):", "- ans += dic[T[i]]", "- serial = 1", "- for j in ...
false
0.045338
0.07057
0.642445
[ "s583251823", "s138379203" ]
u490642448
p02559
python
s564566880
s542977784
839
675
252,772
252,728
Accepted
Accepted
19.55
class fenwick_tree(): def __init__(self, n:int, mod:int = 0): self.__mod = mod self.__n = n self.__data = [0] * self.__n def add(self, p:int, x:int): assert (0 <= p) & (p < self.__n) if(self.__mod == 0): self.__add_mod0(p,x) else: ...
class fenwick_tree(): def __init__(self, n:int): self.__n = n self.__data = [0] * self.__n def add(self, p:int, x:int): assert (0 <= p) & (p < self.__n) p+=1 while( p<= self.__n): self.__data[p-1] += x p += p & -p def sum(self, l:...
74
50
1,817
1,137
class fenwick_tree: def __init__(self, n: int, mod: int = 0): self.__mod = mod self.__n = n self.__data = [0] * self.__n def add(self, p: int, x: int): assert (0 <= p) & (p < self.__n) if self.__mod == 0: self.__add_mod0(p, x) else: self._...
class fenwick_tree: def __init__(self, n: int): self.__n = n self.__data = [0] * self.__n def add(self, p: int, x: int): assert (0 <= p) & (p < self.__n) p += 1 while p <= self.__n: self.__data[p - 1] += x p += p & -p def sum(self, l: int, r:...
false
32.432432
[ "- def __init__(self, n: int, mod: int = 0):", "- self.__mod = mod", "+ def __init__(self, n: int):", "- if self.__mod == 0:", "- self.__add_mod0(p, x)", "- else:", "- self.__add_mod(p, x)", "-", "- def __add_mod0(self, p: int, x: int):", "- d...
false
0.043922
0.048391
0.907636
[ "s564566880", "s542977784" ]
u867848444
p03151
python
s556280801
s825925360
128
117
18,524
19,660
Accepted
Accepted
8.59
n=int(eval(input())) a=list(map(int,input().split())) b=list(map(int,input().split())) l=[] m=[] ans=0 for x,y in zip(a,b): if x-y>=0: l+=[x-y] else: m+=[x-y] ans+=1 if ans==0: print((0)) exit() l=sorted(l,reverse=True) msum=sum(m) if sum(m)+sum(l)<0: prin...
n=int(eval(input())) a=list(map(int,input().split())) b=list(map(int,input().split())) if sum(a)<sum(b): print((-1)) exit() dif_posi=[] dif_nega=0 cnt=0 for x,y in zip(a,b): if x-y<0: dif_nega+=x-y cnt+=1 else: dif_posi.append(x-y) dif_posi=sorted(dif_posi,revers...
28
24
423
420
n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) l = [] m = [] ans = 0 for x, y in zip(a, b): if x - y >= 0: l += [x - y] else: m += [x - y] ans += 1 if ans == 0: print((0)) exit() l = sorted(l, reverse=True) msum = sum(m) if sum(m) +...
n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) if sum(a) < sum(b): print((-1)) exit() dif_posi = [] dif_nega = 0 cnt = 0 for x, y in zip(a, b): if x - y < 0: dif_nega += x - y cnt += 1 else: dif_posi.append(x - y) dif_posi = sorted(...
false
14.285714
[ "-l = []", "-m = []", "-ans = 0", "-for x, y in zip(a, b):", "- if x - y >= 0:", "- l += [x - y]", "- else:", "- m += [x - y]", "- ans += 1", "-if ans == 0:", "- print((0))", "- exit()", "-l = sorted(l, reverse=True)", "-msum = sum(m)", "-if sum(m) + sum(...
false
0.079838
0.055493
1.438712
[ "s556280801", "s825925360" ]
u803848678
p03575
python
s208160816
s830131638
905
23
3,064
3,064
Accepted
Accepted
97.46
n, m = list(map(int, input().split())) a = [[False]*n for i in range(n)] hen_m = [] for i in range(m): x1, x2 = list(map(int, input().split())) x1 -= 1 x2 -= 1 hen_m.append([x1, x2]) a[x1][x2] = True a[x2][x1] = True for i in range(n): a[i][i] = True #ワーシャルフロイド def warshall(n,...
class UnionFind(): def __init__(self, n): self.parent = [-1]*n def root(self, x): if self.parent[x] < 0: return x else: self.parent[x] = self.root(self.parent[x]) return self.parent[x] def union(self, x,y): root_x = self.root(x) ...
39
34
873
995
n, m = list(map(int, input().split())) a = [[False] * n for i in range(n)] hen_m = [] for i in range(m): x1, x2 = list(map(int, input().split())) x1 -= 1 x2 -= 1 hen_m.append([x1, x2]) a[x1][x2] = True a[x2][x1] = True for i in range(n): a[i][i] = True # ワーシャルフロイド def warshall(n, c): for...
class UnionFind: def __init__(self, n): self.parent = [-1] * n def root(self, x): if self.parent[x] < 0: return x else: self.parent[x] = self.root(self.parent[x]) return self.parent[x] def union(self, x, y): root_x = self.root(x) ...
false
12.820513
[ "-n, m = list(map(int, input().split()))", "-a = [[False] * n for i in range(n)]", "-hen_m = []", "-for i in range(m):", "- x1, x2 = list(map(int, input().split()))", "- x1 -= 1", "- x2 -= 1", "- hen_m.append([x1, x2])", "- a[x1][x2] = True", "- a[x2][x1] = True", "-for i in ra...
false
0.046365
0.035603
1.302285
[ "s208160816", "s830131638" ]
u803617136
p03733
python
s621691644
s563717773
219
135
25,196
25,200
Accepted
Accepted
38.36
n, t = list(map(int, input().split())) times = list(map(int, input().split())) p = 0 ans = 0 for time in times: start = min(p, time) ans += t - max(0, p - time) p = time + t print(ans)
N, T = list(map(int, input().split())) times = list(map(int, input().split())) ans = 0 t = 0 for time in times: if time >= t: ans += T t = time + T else: diff = t - time ans += T - diff t = time + T print(ans)
10
13
201
263
n, t = list(map(int, input().split())) times = list(map(int, input().split())) p = 0 ans = 0 for time in times: start = min(p, time) ans += t - max(0, p - time) p = time + t print(ans)
N, T = list(map(int, input().split())) times = list(map(int, input().split())) ans = 0 t = 0 for time in times: if time >= t: ans += T t = time + T else: diff = t - time ans += T - diff t = time + T print(ans)
false
23.076923
[ "-n, t = list(map(int, input().split()))", "+N, T = list(map(int, input().split()))", "-p = 0", "+t = 0", "- start = min(p, time)", "- ans += t - max(0, p - time)", "- p = time + t", "+ if time >= t:", "+ ans += T", "+ t = time + T", "+ else:", "+ diff = t -...
false
0.093752
0.044617
2.101275
[ "s621691644", "s563717773" ]
u597374218
p03107
python
s381279968
s588879801
23
18
3,956
3,188
Accepted
Accepted
21.74
s=list(eval(input())) n=len(s) zero=s.count("0") one=s.count("1") if n==1:print((0)) else:print((2*min(zero,one)))
s=eval(input()) print((2*min(s.count("0"),s.count("1"))))
6
2
109
50
s = list(eval(input())) n = len(s) zero = s.count("0") one = s.count("1") if n == 1: print((0)) else: print((2 * min(zero, one)))
s = eval(input()) print((2 * min(s.count("0"), s.count("1"))))
false
66.666667
[ "-s = list(eval(input()))", "-n = len(s)", "-zero = s.count(\"0\")", "-one = s.count(\"1\")", "-if n == 1:", "- print((0))", "-else:", "- print((2 * min(zero, one)))", "+s = eval(input())", "+print((2 * min(s.count(\"0\"), s.count(\"1\"))))" ]
false
0.041896
0.035934
1.165917
[ "s381279968", "s588879801" ]
u612975321
p02996
python
s714522378
s882400817
816
595
119,972
61,400
Accepted
Accepted
27.08
n = int(eval(input())) ab = [list(map(int,input().split())) for i in range(n)] ab = sorted(ab, key=lambda x:(x[1], x[0])) t = 0 for i in range(n): t += ab[i][0] if t > ab[i][1]: print('No') exit() print('Yes')
import sys input = sys.stdin.buffer.readline n = int(eval(input())) ab = [list(map(int,input().split())) for i in range(n)] ab = sorted(ab, key=lambda x:(x[1], x[0])) t = 0 for i in range(n): t += ab[i][0] if t > ab[i][1]: print('No') exit() print('Yes')
11
14
238
287
n = int(eval(input())) ab = [list(map(int, input().split())) for i in range(n)] ab = sorted(ab, key=lambda x: (x[1], x[0])) t = 0 for i in range(n): t += ab[i][0] if t > ab[i][1]: print("No") exit() print("Yes")
import sys input = sys.stdin.buffer.readline n = int(eval(input())) ab = [list(map(int, input().split())) for i in range(n)] ab = sorted(ab, key=lambda x: (x[1], x[0])) t = 0 for i in range(n): t += ab[i][0] if t > ab[i][1]: print("No") exit() print("Yes")
false
21.428571
[ "+import sys", "+", "+input = sys.stdin.buffer.readline" ]
false
0.074189
0.093823
0.790736
[ "s714522378", "s882400817" ]
u843175622
p02580
python
s028039101
s308251016
1,652
561
39,352
114,620
Accepted
Accepted
66.04
import numpy as np import sys read = sys.stdin.read def solve(stdin): h, w, m = stdin[:3] row = np.zeros(h, np.int) col = np.zeros(w, np.int) for i in range(3, m * 2 + 3, 2): y, x = stdin[i: i + 2] - 1 row[y] += 1 col[x] += 1 max_cnt_y = max(row) max_cnt_x = max(col) max_pair = np.sum(ro...
import numpy as np import sys from numba import njit, i4 read = sys.stdin.read @njit((i4[:],), cache=True) def solve(stdin): h, w, m = stdin[:3] row = np.zeros(h, np.int32) col = np.zeros(w, np.int32) for i in range(3, m * 2 + 3, 2): y, x = stdin[i: i + 2] - 1 row[y] += 1 col[x] += 1 max_c...
25
27
609
672
import numpy as np import sys read = sys.stdin.read def solve(stdin): h, w, m = stdin[:3] row = np.zeros(h, np.int) col = np.zeros(w, np.int) for i in range(3, m * 2 + 3, 2): y, x = stdin[i : i + 2] - 1 row[y] += 1 col[x] += 1 max_cnt_y = max(row) max_cnt_x = max(col) ...
import numpy as np import sys from numba import njit, i4 read = sys.stdin.read @njit((i4[:],), cache=True) def solve(stdin): h, w, m = stdin[:3] row = np.zeros(h, np.int32) col = np.zeros(w, np.int32) for i in range(3, m * 2 + 3, 2): y, x = stdin[i : i + 2] - 1 row[y] += 1 col...
false
7.407407
[ "+from numba import njit, i4", "+@njit((i4[:],), cache=True)", "- row = np.zeros(h, np.int)", "- col = np.zeros(w, np.int)", "+ row = np.zeros(h, np.int32)", "+ col = np.zeros(w, np.int32)", "-print((solve(np.fromstring(read(), dtype=np.int, sep=\" \"))))", "+print((solve(np.fromstring(rea...
false
0.433273
0.496764
0.872192
[ "s028039101", "s308251016" ]
u145950990
p03262
python
s163039637
s249045127
362
93
88,172
20,064
Accepted
Accepted
74.31
import fractions n,X = list(map(int,input().split())) x = sorted(list(map(int,input().split()))+[X]) ans = x[1]-x[0] for i in range(1,n): ans = fractions.gcd(ans,x[i+1]-x[i]) print(ans)
n,c = list(map(int,input().split())) x = [c] + list(map(int,input().split())) x.sort() ans = x[1]-x[0] import math for i in range(1,n): ans = math.gcd(ans,x[i+1]-x[i]) print(ans)
7
8
189
183
import fractions n, X = list(map(int, input().split())) x = sorted(list(map(int, input().split())) + [X]) ans = x[1] - x[0] for i in range(1, n): ans = fractions.gcd(ans, x[i + 1] - x[i]) print(ans)
n, c = list(map(int, input().split())) x = [c] + list(map(int, input().split())) x.sort() ans = x[1] - x[0] import math for i in range(1, n): ans = math.gcd(ans, x[i + 1] - x[i]) print(ans)
false
12.5
[ "-import fractions", "+n, c = list(map(int, input().split()))", "+x = [c] + list(map(int, input().split()))", "+x.sort()", "+ans = x[1] - x[0]", "+import math", "-n, X = list(map(int, input().split()))", "-x = sorted(list(map(int, input().split())) + [X])", "-ans = x[1] - x[0]", "- ans = fracti...
false
0.045962
0.007838
5.864142
[ "s163039637", "s249045127" ]
u219157465
p03747
python
s938331410
s404403750
822
720
68,696
70,104
Accepted
Accepted
12.41
from collections import deque n, l, t = list(map(int, input().split())) ants = [list(map(int, input().split())) for i in range(n)] # print(ants) ants_t = [] count = 0 for ant in ants: ant_t = ant if ant[1] == 1: c, ant_t[0] = divmod(t + ant[0], l) # count += c else: c...
from collections import deque n, l, t = list(map(int, input().split())) ants = [list(map(int, input().split())) for i in range(n)] ants_t = [0]*n count = 0 for i in range(n): ant = ants[i] if ant[1] == 1: c, ant_t = divmod(t + ant[0], l) else: c, ant_t = divmod(-t + ant[0], l) ...
30
23
667
512
from collections import deque n, l, t = list(map(int, input().split())) ants = [list(map(int, input().split())) for i in range(n)] # print(ants) ants_t = [] count = 0 for ant in ants: ant_t = ant if ant[1] == 1: c, ant_t[0] = divmod(t + ant[0], l) # count += c else: c, ant_t[0] = di...
from collections import deque n, l, t = list(map(int, input().split())) ants = [list(map(int, input().split())) for i in range(n)] ants_t = [0] * n count = 0 for i in range(n): ant = ants[i] if ant[1] == 1: c, ant_t = divmod(t + ant[0], l) else: c, ant_t = divmod(-t + ant[0], l) ants_t[...
false
23.333333
[ "-# print(ants)", "-ants_t = []", "+ants_t = [0] * n", "-for ant in ants:", "- ant_t = ant", "+for i in range(n):", "+ ant = ants[i]", "- c, ant_t[0] = divmod(t + ant[0], l)", "- # count += c", "+ c, ant_t = divmod(t + ant[0], l)", "- c, ant_t[0] = divmod(-t + a...
false
0.048707
0.047641
1.022374
[ "s938331410", "s404403750" ]
u802772880
p03220
python
s140746366
s000656986
256
19
18,700
3,060
Accepted
Accepted
92.58
import numpy as np N=int(eval(input())) T,A=list(map(int,input().split())) H=[int(i) for i in input().split()] idx=np.abs(T-0.006*np.asarray(H)-A).argmin() print((idx+1))
N=int(eval(input())) T,A=list(map(int,input().split())) H=list(map(int,input().split())) D=list(abs(T-int(x)*0.006-A) for x in H) print((D.index(min(D))+1))
6
5
162
141
import numpy as np N = int(eval(input())) T, A = list(map(int, input().split())) H = [int(i) for i in input().split()] idx = np.abs(T - 0.006 * np.asarray(H) - A).argmin() print((idx + 1))
N = int(eval(input())) T, A = list(map(int, input().split())) H = list(map(int, input().split())) D = list(abs(T - int(x) * 0.006 - A) for x in H) print((D.index(min(D)) + 1))
false
16.666667
[ "-import numpy as np", "-", "-H = [int(i) for i in input().split()]", "-idx = np.abs(T - 0.006 * np.asarray(H) - A).argmin()", "-print((idx + 1))", "+H = list(map(int, input().split()))", "+D = list(abs(T - int(x) * 0.006 - A) for x in H)", "+print((D.index(min(D)) + 1))" ]
false
0.169334
0.038091
4.445492
[ "s140746366", "s000656986" ]
u729133443
p02913
python
s021988862
s435435601
225
61
44,528
4,208
Accepted
Accepted
72.89
class RollingHash(): def __init__(self,s): self.n=n=len(s) self.b=b=129 self.M=M=2**61-1 x,y=1,0 self.f=f=[x]*(n+1) self.h=h=[y]*(n+1) for i,c in enumerate(s.encode()): f[i+1]=x=x*b%M h[i+1]=y=(y*b+c)%M def get(self,l,r):...
class RollingHash(): def __init__(self,s): self.n=n=len(s) self.b=b=129 self.M=M=2**61-1 x,y=1,0 self.f=f=[x]*(n+1) self.h=h=[y]*(n+1) for i,c in enumerate(s.encode()): f[i+1]=x=x*b%M h[i+1]=y=(y*b+c)%M def get(self,l,r):...
33
32
743
787
class RollingHash: def __init__(self, s): self.n = n = len(s) self.b = b = 129 self.M = M = 2**61 - 1 x, y = 1, 0 self.f = f = [x] * (n + 1) self.h = h = [y] * (n + 1) for i, c in enumerate(s.encode()): f[i + 1] = x = x * b % M h[i + 1]...
class RollingHash: def __init__(self, s): self.n = n = len(s) self.b = b = 129 self.M = M = 2**61 - 1 x, y = 1, 0 self.f = f = [x] * (n + 1) self.h = h = [y] * (n + 1) for i, c in enumerate(s.encode()): f[i + 1] = x = x * b % M h[i + 1]...
false
3.030303
[ "-def check(x):", "- d = {}", "- for i in range(0, n - x + 1):", "- k = s.get(i, i + x)", "- if k in d:", "- if d[k] + x <= i:", "- return True", "+def main():", "+ n = int(eval(input()))", "+ s = RollingHash(eval(input()))", "+ ok, ng = 0, ...
false
0.036643
0.035893
1.020885
[ "s021988862", "s435435601" ]
u347640436
p02837
python
s183888415
s868097722
212
152
3,064
3,064
Accepted
Accepted
28.3
N = int(eval(input())) s = [[] for _ in range(N)] for i in range(N): A = int(eval(input())) for _ in range(A): x, y = list(map(int, input().split())) s[i].append((x - 1, y)) result = 0 for i in range(1, 2 ** N): consistent = True for j in range(N): if (i >> j) & 1 ...
N = int(eval(input())) evidences = [[] for _ in range(N)] for i in range(N): A = int(eval(input())) for _ in range(A): x, y = list(map(int, input().split())) evidences[i].append((x - 1, y)) result = 0 for i in range(1, 2 ** N): consistent = True for j in range(N): ...
22
24
539
610
N = int(eval(input())) s = [[] for _ in range(N)] for i in range(N): A = int(eval(input())) for _ in range(A): x, y = list(map(int, input().split())) s[i].append((x - 1, y)) result = 0 for i in range(1, 2**N): consistent = True for j in range(N): if (i >> j) & 1 == 0: ...
N = int(eval(input())) evidences = [[] for _ in range(N)] for i in range(N): A = int(eval(input())) for _ in range(A): x, y = list(map(int, input().split())) evidences[i].append((x - 1, y)) result = 0 for i in range(1, 2**N): consistent = True for j in range(N): if (i >> j) & 1 =...
false
8.333333
[ "-s = [[] for _ in range(N)]", "+evidences = [[] for _ in range(N)]", "- s[i].append((x - 1, y))", "+ evidences[i].append((x - 1, y))", "- for x, y in s[j]:", "+ for x, y in evidences[j]:", "+ if not consistent:", "+ break" ]
false
0.040359
0.036978
1.091432
[ "s183888415", "s868097722" ]
u156815136
p03951
python
s285284412
s014097878
43
39
10,384
10,216
Accepted
Accepted
9.3
#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,Counte...
#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, product # (string,3) 3回 #from collections import deque from collections import deque,defaultdi...
38
40
900
898
# 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, Co...
# 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, product # (string,3) 3回 # from collections import deque from collections import deque, defaul...
false
5
[ "-from itertools import combinations, permutations, accumulate # (string,3) 3回", "+from itertools import combinations, permutations, accumulate, product # (string,3) 3回", "-# 四捨五入", "+# 四捨五入g", "-same = 0", "+if s == t:", "+ print(n)", "+ exit()", "- # print(s[n-i-1:], t[:i+1])", "- ...
false
0.116078
0.046139
2.515842
[ "s285284412", "s014097878" ]
u175034939
p02585
python
s072742173
s754418435
1,615
450
10,144
102,524
Accepted
Accepted
72.14
from itertools import accumulate import sys sys.setrecursionlimit(10**8) n, k = list(map(int, input().split())) p = list(map(int, input().split())) c = list(map(int, input().split())) p = [i-1 for i in p] seen = [False]*n ans = -float('inf') for i in range(n): if not seen[i]: sc = [] ...
from itertools import accumulate n, k = list(map(int, input().split())) p = list(map(int, input().split())) c = list(map(int, input().split())) p = [i-1 for i in p] seen = [False]*n ans = -float('inf') for i in range(n): if not seen[i]: sc = [] stop = i while True: ...
36
34
949
911
from itertools import accumulate import sys sys.setrecursionlimit(10**8) n, k = list(map(int, input().split())) p = list(map(int, input().split())) c = list(map(int, input().split())) p = [i - 1 for i in p] seen = [False] * n ans = -float("inf") for i in range(n): if not seen[i]: sc = [] stop = i ...
from itertools import accumulate n, k = list(map(int, input().split())) p = list(map(int, input().split())) c = list(map(int, input().split())) p = [i - 1 for i in p] seen = [False] * n ans = -float("inf") for i in range(n): if not seen[i]: sc = [] stop = i while True: seen[i] =...
false
5.555556
[ "-import sys", "-sys.setrecursionlimit(10**8)", "- ans = max(ans, ac[-1] * (k // lens) + max(ac[: k % lens]))", "+ ans = max(ans, ac[-1] * (k // lens) + max(ac[: k % lens] + [0]))" ]
false
0.083258
0.039291
2.119022
[ "s072742173", "s754418435" ]
u504256702
p02820
python
s248319810
s466832738
97
83
3,316
3,316
Accepted
Accepted
14.43
import math N, K = list(map(int, input().split())) R, S, P = list(map(int, input().split())) T = eval(input()) score = 0 def calc_score(a): ret = 0 if a == "s": ret = R elif a == "p": ret = S elif a == "r": ret = P return ret for i in range(K): tmp = ...
import math N, K = list(map(int, input().split())) R, S, P = list(map(int, input().split())) T = eval(input()) score = 0 hand = {"r":P, "s":R, "p":S} for i in range(K): tmp = T[i::K] #print(T[i::K]) score += hand[tmp[0]] flag = True for j in range(1,len(tmp)): if tmp[j] == tmp[j ...
30
19
635
443
import math N, K = list(map(int, input().split())) R, S, P = list(map(int, input().split())) T = eval(input()) score = 0 def calc_score(a): ret = 0 if a == "s": ret = R elif a == "p": ret = S elif a == "r": ret = P return ret for i in range(K): tmp = T[i::K] # pr...
import math N, K = list(map(int, input().split())) R, S, P = list(map(int, input().split())) T = eval(input()) score = 0 hand = {"r": P, "s": R, "p": S} for i in range(K): tmp = T[i::K] # print(T[i::K]) score += hand[tmp[0]] flag = True for j in range(1, len(tmp)): if tmp[j] == tmp[j - 1]: ...
false
36.666667
[ "-", "-", "-def calc_score(a):", "- ret = 0", "- if a == \"s\":", "- ret = R", "- elif a == \"p\":", "- ret = S", "- elif a == \"r\":", "- ret = P", "- return ret", "-", "-", "+hand = {\"r\": P, \"s\": R, \"p\": S}", "- score += calc_score(tmp[0])",...
false
0.007863
0.037672
0.208733
[ "s248319810", "s466832738" ]
u838644735
p02714
python
s991440467
s959140840
1,112
120
9,340
69,176
Accepted
Accepted
89.21
def calc(i, j, B1, len_b): extra = 0 d = j - i # i < j < k k1 = d + j if k1 < len_b: extra += B1[k1] # k < i < j k2 = i - d if 0 <= k2 and k2 < len_b: extra += B1[k2] # i < k < j s = i + j if s % 2 == 0: k3 = s // 2 if k3 <...
def calc(i, j, B1, len_b): extra = 0 d = j - i # i < j < k k1 = d + j if k1 < len_b: extra += B1[k1] # k < i < j k2 = i - d if 0 <= k2 and k2 < len_b: extra += B1[k2] # i < k < j s = i + j if s % 2 == 0: k3 = s // 2 if k3 <...
47
58
968
1,206
def calc(i, j, B1, len_b): extra = 0 d = j - i # i < j < k k1 = d + j if k1 < len_b: extra += B1[k1] # k < i < j k2 = i - d if 0 <= k2 and k2 < len_b: extra += B1[k2] # i < k < j s = i + j if s % 2 == 0: k3 = s // 2 if k3 < len_b: e...
def calc(i, j, B1, len_b): extra = 0 d = j - i # i < j < k k1 = d + j if k1 < len_b: extra += B1[k1] # k < i < j k2 = i - d if 0 <= k2 and k2 < len_b: extra += B1[k2] # i < k < j s = i + j if s % 2 == 0: k3 = s // 2 if k3 < len_b: e...
false
18.965517
[ "- RGB = {\"R\": R, \"G\": G, \"B\": B}", "+ num_r, num_g, num_b = 0, 0, 0", "- RGB[S[i]].append(i)", "- num_r, num_g, num_b = len(R), len(G), len(B)", "- if num_r == 0 or num_g == 0 or num_b == 0:", "+ s = S[i]", "+ if s == \"R\":", "+ R.append(i)", "+ ...
false
0.1393
0.093878
1.483837
[ "s991440467", "s959140840" ]
u340781749
p03270
python
s508613425
s151638221
1,634
551
3,572
3,572
Accepted
Accepted
66.28
def prepare(n, MOD): f = 1 factorials = [1] for m in range(1, n + 1): f *= m f %= MOD factorials.append(f) inv = pow(f, MOD - 2, MOD) invs = [1] * (n + 1) invs[n] = inv for m in range(n, 1, -1): inv *= m inv %= MOD invs[m - 1] = in...
def prepare(k, n, MOD): def get_factorials(m): f = 1 factorials = [1] for m in range(1, m + 1): f *= m f %= MOD factorials.append(f) inv = pow(f, MOD - 2, MOD) invs = [1] * (m + 1) invs[m] = inv for m in range(m, ...
61
54
1,890
1,523
def prepare(n, MOD): f = 1 factorials = [1] for m in range(1, n + 1): f *= m f %= MOD factorials.append(f) inv = pow(f, MOD - 2, MOD) invs = [1] * (n + 1) invs[n] = inv for m in range(n, 1, -1): inv *= m inv %= MOD invs[m - 1] = inv return ...
def prepare(k, n, MOD): def get_factorials(m): f = 1 factorials = [1] for m in range(1, m + 1): f *= m f %= MOD factorials.append(f) inv = pow(f, MOD - 2, MOD) invs = [1] * (m + 1) invs[m] = inv for m in range(m, 1, -1): ...
false
11.47541
[ "-def prepare(n, MOD):", "- f = 1", "- factorials = [1]", "- for m in range(1, n + 1):", "- f *= m", "- f %= MOD", "- factorials.append(f)", "- inv = pow(f, MOD - 2, MOD)", "- invs = [1] * (n + 1)", "- invs[n] = inv", "- for m in range(n, 1, -1):", "- ...
false
0.038833
0.037547
1.034263
[ "s508613425", "s151638221" ]
u104931506
p02394
python
s978600064
s274404329
50
20
7,648
7,636
Accepted
Accepted
60
W, H, x, y, r = list(map(int, input().split())) if r <= x and x <= W-r and r <= y and y <= H-r: print('Yes') else: print('No')
W, H, x, y, r = list(map(int, input().split())) if x+r <= W and x-r >= 0 and y+r <= H and y-r >=0: print("Yes") else: print("No")
5
5
129
135
W, H, x, y, r = list(map(int, input().split())) if r <= x and x <= W - r and r <= y and y <= H - r: print("Yes") else: print("No")
W, H, x, y, r = list(map(int, input().split())) if x + r <= W and x - r >= 0 and y + r <= H and y - r >= 0: print("Yes") else: print("No")
false
0
[ "-if r <= x and x <= W - r and r <= y and y <= H - r:", "+if x + r <= W and x - r >= 0 and y + r <= H and y - r >= 0:" ]
false
0.119887
0.038394
3.122578
[ "s978600064", "s274404329" ]
u673361376
p02918
python
s071231836
s181534197
200
47
56,540
3,316
Accepted
Accepted
76.5
from itertools import groupby N,K = list(map(int,input().split())) S = eval(input()) gnum = len(list(groupby(S))) if gnum<=2*K-1: print((N-1)) else: print((min(N-(gnum-2*K),N-1)))
import itertools N, K = list(map(int, input().split())) S = eval(input()) gnum = 0 for key, elems in itertools.groupby(S): gnum += 1 k = K while gnum > 1 and K > 0: if gnum != 2: gnum -= 2 else: gnum -= 1 K -= 1 if gnum == 1: print((N - 1)) else: print((N ...
9
21
176
313
from itertools import groupby N, K = list(map(int, input().split())) S = eval(input()) gnum = len(list(groupby(S))) if gnum <= 2 * K - 1: print((N - 1)) else: print((min(N - (gnum - 2 * K), N - 1)))
import itertools N, K = list(map(int, input().split())) S = eval(input()) gnum = 0 for key, elems in itertools.groupby(S): gnum += 1 k = K while gnum > 1 and K > 0: if gnum != 2: gnum -= 2 else: gnum -= 1 K -= 1 if gnum == 1: print((N - 1)) else: print((N - gnum))
false
57.142857
[ "-from itertools import groupby", "+import itertools", "-gnum = len(list(groupby(S)))", "-if gnum <= 2 * K - 1:", "+gnum = 0", "+for key, elems in itertools.groupby(S):", "+ gnum += 1", "+k = K", "+while gnum > 1 and K > 0:", "+ if gnum != 2:", "+ gnum -= 2", "+ else:", "+ ...
false
0.038856
0.038407
1.011687
[ "s071231836", "s181534197" ]
u050428930
p03673
python
s306688151
s497540003
290
48
23,364
27,204
Accepted
Accepted
83.45
N=int(input()) s=list(input().split()) t=s[N::-2]+s[N%2::2] for i in range(N): print(t[i],end=" ")
N=int(eval(input())) s=list(input().split()) print((" ".join(s[N::-2]+s[N%2::2])))
5
3
106
76
N = int(input()) s = list(input().split()) t = s[N::-2] + s[N % 2 :: 2] for i in range(N): print(t[i], end=" ")
N = int(eval(input())) s = list(input().split()) print((" ".join(s[N::-2] + s[N % 2 :: 2])))
false
40
[ "-N = int(input())", "+N = int(eval(input()))", "-t = s[N::-2] + s[N % 2 :: 2]", "-for i in range(N):", "- print(t[i], end=\" \")", "+print((\" \".join(s[N::-2] + s[N % 2 :: 2])))" ]
false
0.038683
0.040115
0.964301
[ "s306688151", "s497540003" ]
u844895214
p02819
python
s234271775
s148495786
62
33
17,592
9,508
Accepted
Accepted
46.77
import sys from collections import deque #import numpy as np import math #sys.setrecursionlimit(10**6) def S(): return sys.stdin.readline().rstrip() def SL(): return list(map(str,sys.stdin.readline().rstrip().split())) def I(): return int(sys.stdin.readline().rstrip()) def IL(): return list(map(int,sys.stdin.re...
import sys from collections import deque #import numpy as np import math #sys.setrecursionlimit(10**6) def S(): return sys.stdin.readline().rstrip() def SL(): return list(map(str,sys.stdin.readline().rstrip().split())) def I(): return int(sys.stdin.readline().rstrip()) def IL(): return list(map(int,sys.stdin.re...
35
35
860
867
import sys from collections import deque # import numpy as np import math # sys.setrecursionlimit(10**6) def S(): return sys.stdin.readline().rstrip() def SL(): return list(map(str, sys.stdin.readline().rstrip().split())) def I(): return int(sys.stdin.readline().rstrip()) def IL(): return list(m...
import sys from collections import deque # import numpy as np import math # sys.setrecursionlimit(10**6) def S(): return sys.stdin.readline().rstrip() def SL(): return list(map(str, sys.stdin.readline().rstrip().split())) def I(): return int(sys.stdin.readline().rstrip()) def IL(): return list(m...
false
0
[ "- while j <= x + 2 * i:", "+ while j <= math.sqrt(x):" ]
false
0.04334
0.061644
0.703067
[ "s234271775", "s148495786" ]
u694665829
p03830
python
s867778468
s842850418
32
29
9,116
9,704
Accepted
Accepted
9.38
def solve(): n = int(eval(input())) d = {} mod = 10**9+7 for i in range(1, n+1): d[i] = 0 def prime_factorize(n): a = [] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: ...
n = int(eval(input())) from collections import defaultdict p = defaultdict(int) def f(n): for i in range(2, int(n**0.5) + 1): x = 0 while n%i == 0: n //= i x += 1 if x: p[i] += x if n > 1: p[n] += 1 for i in range(2, n+1)...
39
22
776
428
def solve(): n = int(eval(input())) d = {} mod = 10**9 + 7 for i in range(1, n + 1): d[i] = 0 def prime_factorize(n): a = [] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: a.app...
n = int(eval(input())) from collections import defaultdict p = defaultdict(int) def f(n): for i in range(2, int(n**0.5) + 1): x = 0 while n % i == 0: n //= i x += 1 if x: p[i] += x if n > 1: p[n] += 1 for i in range(2, n + 1): f(i) fro...
false
43.589744
[ "-def solve():", "- n = int(eval(input()))", "- d = {}", "- mod = 10**9 + 7", "- for i in range(1, n + 1):", "- d[i] = 0", "+n = int(eval(input()))", "+from collections import defaultdict", "- def prime_factorize(n):", "- a = []", "- while n % 2 == 0:", "- ...
false
0.035077
0.03324
1.055269
[ "s867778468", "s842850418" ]
u846226907
p03289
python
s739885493
s028210205
19
17
3,060
3,064
Accepted
Accepted
10.53
import sys input = sys.stdin.readline MOD = 1000000007 S = input()[:-1] S = list(S) if S[0] == 'A': if 'C' in S[2:-1] and S.count('C') == 1: x = [] for i in range(1,len(S)): if S[i] == 'C': continue x.append(S[i]) #print(...
import sys input = sys.stdin.readline MOD = 1000000007 S = input()[:-1] S = list(S) if S[0] == 'A': if 'C' in S[2:-1] and S.count('C') == 1: cnt = 0 for i in range(1,len(S)): if S[i].isupper() : if S[i] == 'C': continue ...
24
25
415
462
import sys input = sys.stdin.readline MOD = 1000000007 S = input()[:-1] S = list(S) if S[0] == "A": if "C" in S[2:-1] and S.count("C") == 1: x = [] for i in range(1, len(S)): if S[i] == "C": continue x.append(S[i]) # print(x) if str(x).islower...
import sys input = sys.stdin.readline MOD = 1000000007 S = input()[:-1] S = list(S) if S[0] == "A": if "C" in S[2:-1] and S.count("C") == 1: cnt = 0 for i in range(1, len(S)): if S[i].isupper(): if S[i] == "C": continue else: ...
false
4
[ "- x = []", "+ cnt = 0", "- if S[i] == \"C\":", "- continue", "- x.append(S[i])", "+ if S[i].isupper():", "+ if S[i] == \"C\":", "+ continue", "+ else:", "+ cnt += 1", "- ...
false
0.043443
0.183481
0.236772
[ "s739885493", "s028210205" ]
u743281086
p03379
python
s366925986
s522363617
1,039
285
105,816
25,556
Accepted
Accepted
72.57
n = int(eval(input())) x = list(map(int, input().split())) temp = sorted(zip(x, list(range(n)))) ans = [None] * n for i in range(n): idx = n//2 if i >= idx: idx -= 1 ans[temp[i][1]] = temp[idx][0] for item in ans: print(item)
n = int(eval(input())) x = list(map(int, input().split())) temp = sorted(x) idx = n//2 y = temp[idx-1] z = temp[idx] for item in x: if item >= z: print(y) else: print(z)
11
11
241
197
n = int(eval(input())) x = list(map(int, input().split())) temp = sorted(zip(x, list(range(n)))) ans = [None] * n for i in range(n): idx = n // 2 if i >= idx: idx -= 1 ans[temp[i][1]] = temp[idx][0] for item in ans: print(item)
n = int(eval(input())) x = list(map(int, input().split())) temp = sorted(x) idx = n // 2 y = temp[idx - 1] z = temp[idx] for item in x: if item >= z: print(y) else: print(z)
false
0
[ "-temp = sorted(zip(x, list(range(n))))", "-ans = [None] * n", "-for i in range(n):", "- idx = n // 2", "- if i >= idx:", "- idx -= 1", "- ans[temp[i][1]] = temp[idx][0]", "-for item in ans:", "- print(item)", "+temp = sorted(x)", "+idx = n // 2", "+y = temp[idx - 1]", "+z...
false
0.07714
0.039137
1.971028
[ "s366925986", "s522363617" ]
u131406572
p03644
python
s184591660
s980546228
19
17
3,060
2,940
Accepted
Accepted
10.53
n=int(eval(input())) if n==1: print((1)) elif n==2 or n==3: print((2)) elif 4<=n<=7: print((4)) elif 8<=n<=15: print((8)) elif 16<=n<=31: print((16)) elif 32<=n<=63: print((32)) else: print((64))
n=int(eval(input())) x=1 while True: if x<n: x=x*2 else:break if x>n : print((x//2)) else:print(x)
15
9
217
108
n = int(eval(input())) if n == 1: print((1)) elif n == 2 or n == 3: print((2)) elif 4 <= n <= 7: print((4)) elif 8 <= n <= 15: print((8)) elif 16 <= n <= 31: print((16)) elif 32 <= n <= 63: print((32)) else: print((64))
n = int(eval(input())) x = 1 while True: if x < n: x = x * 2 else: break if x > n: print((x // 2)) else: print(x)
false
40
[ "-if n == 1:", "- print((1))", "-elif n == 2 or n == 3:", "- print((2))", "-elif 4 <= n <= 7:", "- print((4))", "-elif 8 <= n <= 15:", "- print((8))", "-elif 16 <= n <= 31:", "- print((16))", "-elif 32 <= n <= 63:", "- print((32))", "+x = 1", "+while True:", "+ if x ...
false
0.041727
0.082084
0.50834
[ "s184591660", "s980546228" ]