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
u636684559
p02861
python
s689028640
s912985357
219
112
4,404
3,444
Accepted
Accepted
48.86
import math def calc(now,points,length,M,ans): if len(points)==0: #print(length). ans.append(length) return 0 for i in range(len(points)): #print(points,points[:i]+points[i+1:]) tmp=length + math.sqrt( ((now[0]-M[points[i]][0])**2) + ((now[1]-M[points[i]][1])**2) ) #print(tmp) ...
import itertools import math N=int(eval(input())) X=[] Y=[] dist=[ [ 0 for j in range(N) ] for i in range(N) ] for n in range(N): x,y=list(map(int,input().split())) X.append(x) Y.append(y) for i in range(N): for j in range(N): dist[i][j]=math.sqrt( (X[i]-X[j])**2 + (Y[i]-Y[j])**2 ) l=[ i ...
28
24
808
474
import math def calc(now, points, length, M, ans): if len(points) == 0: # print(length). ans.append(length) return 0 for i in range(len(points)): # print(points,points[:i]+points[i+1:]) tmp = length + math.sqrt( ((now[0] - M[points[i]][0]) ** 2) + ((now[1] -...
import itertools import math N = int(eval(input())) X = [] Y = [] dist = [[0 for j in range(N)] for i in range(N)] for n in range(N): x, y = list(map(int, input().split())) X.append(x) Y.append(y) for i in range(N): for j in range(N): dist[i][j] = math.sqrt((X[i] - X[j]) ** 2 + (Y[i] - Y[j]) **...
false
14.285714
[ "+import itertools", "-", "-def calc(now, points, length, M, ans):", "- if len(points) == 0:", "- # print(length).", "- ans.append(length)", "- return 0", "- for i in range(len(points)):", "- # print(points,points[:i]+points[i+1:])", "- tmp = length + math....
false
0.039684
0.038606
1.027922
[ "s689028640", "s912985357" ]
u156815136
p03624
python
s577341855
s881190384
44
39
10,272
10,296
Accepted
Accepted
11.36
#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...
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from math import gcd from itertools import combinations,permutations,accumulate, product # (string,3) 3回 #from collections import deque from collections import deque,defaultdict,Co...
50
49
1,186
1,147
# 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...
# from statistics import median # import collections # aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from math import gcd from itertools import combinations, permutations, accumulate, product # (string,3) 3回 # from collections import deque from collections import deque, defaultdict...
false
2
[ "-from fractions import gcd", "+from math import gcd", "+import heapq", "+INF = float(\"inf\")", "-ans = \"abcdefghijklmnopqrstuvwxyz\"", "-s = sorted(list(set(s)))", "-for v in ans:", "- flag = True", "- for j in range(len(s)):", "- if s[j] == v:", "- flag = False", "-...
false
0.040034
0.0424
0.944202
[ "s577341855", "s881190384" ]
u347640436
p03457
python
s295315048
s039943483
580
413
60,376
27,300
Accepted
Accepted
28.79
import sys def main(): _int = int n = int(eval(input())) data = [[_int(e) for e in input().split()] for _ in range(n)] t, x, y = 0, 0, 0 for d in data: rt = d[0] - t - abs(x - d[1]) - abs(y - d[2]) if rt < 0 or rt & 1 == 1: print('No') sys.exit() t, x, y = d print('Yes') ...
from sys import exit n = int(eval(input())) data = [list(map(int, input().split())) for _ in range(n)] t = 0 x = 0 y = 0 for d in data: duration = d[0] - t distance = abs(x - d[1]) + abs(y - d[2]) if (distance > duration) or ((duration - distance) % 2 == 1): print('No') exit() t = d[0] x ...
14
16
322
347
import sys def main(): _int = int n = int(eval(input())) data = [[_int(e) for e in input().split()] for _ in range(n)] t, x, y = 0, 0, 0 for d in data: rt = d[0] - t - abs(x - d[1]) - abs(y - d[2]) if rt < 0 or rt & 1 == 1: print("No") sys.exit() t, ...
from sys import exit n = int(eval(input())) data = [list(map(int, input().split())) for _ in range(n)] t = 0 x = 0 y = 0 for d in data: duration = d[0] - t distance = abs(x - d[1]) + abs(y - d[2]) if (distance > duration) or ((duration - distance) % 2 == 1): print("No") exit() t = d[0] ...
false
12.5
[ "-import sys", "+from sys import exit", "-", "-def main():", "- _int = int", "- n = int(eval(input()))", "- data = [[_int(e) for e in input().split()] for _ in range(n)]", "- t, x, y = 0, 0, 0", "- for d in data:", "- rt = d[0] - t - abs(x - d[1]) - abs(y - d[2])", "- ...
false
0.041349
0.035928
1.150864
[ "s295315048", "s039943483" ]
u203843959
p02678
python
s972187672
s386782347
1,420
800
170,820
37,840
Accepted
Accepted
43.66
N,M=list(map(int,input().split())) import heapq def dijkstra_heap(s): #始点sから各頂点への最短距離 dist=[float("inf")]*size_v used=[False]*size_v dist[s]=0 used[s]=True hq_edge=[] for v,w,i in graph[s]: heapq.heappush(hq_edge,(w,v,i)) while hq_edge: min_w,min_v,i=heapq.heappop(hq_edge) ...
N,M=list(map(int,input().split())) graph=[[] for _ in range(N+1)] for i in range(M): a,b=list(map(int,input().split())) graph[a].append(b) graph[b].append(a) #print(graph) queue=[1] d=0 dist=[-1]*(N+1) while queue: new_queue=set() for q in queue: if dist[q]!=-1: continue ...
51
36
982
638
N, M = list(map(int, input().split())) import heapq def dijkstra_heap(s): # 始点sから各頂点への最短距離 dist = [float("inf")] * size_v used = [False] * size_v dist[s] = 0 used[s] = True hq_edge = [] for v, w, i in graph[s]: heapq.heappush(hq_edge, (w, v, i)) while hq_edge: min_w, mi...
N, M = list(map(int, input().split())) graph = [[] for _ in range(N + 1)] for i in range(M): a, b = list(map(int, input().split())) graph[a].append(b) graph[b].append(a) # print(graph) queue = [1] d = 0 dist = [-1] * (N + 1) while queue: new_queue = set() for q in queue: if dist[q] != -1: ...
false
29.411765
[ "-import heapq", "-", "-", "-def dijkstra_heap(s):", "- # 始点sから各頂点への最短距離", "- dist = [float(\"inf\")] * size_v", "- used = [False] * size_v", "- dist[s] = 0", "- used[s] = True", "- hq_edge = []", "- for v, w, i in graph[s]:", "- heapq.heappush(hq_edge, (w, v, i))",...
false
0.105526
0.037701
2.799047
[ "s972187672", "s386782347" ]
u691018832
p02918
python
s230723110
s509064063
49
35
3,316
3,380
Accepted
Accepted
28.57
n, k = list(map(int, input().split())) s = eval(input()) ans = n - 1 for i in range(1, n): if s[i] != s[i - 1]: ans -= 1 print((min(n - 1, ans + 2 * k)))
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) n, k = list(map(int, readline().split())) s = read().rstrip().decode() ans = n - 1 for bf, af in zip(s, s[1:]): if bf != af: ans -= 1 print((min(n -...
7
13
158
331
n, k = list(map(int, input().split())) s = eval(input()) ans = n - 1 for i in range(1, n): if s[i] != s[i - 1]: ans -= 1 print((min(n - 1, ans + 2 * k)))
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**7) n, k = list(map(int, readline().split())) s = read().rstrip().decode() ans = n - 1 for bf, af in zip(s, s[1:]): if bf != af: ans -= 1 print((min(n - 1, ans + k * ...
false
46.153846
[ "-n, k = list(map(int, input().split()))", "-s = eval(input())", "+import sys", "+", "+read = sys.stdin.buffer.read", "+readline = sys.stdin.buffer.readline", "+readlines = sys.stdin.buffer.readlines", "+sys.setrecursionlimit(10**7)", "+n, k = list(map(int, readline().split()))", "+s = read().rstr...
false
0.036597
0.036239
1.009881
[ "s230723110", "s509064063" ]
u891635666
p03148
python
s552263258
s227751052
462
367
41,720
37,132
Accepted
Accepted
20.56
import collections import heapq import operator import sys input = sys.stdin.readline ri = lambda: int(eval(input())) rs = lambda: input().rstrip() ril = lambda: list(map(int, input().split())) rsl = lambda: input().rstrip().split() ris = lambda n: [ri() for _ in range(n)] rss = lambda n: [rs() for _ in r...
import heapq import operator import sys input = sys.stdin.readline ri = lambda: int(eval(input())) rs = lambda: input().rstrip() ril = lambda: list(map(int, input().split())) rsl = lambda: input().rstrip().split() ris = lambda n: [ri() for _ in range(n)] rss = lambda n: [rs() for _ in range(n)] rils = lam...
48
47
1,155
1,107
import collections import heapq import operator import sys input = sys.stdin.readline ri = lambda: int(eval(input())) rs = lambda: input().rstrip() ril = lambda: list(map(int, input().split())) rsl = lambda: input().rstrip().split() ris = lambda n: [ri() for _ in range(n)] rss = lambda n: [rs() for _ in range(n)] rils...
import heapq import operator import sys input = sys.stdin.readline ri = lambda: int(eval(input())) rs = lambda: input().rstrip() ril = lambda: list(map(int, input().split())) rsl = lambda: input().rstrip().split() ris = lambda n: [ri() for _ in range(n)] rss = lambda n: [rs() for _ in range(n)] rils = lambda n: [ril()...
false
2.083333
[ "-import collections", "-counter0 = collections.Counter()", "-counter1 = collections.Counter()", "+selected0 = set()", "+selected1 = set()", "- if counter0[t] > 0:", "+ if t in selected0:", "- counter0[t] += 1", "+ selected0.add(t)", "- if t not in counter0 and t...
false
0.043231
0.041593
1.039377
[ "s552263258", "s227751052" ]
u333945892
p03270
python
s546178206
s451247436
774
626
62,164
55,256
Accepted
Accepted
19.12
from collections import defaultdict,deque import sys,heapq,bisect,math,itertools,string,queue,datetime sys.setrecursionlimit(10**8) INF = float('inf') mod = 998244353 eps = 10**-7 def inp(): return int(eval(input())) def inpl(): return list(map(int, input().split())) def inpls(): return list(input().split()) ...
K,N = list(map(int, input().split())) MAX = K+N+3 mod = 998244353 fac = [1]*(MAX+1) for i in range(1,MAX+1): fac[i] = (fac[i-1]*i)%mod rev_m = [1]*(MAX+1) rev_m[MAX] = pow(fac[MAX],mod-2,mod) for i in range(MAX,0,-1): rev_m[i-1] = (rev_m[i]*i)%mod def Comb(n,k):#nCk return (fac[n]*rev_m[k]*rev_m[n-k...
66
51
1,384
922
from collections import defaultdict, deque import sys, heapq, bisect, math, itertools, string, queue, datetime sys.setrecursionlimit(10**8) INF = float("inf") mod = 998244353 eps = 10**-7 def inp(): return int(eval(input())) def inpl(): return list(map(int, input().split())) def inpls(): return list(...
K, N = list(map(int, input().split())) MAX = K + N + 3 mod = 998244353 fac = [1] * (MAX + 1) for i in range(1, MAX + 1): fac[i] = (fac[i - 1] * i) % mod rev_m = [1] * (MAX + 1) rev_m[MAX] = pow(fac[MAX], mod - 2, mod) for i in range(MAX, 0, -1): rev_m[i - 1] = (rev_m[i] * i) % mod def Comb(n, k): # nCk r...
false
22.727273
[ "-from collections import defaultdict, deque", "-import sys, heapq, bisect, math, itertools, string, queue, datetime", "-", "-sys.setrecursionlimit(10**8)", "-INF = float(\"inf\")", "+K, N = list(map(int, input().split()))", "+MAX = K + N + 3", "-eps = 10**-7", "-", "-", "-def inp():", "- r...
false
0.038467
0.039669
0.96969
[ "s546178206", "s451247436" ]
u102461423
p03987
python
s856045721
s119927975
639
322
73,072
36,380
Accepted
Accepted
49.61
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) # 大きい数字から追加していく。そのときの連結成分の大きさだけ足される。 # union findっぽく。各成分の左端を根として持つ N = int(eval(input())) A = [int(x) for x in input().split()] x_to_i = {x:i for i,x in enumerate(A)} V = set() root = dict() size = dict() def find_root(x): y ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines """ ・大きい数から挿入していく ・連結成分の両端を管理する """ N,*A = list(map(int,read().split())) A = [0] + A + [0] ind = [0] * (N+1) for i,x in enumerate(A): ind[x] = i left = list(range(1,len(A)+1)) ri...
53
28
980
541
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) # 大きい数字から追加していく。そのときの連結成分の大きさだけ足される。 # union findっぽく。各成分の左端を根として持つ N = int(eval(input())) A = [int(x) for x in input().split()] x_to_i = {x: i for i, x in enumerate(A)} V = set() root = dict() size = dict() def find_root(x): y = root[x] if x ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines """ ・大きい数から挿入していく ・連結成分の両端を管理する """ N, *A = list(map(int, read().split())) A = [0] + A + [0] ind = [0] * (N + 1) for i, x in enumerate(A): ind[x] = i left = list(range(1, len(A) + 1)) right = list(ra...
false
47.169811
[ "-input = sys.stdin.readline", "-sys.setrecursionlimit(10**7)", "-# 大きい数字から追加していく。そのときの連結成分の大きさだけ足される。", "-# union findっぽく。各成分の左端を根として持つ", "-N = int(eval(input()))", "-A = [int(x) for x in input().split()]", "-x_to_i = {x: i for i, x in enumerate(A)}", "-V = set()", "-root = dict()", "-size = dict...
false
0.037085
0.049656
0.746844
[ "s856045721", "s119927975" ]
u970197315
p02861
python
s620582724
s875953985
427
268
9,460
13,908
Accepted
Accepted
37.24
n=int(eval(input())) xy=[] for i in range(n): xx,yy=list(map(int,input().split())) xy.append((xx,yy)) from itertools import permutations a=list(permutations(xy)) d=[] for aa in a: t=0 for i in range(len(aa)-1): t+=((aa[i+1][0]-aa[i][0])**2+(aa[i+1][1]-aa[i][1])**2)**0.5 d.append(t) print((sum...
n = int(eval(input())) xy = [list(map(int,input().split())) for _ in range(n)] from itertools import permutations count = 0 dist = 0 for l in list(permutations(xy)): tmp = 0 for i in range(len(l)-1): tmp += ((l[i+1][0]-l[i][0])**2+(l[i+1][1]-l[i][1])**2)**0.5 dist += tmp count += 1 ...
14
14
319
334
n = int(eval(input())) xy = [] for i in range(n): xx, yy = list(map(int, input().split())) xy.append((xx, yy)) from itertools import permutations a = list(permutations(xy)) d = [] for aa in a: t = 0 for i in range(len(aa) - 1): t += ((aa[i + 1][0] - aa[i][0]) ** 2 + (aa[i + 1][1] - aa[i][1]) **...
n = int(eval(input())) xy = [list(map(int, input().split())) for _ in range(n)] from itertools import permutations count = 0 dist = 0 for l in list(permutations(xy)): tmp = 0 for i in range(len(l) - 1): tmp += ((l[i + 1][0] - l[i][0]) ** 2 + (l[i + 1][1] - l[i][1]) ** 2) ** 0.5 dist += tmp coun...
false
0
[ "-xy = []", "-for i in range(n):", "- xx, yy = list(map(int, input().split()))", "- xy.append((xx, yy))", "+xy = [list(map(int, input().split())) for _ in range(n)]", "-a = list(permutations(xy))", "-d = []", "-for aa in a:", "- t = 0", "- for i in range(len(aa) - 1):", "- t +...
false
0.051837
0.039259
1.320362
[ "s620582724", "s875953985" ]
u992910889
p03627
python
s404007847
s676586696
298
267
71,832
69,912
Accepted
Accepted
10.4
# import bisect from collections import Counter, deque # from copy import copy, deepcopy # from fractions import gcd # from functools import reduce # from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product # import math # import numpy as np # from operator i...
# import bisect from collections import Counter, deque # from copy import copy, deepcopy # from fractions import gcd # from functools import reduce # from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product # import math # import numpy as np # from operator i...
42
33
946
792
# import bisect from collections import Counter, deque # from copy import copy, deepcopy # from fractions import gcd # from functools import reduce # from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product # import math # import numpy as np # from operator import x...
# import bisect from collections import Counter, deque # from copy import copy, deepcopy # from fractions import gcd # from functools import reduce # from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product # import math # import numpy as np # from operator import x...
false
21.428571
[ "- A = list(map(int, input().split()))", "- AA = Counter(A).most_common()", "- ls = []", "- for i in range(len(AA)):", "- if AA[i][1] >= 2:", "- ls.append(AA[i])", "- else:", "- break", "- ls = sorted(ls, key=lambda x: x[0])", "- try:", "- ...
false
0.008531
0.084117
0.101422
[ "s404007847", "s676586696" ]
u337080722
p03081
python
s862741167
s250813563
1,775
530
41,400
41,388
Accepted
Accepted
70.14
def search_right(a, x, lo=0, hi=None, key=lambda x: x): if lo < 0: raise ValueError('lo must be non-negative') if hi is None: hi = len(a) while lo < hi: mid = (lo+hi)//2 if x < key(a[mid]): hi = mid else: lo = mid+1 return lo def search_left(a, x, lo...
n, q = list(map(int, input().split())) s = "_{}_".format(eval(input())) td = [input().split() for _ in range(q)] current_l = 0 current_r = len(s) - 1 for t, d in reversed(td): if current_l + 1 < len(s) - 1 and t == s[current_l + 1] and d == "L": current_l += 1 elif t == s[current_l] and d ...
39
20
1,097
542
def search_right(a, x, lo=0, hi=None, key=lambda x: x): if lo < 0: raise ValueError("lo must be non-negative") if hi is None: hi = len(a) while lo < hi: mid = (lo + hi) // 2 if x < key(a[mid]): hi = mid else: lo = mid + 1 return lo def se...
n, q = list(map(int, input().split())) s = "_{}_".format(eval(input())) td = [input().split() for _ in range(q)] current_l = 0 current_r = len(s) - 1 for t, d in reversed(td): if current_l + 1 < len(s) - 1 and t == s[current_l + 1] and d == "L": current_l += 1 elif t == s[current_l] and d == "R": ...
false
48.717949
[ "-def search_right(a, x, lo=0, hi=None, key=lambda x: x):", "- if lo < 0:", "- raise ValueError(\"lo must be non-negative\")", "- if hi is None:", "- hi = len(a)", "- while lo < hi:", "- mid = (lo + hi) // 2", "- if x < key(a[mid]):", "- hi = mid", "...
false
0.041455
0.040325
1.028038
[ "s862741167", "s250813563" ]
u745087332
p03241
python
s037635922
s409876889
490
26
40,044
3,060
Accepted
Accepted
94.69
# coding:utf-8 def inpl(): return list(map(int, input().split())) N, M = inpl() n = M // N while n > 0: if M % n == 0: print(n) break else: n -= 1
# coding:utf-8 def inpl(): return list(map(int, input().split())) N, M = inpl() A = 1 ans = 1 while A * A <= M: # 約数判定 if M % A != 0: A += 1 continue B = M // A # dはM // N以下 if A * N <= M: ans = max(ans, A) # M = A * BでAはsqrt(M)までしか探索しない # 答...
15
30
198
476
# coding:utf-8 def inpl(): return list(map(int, input().split())) N, M = inpl() n = M // N while n > 0: if M % n == 0: print(n) break else: n -= 1
# coding:utf-8 def inpl(): return list(map(int, input().split())) N, M = inpl() A = 1 ans = 1 while A * A <= M: # 約数判定 if M % A != 0: A += 1 continue B = M // A # dはM // N以下 if A * N <= M: ans = max(ans, A) # M = A * BでAはsqrt(M)までしか探索しない # 答えがsqrt(M)以上M // N以下のと...
false
50
[ "-n = M // N", "-while n > 0:", "- if M % n == 0:", "- print(n)", "- break", "- else:", "- n -= 1", "+A = 1", "+ans = 1", "+while A * A <= M:", "+ # 約数判定", "+ if M % A != 0:", "+ A += 1", "+ continue", "+ B = M // A", "+ # dはM // N以下...
false
0.102673
0.040378
2.542791
[ "s037635922", "s409876889" ]
u888092736
p03695
python
s758200944
s088174376
21
17
3,316
2,940
Accepted
Accepted
19.05
from collections import Counter def get_color(rating): if rating >= 3200: return 8 else: return rating // 400 eval(input()) a = Counter([get_color(int(x)) for x in input().split()]) min_color_cnt = len([i for i in a if i < 8]) print((max(1, min_color_cnt), min_color_cnt + a[8]))...
eval(input()) super_coders_cnt = 0 coders = set() for r in map(int, input().split()): if r >= 3200: super_coders_cnt += 1 else: coders.add(r // 400) print((max(1, len(coders)), len(coders) + super_coders_cnt))
14
9
318
234
from collections import Counter def get_color(rating): if rating >= 3200: return 8 else: return rating // 400 eval(input()) a = Counter([get_color(int(x)) for x in input().split()]) min_color_cnt = len([i for i in a if i < 8]) print((max(1, min_color_cnt), min_color_cnt + a[8]))
eval(input()) super_coders_cnt = 0 coders = set() for r in map(int, input().split()): if r >= 3200: super_coders_cnt += 1 else: coders.add(r // 400) print((max(1, len(coders)), len(coders) + super_coders_cnt))
false
35.714286
[ "-from collections import Counter", "-", "-", "-def get_color(rating):", "- if rating >= 3200:", "- return 8", "+eval(input())", "+super_coders_cnt = 0", "+coders = set()", "+for r in map(int, input().split()):", "+ if r >= 3200:", "+ super_coders_cnt += 1", "- ret...
false
0.10563
0.041352
2.554442
[ "s758200944", "s088174376" ]
u200887663
p02947
python
s832520883
s729114347
418
260
17,808
22,148
Accepted
Accepted
37.8
n=int(eval(input())) #n,p=map(int,input().split()) #hl=list(map(int,input().split())) #l=[list(map(int,input().split())) for i in range(n)] #素因数分解した結果を2次元配列にして返す dic={} ans=0 for i in range(n): s=list(eval(input())) s.sort() st="".join(s) v=dic.get(st,0) ans+=v dic[st]=v+1 print(...
n=int(eval(input())) #n,m=map(int,input().split()) #t=int(input()) #pl=list(map(int,input().split())) #l=[list(map(int,input().split())) for i in range(n)] dic={} res=0 for i in range(n): s=list(eval(input())) s="".join(sorted(s)) count=dic.get(s,0) if count>0: res+=count dic[s]...
16
15
313
329
n = int(eval(input())) # n,p=map(int,input().split()) # hl=list(map(int,input().split())) # l=[list(map(int,input().split())) for i in range(n)] # 素因数分解した結果を2次元配列にして返す dic = {} ans = 0 for i in range(n): s = list(eval(input())) s.sort() st = "".join(s) v = dic.get(st, 0) ans += v dic[st] = v + 1...
n = int(eval(input())) # n,m=map(int,input().split()) # t=int(input()) # pl=list(map(int,input().split())) # l=[list(map(int,input().split())) for i in range(n)] dic = {} res = 0 for i in range(n): s = list(eval(input())) s = "".join(sorted(s)) count = dic.get(s, 0) if count > 0: res += count ...
false
6.25
[ "-# n,p=map(int,input().split())", "-# hl=list(map(int,input().split()))", "+# n,m=map(int,input().split())", "+# t=int(input())", "+# pl=list(map(int,input().split()))", "-# 素因数分解した結果を2次元配列にして返す", "-ans = 0", "+res = 0", "- s.sort()", "- st = \"\".join(s)", "- v = dic.get(st, 0)", "-...
false
0.172763
0.041394
4.173669
[ "s832520883", "s729114347" ]
u059262067
p03274
python
s085322233
s282245627
395
103
23,084
14,224
Accepted
Accepted
73.92
import numpy as np b = list(map(int, input().split())) a = list(map(int, input().split())) x = b[0]-b[1]+1 res = 10**15 for i in range(x): tmp = i + b[1] - 1 if res > (a[tmp]-a[i] + min(abs(a[i]),abs(a[tmp]))): res = a[tmp]-a[i] + min(abs(a[i]),abs(a[tmp])) print(res)
b = list(map(int, input().split())) a = list(map(int, input().split())) x = b[0]-b[1]+1 res = 10**15 for i in range(x): tmp = i + b[1] - 1 if res > (a[tmp]-a[i] + min(abs(a[i]),abs(a[tmp]))): res = a[tmp]-a[i] + min(abs(a[i]),abs(a[tmp])) print(res)
12
11
303
283
import numpy as np b = list(map(int, input().split())) a = list(map(int, input().split())) x = b[0] - b[1] + 1 res = 10**15 for i in range(x): tmp = i + b[1] - 1 if res > (a[tmp] - a[i] + min(abs(a[i]), abs(a[tmp]))): res = a[tmp] - a[i] + min(abs(a[i]), abs(a[tmp])) print(res)
b = list(map(int, input().split())) a = list(map(int, input().split())) x = b[0] - b[1] + 1 res = 10**15 for i in range(x): tmp = i + b[1] - 1 if res > (a[tmp] - a[i] + min(abs(a[i]), abs(a[tmp]))): res = a[tmp] - a[i] + min(abs(a[i]), abs(a[tmp])) print(res)
false
8.333333
[ "-import numpy as np", "-" ]
false
0.045803
0.044478
1.029791
[ "s085322233", "s282245627" ]
u133936772
p02684
python
s750855081
s150063479
175
140
31,728
31,788
Accepted
Accepted
20
n,k,*a=list(map(int,open(0).read().split())) v=[0]+[-1]*n p=0 for i in range(n): t=a[p]-1 if v[t]>=0: l,r=v[t],i+1; break v[t]=i+1; p=t print((v.index(min(k,l+(k-l)%(r-l)))+1))
n,k,*a=list(map(int,open(0).read().split())) v=[0]+[-1]*n t=a[0]-1 c=1 while v[t]<0: v[t]=c t=a[t]-1 c+=1 l=v[t] c-=l print((v.index(min(k,l+(k-l)%c))+1))
8
11
181
162
n, k, *a = list(map(int, open(0).read().split())) v = [0] + [-1] * n p = 0 for i in range(n): t = a[p] - 1 if v[t] >= 0: l, r = v[t], i + 1 break v[t] = i + 1 p = t print((v.index(min(k, l + (k - l) % (r - l))) + 1))
n, k, *a = list(map(int, open(0).read().split())) v = [0] + [-1] * n t = a[0] - 1 c = 1 while v[t] < 0: v[t] = c t = a[t] - 1 c += 1 l = v[t] c -= l print((v.index(min(k, l + (k - l) % c)) + 1))
false
27.272727
[ "-p = 0", "-for i in range(n):", "- t = a[p] - 1", "- if v[t] >= 0:", "- l, r = v[t], i + 1", "- break", "- v[t] = i + 1", "- p = t", "-print((v.index(min(k, l + (k - l) % (r - l))) + 1))", "+t = a[0] - 1", "+c = 1", "+while v[t] < 0:", "+ v[t] = c", "+ t = ...
false
0.038705
0.039661
0.975886
[ "s750855081", "s150063479" ]
u821624310
p02413
python
s542456510
s823858481
50
40
8,336
8,196
Accepted
Accepted
20
r, c = map(int, input().split()) a = [[0 for i in range(c+1)] for j in range(r+1)] for i in range(r): l = list(map(int, input().split())) for j in range(c): a[i][j] = l[j] a[i][c] += a[i][j] for i in range(c+1): for j in range(r): a[r][i] += a[j][i] for i in range(r+1):...
r, c = map(int, input().split()) a = [[int(i) for i in input().split()] for j in range(r)] b = [[0 for i in range(c+1)] for j in range(r+1)] for i in range(r): for j in range(c): b[i][j] = a[i][j] b[i][c] += a[i][j] for i in range(c+1): for j in range(r): b[r][i] += b[j][i...
18
18
461
487
r, c = map(int, input().split()) a = [[0 for i in range(c + 1)] for j in range(r + 1)] for i in range(r): l = list(map(int, input().split())) for j in range(c): a[i][j] = l[j] a[i][c] += a[i][j] for i in range(c + 1): for j in range(r): a[r][i] += a[j][i] for i in range(r + 1): f...
r, c = map(int, input().split()) a = [[int(i) for i in input().split()] for j in range(r)] b = [[0 for i in range(c + 1)] for j in range(r + 1)] for i in range(r): for j in range(c): b[i][j] = a[i][j] b[i][c] += a[i][j] for i in range(c + 1): for j in range(r): b[r][i] += b[j][i] for i i...
false
0
[ "-a = [[0 for i in range(c + 1)] for j in range(r + 1)]", "+a = [[int(i) for i in input().split()] for j in range(r)]", "+b = [[0 for i in range(c + 1)] for j in range(r + 1)]", "- l = list(map(int, input().split()))", "- a[i][j] = l[j]", "- a[i][c] += a[i][j]", "+ b[i][j] = a[i]...
false
0.046936
0.101594
0.461998
[ "s542456510", "s823858481" ]
u756595712
p02259
python
s897633678
s658773272
50
40
7,716
7,700
Accepted
Accepted
20
length = int(eval(input())) eles = [int(l) for l in input().split()] times = 0 for i in range(length): flag = 1 while flag > 0: flag = 0 for j in range(length-1, 0, -1): if eles[j] < eles[j - 1]: _temp = eles[j] eles[j] = eles[j-1] ...
length = int(eval(input())) eles = [int(l) for l in input().split()] times = 0 for i in range(length): flag = 1 while flag > 0: flag = 0 for j in range(length-1, i, -1): if eles[j] < eles[j - 1]: _temp = eles[j] eles[j] = eles[j-1] ...
18
18
424
424
length = int(eval(input())) eles = [int(l) for l in input().split()] times = 0 for i in range(length): flag = 1 while flag > 0: flag = 0 for j in range(length - 1, 0, -1): if eles[j] < eles[j - 1]: _temp = eles[j] eles[j] = eles[j - 1] ...
length = int(eval(input())) eles = [int(l) for l in input().split()] times = 0 for i in range(length): flag = 1 while flag > 0: flag = 0 for j in range(length - 1, i, -1): if eles[j] < eles[j - 1]: _temp = eles[j] eles[j] = eles[j - 1] ...
false
0
[ "- for j in range(length - 1, 0, -1):", "+ for j in range(length - 1, i, -1):" ]
false
0.045517
0.101064
0.450379
[ "s897633678", "s658773272" ]
u887207211
p03221
python
s305007694
s770957003
660
563
30,076
36,380
Accepted
Accepted
14.7
N, M = list(map(int,input().split())) PY = [list(map(int,input().split())) + [0] for _ in range(M)] sort_PY = sorted(PY, key = lambda x: x[1]) city = {} for i in range(M): p, y = sort_PY[i][0], sort_PY[i][1] if p in city: city[p] += 1 else: city[p] = 1 sort_PY[i][2] = city[p] for p, y, z in P...
import sys stdin = sys.stdin sn = lambda : stdin.readline().rstrip() an = lambda : list(map(int, stdin.readline().split())) ni = lambda : int(sn()) n, m = an() py = [] for _ in range(m): py.append(list(an()) + [0]) sortPy = sorted(py, key = lambda x : (x[0], x[1])) d = {} for i, (p, y, n) in enum...
13
25
358
469
N, M = list(map(int, input().split())) PY = [list(map(int, input().split())) + [0] for _ in range(M)] sort_PY = sorted(PY, key=lambda x: x[1]) city = {} for i in range(M): p, y = sort_PY[i][0], sort_PY[i][1] if p in city: city[p] += 1 else: city[p] = 1 sort_PY[i][2] = city[p] for p, y, z...
import sys stdin = sys.stdin sn = lambda: stdin.readline().rstrip() an = lambda: list(map(int, stdin.readline().split())) ni = lambda: int(sn()) n, m = an() py = [] for _ in range(m): py.append(list(an()) + [0]) sortPy = sorted(py, key=lambda x: (x[0], x[1])) d = {} for i, (p, y, n) in enumerate(sortPy): if p ...
false
48
[ "-N, M = list(map(int, input().split()))", "-PY = [list(map(int, input().split())) + [0] for _ in range(M)]", "-sort_PY = sorted(PY, key=lambda x: x[1])", "-city = {}", "-for i in range(M):", "- p, y = sort_PY[i][0], sort_PY[i][1]", "- if p in city:", "- city[p] += 1", "+import sys", ...
false
0.048236
0.048789
0.988664
[ "s305007694", "s770957003" ]
u588341295
p03212
python
s374561314
s675973866
802
429
44,464
3,060
Accepted
Accepted
46.51
# -*- coding: utf-8 -*- from itertools import product N = int(eval(input())) cnt = 0 # 候補となりうる10桁までの数字を列挙 for prod in product(['0', '3', '5', '7'], repeat=10): # チェック用に変形 num = int(''.join(prod)) s = str(num) # 753数ではない if (s.find('3') == -1 or s.find('5') == -1 or s.fin...
# -*- coding: utf-8 -*- from itertools import product N = int(eval(input())) cnt = 0 # 候補となりうる9桁までの数字を列挙 for prod in product(['0', '3', '5', '7'], repeat=9): # チェック用に変形 num = int(''.join(prod)) s = str(num) # 753数ではない if (s.find('3') == -1 or s.find('5') == -1 or s.find(...
21
21
444
442
# -*- coding: utf-8 -*- from itertools import product N = int(eval(input())) cnt = 0 # 候補となりうる10桁までの数字を列挙 for prod in product(["0", "3", "5", "7"], repeat=10): # チェック用に変形 num = int("".join(prod)) s = str(num) # 753数ではない if s.find("3") == -1 or s.find("5") == -1 or s.find("7") == -1 or s.find("0") !...
# -*- coding: utf-8 -*- from itertools import product N = int(eval(input())) cnt = 0 # 候補となりうる9桁までの数字を列挙 for prod in product(["0", "3", "5", "7"], repeat=9): # チェック用に変形 num = int("".join(prod)) s = str(num) # 753数ではない if s.find("3") == -1 or s.find("5") == -1 or s.find("7") == -1 or s.find("0") != ...
false
0
[ "-# 候補となりうる10桁までの数字を列挙", "-for prod in product([\"0\", \"3\", \"5\", \"7\"], repeat=10):", "+# 候補となりうる9桁までの数字を列挙", "+for prod in product([\"0\", \"3\", \"5\", \"7\"], repeat=9):" ]
false
2.032379
0.636855
3.191276
[ "s374561314", "s675973866" ]
u821588465
p02886
python
s316957674
s294738961
30
27
9,044
9,136
Accepted
Accepted
10
N = int(eval(input())) D = list(map(int, input().split())) from itertools import accumulate print((sum(list(d*c for d, c in zip(D[1:], accumulate(D))))))
N = int(eval(input())) D = list(map(int, input().split())) from itertools import combinations ans = 0 for i , j in combinations(D,2): ans += i*j print(ans)
4
7
149
159
N = int(eval(input())) D = list(map(int, input().split())) from itertools import accumulate print((sum(list(d * c for d, c in zip(D[1:], accumulate(D))))))
N = int(eval(input())) D = list(map(int, input().split())) from itertools import combinations ans = 0 for i, j in combinations(D, 2): ans += i * j print(ans)
false
42.857143
[ "-from itertools import accumulate", "+from itertools import combinations", "-print((sum(list(d * c for d, c in zip(D[1:], accumulate(D))))))", "+ans = 0", "+for i, j in combinations(D, 2):", "+ ans += i * j", "+print(ans)" ]
false
0.037691
0.047151
0.799366
[ "s316957674", "s294738961" ]
u537782349
p03073
python
s934873167
s145471297
143
82
4,852
3,956
Accepted
Accepted
42.66
a = eval(input()) b = [bool(int(a[i])) for i in range(len(a))] b.insert(0, True) c = [bool(int(a[i])) for i in range(len(a))] c.insert(0, False) bc = 0 cc = 0 for i in range(1, len(b)): if b[i-1] == b[i]: b[i] = not b[i-1] bc += 1 if c[i-1] == c[i]: c[i] = not c[i - 1] ...
a = eval(input()) a = [bool(int(a[i])) for i in range(len(a))] b = True c = 0 d = 0 for i in range(len(a)): if b is a[i]: c += 1 if b is not a[i]: d += 1 b = not b print((min(c, d)))
17
12
349
214
a = eval(input()) b = [bool(int(a[i])) for i in range(len(a))] b.insert(0, True) c = [bool(int(a[i])) for i in range(len(a))] c.insert(0, False) bc = 0 cc = 0 for i in range(1, len(b)): if b[i - 1] == b[i]: b[i] = not b[i - 1] bc += 1 if c[i - 1] == c[i]: c[i] = not c[i - 1] cc +...
a = eval(input()) a = [bool(int(a[i])) for i in range(len(a))] b = True c = 0 d = 0 for i in range(len(a)): if b is a[i]: c += 1 if b is not a[i]: d += 1 b = not b print((min(c, d)))
false
29.411765
[ "-b = [bool(int(a[i])) for i in range(len(a))]", "-b.insert(0, True)", "-c = [bool(int(a[i])) for i in range(len(a))]", "-c.insert(0, False)", "-bc = 0", "-cc = 0", "-for i in range(1, len(b)):", "- if b[i - 1] == b[i]:", "- b[i] = not b[i - 1]", "- bc += 1", "- if c[i - 1] =...
false
0.084471
0.065251
1.294555
[ "s934873167", "s145471297" ]
u620868411
p03253
python
s143090127
s846781672
266
108
62,960
15,212
Accepted
Accepted
59.4
# -*- coding: utf-8 -*- from collections import defaultdict # mod mでの二項係数を求める class BiCoeff(object): def __init__(self, MAX, m): super(BiCoeff, self).__init__() fac = [0]*MAX finv = [0]*MAX inv = [0]*MAX fac[0] = 1 fac[1] = 1 finv[0] = 1 ...
# -*- coding: utf-8 -*- def primeFactors(n): res = [] while n%2==0: res.append(2) n //= 2 x = 3 while n>1 and n>=x*x: while n%x==0: res.append(x) n //= x x += 2 if n>1: res.append(n) return res class BiCoeff(object)...
55
61
1,150
1,325
# -*- coding: utf-8 -*- from collections import defaultdict # mod mでの二項係数を求める class BiCoeff(object): def __init__(self, MAX, m): super(BiCoeff, self).__init__() fac = [0] * MAX finv = [0] * MAX inv = [0] * MAX fac[0] = 1 fac[1] = 1 finv[0] = 1 finv[1]...
# -*- coding: utf-8 -*- def primeFactors(n): res = [] while n % 2 == 0: res.append(2) n //= 2 x = 3 while n > 1 and n >= x * x: while n % x == 0: res.append(x) n //= x x += 2 if n > 1: res.append(n) return res class BiCoeff(object...
false
9.836066
[ "-from collections import defaultdict", "+def primeFactors(n):", "+ res = []", "+ while n % 2 == 0:", "+ res.append(2)", "+ n //= 2", "+ x = 3", "+ while n > 1 and n >= x * x:", "+ while n % x == 0:", "+ res.append(x)", "+ n //= x", "+ ...
false
1.692955
0.082015
20.642106
[ "s143090127", "s846781672" ]
u852690916
p02793
python
s137090506
s100393322
379
283
56,412
45,148
Accepted
Accepted
25.33
from collections import defaultdict N=int(eval(input())) A=list(map(int,input().split())) MOD=10**9+7 inv=[1]*(10**6+1) for i in range(2,10**6+1): inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD LCM=defaultdict(int) def f(n): tmp=0 p=2 while n%p==0: tmp+=1 n//=p LCM[p]=max(LCM...
from collections import defaultdict N=int(eval(input())) A=list(map(int,input().split())) MOD=10**9+7 primes=[] is_prime=[True]*(10**3) for i in range(2,10**3): if not is_prime[i]: continue primes.append(i) for j in range(2*i,10**3,i): is_prime[j]=False LCM=defaultdict(int) for n i...
40
34
657
628
from collections import defaultdict N = int(eval(input())) A = list(map(int, input().split())) MOD = 10**9 + 7 inv = [1] * (10**6 + 1) for i in range(2, 10**6 + 1): inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD LCM = defaultdict(int) def f(n): tmp = 0 p = 2 while n % p == 0: tmp += 1 ...
from collections import defaultdict N = int(eval(input())) A = list(map(int, input().split())) MOD = 10**9 + 7 primes = [] is_prime = [True] * (10**3) for i in range(2, 10**3): if not is_prime[i]: continue primes.append(i) for j in range(2 * i, 10**3, i): is_prime[j] = False LCM = defaultdi...
false
15
[ "-inv = [1] * (10**6 + 1)", "-for i in range(2, 10**6 + 1):", "- inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD", "+primes = []", "+is_prime = [True] * (10**3)", "+for i in range(2, 10**3):", "+ if not is_prime[i]:", "+ continue", "+ primes.append(i)", "+ for j in range(2 * i, 1...
false
1.656227
0.112109
14.773312
[ "s137090506", "s100393322" ]
u358919705
p02270
python
s169973323
s216887734
960
820
11,656
11,580
Accepted
Accepted
14.58
n, k = list(map(int, input().split())) ww = [int(eval(input())) for _ in range(n)] def chk(p): c = 1 s = 0 for w in ww: if w > p: return False if s + w <= p: s += w else: c += 1 s = w if c > k: return F...
n, k = list(map(int, input().split())) ww = [int(eval(input())) for _ in range(n)] def chk(p): c = 1 s = 0 for w in ww: if w > p: return False if s + w <= p: s += w else: c += 1 s = w if c > k: return F...
27
27
587
591
n, k = list(map(int, input().split())) ww = [int(eval(input())) for _ in range(n)] def chk(p): c = 1 s = 0 for w in ww: if w > p: return False if s + w <= p: s += w else: c += 1 s = w if c > k: return False ret...
n, k = list(map(int, input().split())) ww = [int(eval(input())) for _ in range(n)] def chk(p): c = 1 s = 0 for w in ww: if w > p: return False if s + w <= p: s += w else: c += 1 s = w if c > k: return False ret...
false
0
[ "- return search(m, r)", "+ return search(m + 1, r)" ]
false
0.034115
0.033552
1.016777
[ "s169973323", "s216887734" ]
u287500079
p02662
python
s636323375
s339698066
352
265
149,200
149,304
Accepted
Accepted
24.72
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd from itertools import permutations, combinations, product, accumulate, combinations_with_replacement from operator import itemgetter, mul fr...
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd from itertools import permutations, combinations, product, accumulate, combinations_with_replacement from operator import itemgetter, mul fr...
51
47
1,736
1,608
import sys, re, os from collections import deque, defaultdict, Counter from math import ( ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd, ) from itertools import ( permutations, combinations, product, accumul...
import sys, re, os from collections import deque, defaultdict, Counter from math import ( ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd, ) from itertools import ( permutations, combinations, product, accumul...
false
7.843137
[ "-# print(a[0], dp[0])", "- dp[i][j] = dp[i - 1][j] * 2", "- if dp[i - 1][j - a[i]]:", "- dp[i][j] += dp[i - 1][j - a[i]] # * 2 + dp[i - 1][j - a[i]]", "+ dp[i][j] = dp[i - 1][j] * 2 + dp[i - 1][j - a[i]]", "- # print(a[i], dp[i])" ]
false
0.037869
0.038254
0.98995
[ "s636323375", "s339698066" ]
u022407960
p02469
python
s906683849
s348923824
50
40
10,224
8,296
Accepted
Accepted
20
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 4 1 2 3 5 output: 30 """ import sys import fractions from functools import reduce def gcd(x, y): if x < y: x, y = y, x while y > 0: r = x % y x = y y = r return x def lcm(a, b): ...
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 4 1 2 3 5 output: 30 """ import sys from functools import reduce def gcd(x, y): if x < y: x, y = y, x while y > 0: r = x % y x = y y = r return x def lcm(a, b): return a * b // ...
42
41
584
556
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 4 1 2 3 5 output: 30 """ import sys import fractions from functools import reduce def gcd(x, y): if x < y: x, y = y, x while y > 0: r = x % y x = y y = r return x def lcm(a, b): return a * b // fractions.gcd(a, ...
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 4 1 2 3 5 output: 30 """ import sys from functools import reduce def gcd(x, y): if x < y: x, y = y, x while y > 0: r = x % y x = y y = r return x def lcm(a, b): return a * b // gcd(a, b) def solve(_n_list): ...
false
2.380952
[ "-import fractions", "- return a * b // fractions.gcd(a, b)", "+ return a * b // gcd(a, b)" ]
false
0.055999
0.043503
1.287225
[ "s906683849", "s348923824" ]
u581187895
p03387
python
s124948672
s313623617
20
17
3,316
3,064
Accepted
Accepted
15
a, b, c = list(map(int, input().split())) ans = 0 while not (a==b==c): a, b, c = sorted([a, b, c]) if a+2 <= c: a += 2 else: a += 1 b += 1 ans += 1 print(ans)
A = list(map(int, input().split())) # 偶数、奇数の個数を数える odds = 0 even = 0 for a in A: if a%2 == 0: even += 1 else: odds += 1 ans = 0 # 操作1をするため個数が多いものを少ないものに偶奇を合わせる if even == 2: # 偶数を奇数にする ans += 1 for i in range(3): if A[i]%2==0: A[i] += 1 elif odds == 2: ans += 1 ...
11
31
184
492
a, b, c = list(map(int, input().split())) ans = 0 while not (a == b == c): a, b, c = sorted([a, b, c]) if a + 2 <= c: a += 2 else: a += 1 b += 1 ans += 1 print(ans)
A = list(map(int, input().split())) # 偶数、奇数の個数を数える odds = 0 even = 0 for a in A: if a % 2 == 0: even += 1 else: odds += 1 ans = 0 # 操作1をするため個数が多いものを少ないものに偶奇を合わせる if even == 2: # 偶数を奇数にする ans += 1 for i in range(3): if A[i] % 2 == 0: A[i] += 1 elif odds == 2: ans ...
false
64.516129
[ "-a, b, c = list(map(int, input().split()))", "+A = list(map(int, input().split()))", "+# 偶数、奇数の個数を数える", "+odds = 0", "+even = 0", "+for a in A:", "+ if a % 2 == 0:", "+ even += 1", "+ else:", "+ odds += 1", "-while not (a == b == c):", "- a, b, c = sorted([a, b, c])", ...
false
0.049271
0.049352
0.998365
[ "s124948672", "s313623617" ]
u743272507
p02773
python
s006744086
s457381182
944
773
59,800
62,308
Accepted
Accepted
18.11
from collections import defaultdict n = int(eval(input())) d = defaultdict(int) for i in range(n): d[eval(input())]+=1 ds = sorted(list(d.items()), key = lambda x : (-x[1], x[0])) nmx = ds[0][1] for i in ds: if nmx != i[1]: break print((i[0]))
from collections import defaultdict d = defaultdict(int) n = int(eval(input())) for _ in range(n): d[eval(input())] += 1 s = sorted(list(d.items()), key=lambda x: (-x[1], x[0])) nmax = s[0][1] for i in s: if i[1] != nmax: break print((i[0]))
9
9
236
233
from collections import defaultdict n = int(eval(input())) d = defaultdict(int) for i in range(n): d[eval(input())] += 1 ds = sorted(list(d.items()), key=lambda x: (-x[1], x[0])) nmx = ds[0][1] for i in ds: if nmx != i[1]: break print((i[0]))
from collections import defaultdict d = defaultdict(int) n = int(eval(input())) for _ in range(n): d[eval(input())] += 1 s = sorted(list(d.items()), key=lambda x: (-x[1], x[0])) nmax = s[0][1] for i in s: if i[1] != nmax: break print((i[0]))
false
0
[ "+d = defaultdict(int)", "-d = defaultdict(int)", "-for i in range(n):", "+for _ in range(n):", "-ds = sorted(list(d.items()), key=lambda x: (-x[1], x[0]))", "-nmx = ds[0][1]", "-for i in ds:", "- if nmx != i[1]:", "+s = sorted(list(d.items()), key=lambda x: (-x[1], x[0]))", "+nmax = s[0][1]", ...
false
0.114262
0.047943
2.383284
[ "s006744086", "s457381182" ]
u426534722
p02283
python
s052219514
s677642319
7,370
6,000
105,028
57,536
Accepted
Accepted
18.59
import sys readline = sys.stdin.readline NIL = None class Tree: def __init__(self, key = None): self.key = key self.p = NIL self.left = NIL self.right = NIL n = int(input()) tree = {"root":NIL} def insert(T, z): y = NIL x = T["root"] while x != NIL: ...
import sys readline = sys.stdin.readline NIL = None class Tree: __slots__ = ['key', 'p', 'left', 'right'] def __init__(self, key = None): self.key = key self.p = NIL self.left = NIL self.right = NIL n = int(input()) tree = {"root":NIL} def insert(T, z): y = NIL ...
50
51
1,162
1,209
import sys readline = sys.stdin.readline NIL = None class Tree: def __init__(self, key=None): self.key = key self.p = NIL self.left = NIL self.right = NIL n = int(input()) tree = {"root": NIL} def insert(T, z): y = NIL x = T["root"] while x != NIL: y = x ...
import sys readline = sys.stdin.readline NIL = None class Tree: __slots__ = ["key", "p", "left", "right"] def __init__(self, key=None): self.key = key self.p = NIL self.left = NIL self.right = NIL n = int(input()) tree = {"root": NIL} def insert(T, z): y = NIL x =...
false
1.960784
[ "+ __slots__ = [\"key\", \"p\", \"left\", \"right\"]", "+" ]
false
0.11235
0.110865
1.013394
[ "s052219514", "s677642319" ]
u670180528
p03162
python
s965353022
s295798290
263
184
37,148
35,636
Accepted
Accepted
30.04
n,*l=list(map(int,open(0).read().split())) a=l[::3] b=l[1::3] c=l[2::3] dp=[[0]*3 for _ in range(n)] dp[0]=[a[0],b[0],c[0]] A,B,C=dp[0] for i in range(1,n): dp[i]=[ a[i]+max(B,C) , b[i]+max(C,A) , c[i]+max(A,B) ] A,B,C=dp[i] print((max(dp[-1])))
n,*l=list(map(int,open(0).read().split())) a=l[::3];b=l[1::3];c=l[2::3] A,B,C=a[0],b[0],c[0] M=max for i in range(1,n): A,B,C=a[i]+M(B,C),b[i]+M(C,A),c[i]+M(A,B) print((M(A,B,C)))
11
7
249
178
n, *l = list(map(int, open(0).read().split())) a = l[::3] b = l[1::3] c = l[2::3] dp = [[0] * 3 for _ in range(n)] dp[0] = [a[0], b[0], c[0]] A, B, C = dp[0] for i in range(1, n): dp[i] = [a[i] + max(B, C), b[i] + max(C, A), c[i] + max(A, B)] A, B, C = dp[i] print((max(dp[-1])))
n, *l = list(map(int, open(0).read().split())) a = l[::3] b = l[1::3] c = l[2::3] A, B, C = a[0], b[0], c[0] M = max for i in range(1, n): A, B, C = a[i] + M(B, C), b[i] + M(C, A), c[i] + M(A, B) print((M(A, B, C)))
false
36.363636
[ "-dp = [[0] * 3 for _ in range(n)]", "-dp[0] = [a[0], b[0], c[0]]", "-A, B, C = dp[0]", "+A, B, C = a[0], b[0], c[0]", "+M = max", "- dp[i] = [a[i] + max(B, C), b[i] + max(C, A), c[i] + max(A, B)]", "- A, B, C = dp[i]", "-print((max(dp[-1])))", "+ A, B, C = a[i] + M(B, C), b[i] + M(C, A), c...
false
0.044686
0.038494
1.160847
[ "s965353022", "s295798290" ]
u648868410
p03176
python
s195006815
s328111268
1,265
297
41,056
146,536
Accepted
Accepted
76.52
# EDPC Q - Flowers # 重み付きのLISと言って良いような問題 # これは、LISのdpを少し改造すれば解ける # import numpy as np ## test data # 4 # 3 1 4 2 # 10 20 30 40 ## ans=60 # import bisect class BIT: def __init__(self,size): self.N = size self.bit = [0] * (self.N+1) def getSum(self,i): s = 0 while 0 < i: s +=...
# EDPC Q - Flowers # 重み付きのLISと言って良いような問題 # これは、LISのdpを少し改造すれば解ける ## test data # 4 # 3 1 4 2 # 10 20 30 40 ## ans=60 import bisect class SegTree: """ 1-indexed """ def __init__(self,size,func,init_val,undef): self.specSize = size self.datSize = 1 self.compareFunc = func # suppose to min ...
76
141
1,259
3,278
# EDPC Q - Flowers # 重み付きのLISと言って良いような問題 # これは、LISのdpを少し改造すれば解ける # import numpy as np ## test data # 4 # 3 1 4 2 # 10 20 30 40 ## ans=60 # import bisect class BIT: def __init__(self, size): self.N = size self.bit = [0] * (self.N + 1) def getSum(self, i): s = 0 while 0 < i: ...
# EDPC Q - Flowers # 重み付きのLISと言って良いような問題 # これは、LISのdpを少し改造すれば解ける ## test data # 4 # 3 1 4 2 # 10 20 30 40 ## ans=60 import bisect class SegTree: """ 1-indexed """ def __init__(self, size, func, init_val, undef): self.specSize = size self.datSize = 1 self.compareFunc = func # ...
false
46.099291
[ "-# import numpy as np", "-# import bisect", "-class BIT:", "- def __init__(self, size):", "- self.N = size", "- self.bit = [0] * (self.N + 1)", "+import bisect", "- def getSum(self, i):", "- s = 0", "- while 0 < i:", "- s += self.bit[i]", "- ...
false
0.070743
0.039438
1.79378
[ "s195006815", "s328111268" ]
u813387707
p03625
python
s838986024
s821402828
94
80
22,196
19,788
Accepted
Accepted
14.89
from collections import defaultdict n = int(eval(input())) a_list = [int(x) for x in input().split()] d = defaultdict(int) for a in a_list: d[a] += 1 temp_list = sorted([(k, v) for k, v in list(d.items()) if v >= 2], reverse=True) if len(temp_list) >= 2: print((temp_list[0][0] ** 2 if temp_list[0][1] >=...
n = int(eval(input())) a_list = sorted([int(x) for x in input().split()], reverse=True) ans = 0 temp = 0 count = 0 e = None for i in range(n): if a_list[i] == temp: count += 1 if count == 2: if e is None: e = temp count -= 2 else: ...
11
20
370
436
from collections import defaultdict n = int(eval(input())) a_list = [int(x) for x in input().split()] d = defaultdict(int) for a in a_list: d[a] += 1 temp_list = sorted([(k, v) for k, v in list(d.items()) if v >= 2], reverse=True) if len(temp_list) >= 2: print( ( temp_list[0][0] ** 2 ...
n = int(eval(input())) a_list = sorted([int(x) for x in input().split()], reverse=True) ans = 0 temp = 0 count = 0 e = None for i in range(n): if a_list[i] == temp: count += 1 if count == 2: if e is None: e = temp count -= 2 else: ...
false
45
[ "-from collections import defaultdict", "-", "-a_list = [int(x) for x in input().split()]", "-d = defaultdict(int)", "-for a in a_list:", "- d[a] += 1", "-temp_list = sorted([(k, v) for k, v in list(d.items()) if v >= 2], reverse=True)", "-if len(temp_list) >= 2:", "- print(", "- (", ...
false
0.044389
0.050397
0.880793
[ "s838986024", "s821402828" ]
u974231963
p02548
python
s137209442
s815663188
313
269
9,120
9,184
Accepted
Accepted
14.06
n = int(eval(input())) ans = 0 count = 0 a, b, c = 1, 1, 1 while a <= n: # print("A : {0}".format(a)) # print("追加パターン : {0}".format( (n // a) )) if a == 1 : ans = ans + ( (n // a) - 1) else : if n // a == 1 : ans = ans + 1 else : ...
n = int(eval(input())) ans = 0 a = 1 while a <= n: if a == 1 : ans = ans + (n - 1) else : if n % a == 0 : ans = ans + ( (n // a) - 1) else : ans = ans + ( (n // a) ) a += 1 print(ans)
53
20
860
265
n = int(eval(input())) ans = 0 count = 0 a, b, c = 1, 1, 1 while a <= n: # print("A : {0}".format(a)) # print("追加パターン : {0}".format( (n // a) )) if a == 1: ans = ans + ((n // a) - 1) else: if n // a == 1: ans = ans + 1 else: if n % a == 0: ...
n = int(eval(input())) ans = 0 a = 1 while a <= n: if a == 1: ans = ans + (n - 1) else: if n % a == 0: ans = ans + ((n // a) - 1) else: ans = ans + ((n // a)) a += 1 print(ans)
false
62.264151
[ "-count = 0", "-a, b, c = 1, 1, 1", "+a = 1", "- # print(\"A : {0}\".format(a))", "- # print(\"追加パターン : {0}\".format( (n // a) ))", "- ans = ans + ((n // a) - 1)", "+ ans = ans + (n - 1)", "- if n // a == 1:", "- ans = ans + 1", "+ if n % a == 0:", "+...
false
0.39541
0.27969
1.413745
[ "s137209442", "s815663188" ]
u327532412
p03160
python
s194176007
s093042353
131
118
20,640
20,444
Accepted
Accepted
9.92
N = int(eval(input())) *h, = list(map(int, input().split())) dp = [0] * N for i in range(1, N): if i == 1: dp[i] = dp[i-1] + abs(h[i] - h[i-1]) else: dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2])) print((dp[-1]))
N = int(eval(input())) *h, = list(map(int, input().split())) dp = [0] * N dp[1] = abs(h[0] - h[1]) for i in range(2, N): dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i])) print((dp[-1]))
9
7
255
204
N = int(eval(input())) (*h,) = list(map(int, input().split())) dp = [0] * N for i in range(1, N): if i == 1: dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]) else: dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])) print((dp[-1]))
N = int(eval(input())) (*h,) = list(map(int, input().split())) dp = [0] * N dp[1] = abs(h[0] - h[1]) for i in range(2, N): dp[i] = min(dp[i - 2] + abs(h[i - 2] - h[i]), dp[i - 1] + abs(h[i - 1] - h[i])) print((dp[-1]))
false
22.222222
[ "-for i in range(1, N):", "- if i == 1:", "- dp[i] = dp[i - 1] + abs(h[i] - h[i - 1])", "- else:", "- dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))", "+dp[1] = abs(h[0] - h[1])", "+for i in range(2, N):", "+ dp[i] = min(dp[i - 2] + abs(h[i - 2] ...
false
0.036555
0.040242
0.908357
[ "s194176007", "s093042353" ]
u729133443
p03273
python
s064663944
s194474837
159
18
12,532
3,060
Accepted
Accepted
88.68
from numpy import* h,w=int8(input().split()) a=array(eval('list(input()),'*h)) print((*list(map(''.join,a[any(a<'.',1)][:,any(a<'.',0)]))))
f=lambda s:list(zip(*[t for t in s if'#'in t]));print((*list(map(''.join,f(f(open(0)))))))
4
1
134
76
from numpy import * h, w = int8(input().split()) a = array(eval("list(input())," * h)) print((*list(map("".join, a[any(a < ".", 1)][:, any(a < ".", 0)]))))
f = lambda s: list(zip(*[t for t in s if "#" in t])) print((*list(map("".join, f(f(open(0)))))))
false
75
[ "-from numpy import *", "-", "-h, w = int8(input().split())", "-a = array(eval(\"list(input()),\" * h))", "-print((*list(map(\"\".join, a[any(a < \".\", 1)][:, any(a < \".\", 0)]))))", "+f = lambda s: list(zip(*[t for t in s if \"#\" in t]))", "+print((*list(map(\"\".join, f(f(open(0)))))))" ]
false
0.21245
0.037233
5.70591
[ "s064663944", "s194474837" ]
u017810624
p02925
python
s415885255
s543767970
981
639
54,236
53,980
Accepted
Accepted
34.86
n=int(eval(input()));l=[list(map(int,input().split()))for i in[0]*n];a=[0 for i in[0]*n];d=1;k=n*(n-1) while sum(a)<k and 0<d<9999: L=[];y=0;d+=1 for i in range(n): if a[i]<n-1: x=l[i][a[i]]-1 if not(l[x][a[x]]-1!=i or x in L or i in L): a[i]+=1;a[x]+=1;L+=[i,x];y=1 d*=y print(([k//2,d-1][d<9999...
n=int(eval(input()));l=[list(map(int,input().split()))for i in[0]*n];a=[0]*n;d=1;k=n*(n-1) while sum(a)<k and 0<d<9999: L=[0]*n;y=0;d+=1 for i in range(n): if a[i]<n-1: x=l[i][a[i]]-1 if l[x][a[x]]-1==i and L[x]+L[i]<1: a[i]+=1;a[x]+=1;L[i]=L[x]=y=1 d*=y print(([k//2,d-1][d<9999]))
10
10
315
298
n = int(eval(input())) l = [list(map(int, input().split())) for i in [0] * n] a = [0 for i in [0] * n] d = 1 k = n * (n - 1) while sum(a) < k and 0 < d < 9999: L = [] y = 0 d += 1 for i in range(n): if a[i] < n - 1: x = l[i][a[i]] - 1 if not (l[x][a[x]] - 1 != i or x in L...
n = int(eval(input())) l = [list(map(int, input().split())) for i in [0] * n] a = [0] * n d = 1 k = n * (n - 1) while sum(a) < k and 0 < d < 9999: L = [0] * n y = 0 d += 1 for i in range(n): if a[i] < n - 1: x = l[i][a[i]] - 1 if l[x][a[x]] - 1 == i and L[x] + L[i] < 1: ...
false
0
[ "-a = [0 for i in [0] * n]", "+a = [0] * n", "- L = []", "+ L = [0] * n", "- if not (l[x][a[x]] - 1 != i or x in L or i in L):", "+ if l[x][a[x]] - 1 == i and L[x] + L[i] < 1:", "- L += [i, x]", "- y = 1", "+ L[i] = L[x] = y = ...
false
0.041498
0.036283
1.143727
[ "s415885255", "s543767970" ]
u577170763
p03162
python
s035289746
s690804195
319
276
54,124
42,860
Accepted
Accepted
13.48
# import sys # sys.setrecursionlimit(10**5) # from collections import defaultdict import sys readline = sys.stdin.buffer.readline geta = lambda fn: list(map(fn, readline().split())) gete = lambda fn: fn(readline()) def main(): n=gete(int) dp=[[0]*3 for _ in range(n+1)] for i in range(n): a,b,c =...
# import sys # sys.setrecursionlimit(10**5) # from collections import defaultdict import sys readline = sys.stdin.buffer.readline geta = lambda fn: list(map(fn, readline().split())) gete = lambda fn: fn(readline()) def main(): N = gete(int) cur, prev = [0]*3, [0]*3 for _ in range(N): ...
25
26
553
578
# import sys # sys.setrecursionlimit(10**5) # from collections import defaultdict import sys readline = sys.stdin.buffer.readline geta = lambda fn: list(map(fn, readline().split())) gete = lambda fn: fn(readline()) def main(): n = gete(int) dp = [[0] * 3 for _ in range(n + 1)] for i in range(n): ...
# import sys # sys.setrecursionlimit(10**5) # from collections import defaultdict import sys readline = sys.stdin.buffer.readline geta = lambda fn: list(map(fn, readline().split())) gete = lambda fn: fn(readline()) def main(): N = gete(int) cur, prev = [0] * 3, [0] * 3 for _ in range(N): a, b, c ...
false
3.846154
[ "- n = gete(int)", "- dp = [[0] * 3 for _ in range(n + 1)]", "- for i in range(n):", "+ N = gete(int)", "+ cur, prev = [0] * 3, [0] * 3", "+ for _ in range(N):", "- dp[i + 1][0] = max(dp[i][1], dp[i][2]) + a", "- dp[i + 1][1] = max(dp[i][2], dp[i][0]) + b", "- ...
false
0.036797
0.035566
1.034631
[ "s035289746", "s690804195" ]
u419877586
p02780
python
s508042017
s716111823
250
183
75,784
24,812
Accepted
Accepted
26.8
import itertools N, K=list(map(int, input().split())) p=list(map(int, input().split())) acup=list(itertools.accumulate([(x+1)/2 for x in p])) ans=acup[K-1] for i in range(K, N): ans=max(ans, acup[i]-acup[i-K]) print(ans)
N, K = list(map(int, input().split())) p = list(map(int, input().split())) exp = [(1+p[i])/2 for i in range(N)] s = sum(exp[:K]) ans = s for i in range(K, N): s -= exp[i-K] s += exp[i] ans = max(ans, s) print(ans)
9
11
231
230
import itertools N, K = list(map(int, input().split())) p = list(map(int, input().split())) acup = list(itertools.accumulate([(x + 1) / 2 for x in p])) ans = acup[K - 1] for i in range(K, N): ans = max(ans, acup[i] - acup[i - K]) print(ans)
N, K = list(map(int, input().split())) p = list(map(int, input().split())) exp = [(1 + p[i]) / 2 for i in range(N)] s = sum(exp[:K]) ans = s for i in range(K, N): s -= exp[i - K] s += exp[i] ans = max(ans, s) print(ans)
false
18.181818
[ "-import itertools", "-", "-acup = list(itertools.accumulate([(x + 1) / 2 for x in p]))", "-ans = acup[K - 1]", "+exp = [(1 + p[i]) / 2 for i in range(N)]", "+s = sum(exp[:K])", "+ans = s", "- ans = max(ans, acup[i] - acup[i - K])", "+ s -= exp[i - K]", "+ s += exp[i]", "+ ans = max(...
false
0.03645
0.037905
0.961618
[ "s508042017", "s716111823" ]
u707500405
p03548
python
s557125224
s800106905
27
17
2,940
2,940
Accepted
Accepted
37.04
X, Y, Z = list(map(int, input().split())) ans = 1 while ans * (Y + Z) + Z <= X: ans += 1 print((ans - 1))
X, Y, Z = list(map(int, input().split())) print(((X - Z) // (Y + Z)))
5
2
103
63
X, Y, Z = list(map(int, input().split())) ans = 1 while ans * (Y + Z) + Z <= X: ans += 1 print((ans - 1))
X, Y, Z = list(map(int, input().split())) print(((X - Z) // (Y + Z)))
false
60
[ "-ans = 1", "-while ans * (Y + Z) + Z <= X:", "- ans += 1", "-print((ans - 1))", "+print(((X - Z) // (Y + Z)))" ]
false
0.139555
0.090801
1.536925
[ "s557125224", "s800106905" ]
u249218427
p02574
python
s628488423
s974047172
1,266
329
126,252
231,404
Accepted
Accepted
74.01
N = int(eval(input())) A = list(map(int, input().split())) maxA = max(A) counts = [0 for _ in range(maxA+1)] for a in A: counts[a] += 1 integers = [1 for _ in range(maxA+1)] integers[0] = 0 integers[1] = 0 max_count = 0 for i in range(maxA+1): if integers[i] >= 1: count = 0 for j in range(...
N = int(eval(input())) A = list(map(int, input().split())) M = 10**6 + 1 counts = [0 for _ in range(M)] for a in A: counts[a] += 1 integers = [1 for _ in range(M)] integers[0] = 0 integers[1] = 0 max_count = 0 for i in range(M): if integers[i] >= 1: count = 0 for j in range(i,M,i): ...
28
28
568
548
N = int(eval(input())) A = list(map(int, input().split())) maxA = max(A) counts = [0 for _ in range(maxA + 1)] for a in A: counts[a] += 1 integers = [1 for _ in range(maxA + 1)] integers[0] = 0 integers[1] = 0 max_count = 0 for i in range(maxA + 1): if integers[i] >= 1: count = 0 for j in range(...
N = int(eval(input())) A = list(map(int, input().split())) M = 10**6 + 1 counts = [0 for _ in range(M)] for a in A: counts[a] += 1 integers = [1 for _ in range(M)] integers[0] = 0 integers[1] = 0 max_count = 0 for i in range(M): if integers[i] >= 1: count = 0 for j in range(i, M, i): ...
false
0
[ "-maxA = max(A)", "-counts = [0 for _ in range(maxA + 1)]", "+M = 10**6 + 1", "+counts = [0 for _ in range(M)]", "-integers = [1 for _ in range(maxA + 1)]", "+integers = [1 for _ in range(M)]", "-for i in range(maxA + 1):", "+for i in range(M):", "- for j in range(i, maxA + 1, i):", "+ ...
false
0.074891
1.093013
0.068518
[ "s628488423", "s974047172" ]
u976225138
p03612
python
s220602041
s659808455
76
65
19,948
19,960
Accepted
Accepted
14.47
n = int(eval(input())) p = [int(x) for x in input().split()] cnt = 0 for i in range(n): if p[i] == i + 1: cnt += 1 if i != n - 1: p[i], p[i+1] = p[i+1], p[i] else: print(cnt)
n = int(eval(input())) p = [int(x) for x in input().split()] skip = False cnt = 0 for i in range(n): if skip: skip = False elif p[i] == i + 1: cnt += 1 skip = True else: print(cnt)
11
13
215
223
n = int(eval(input())) p = [int(x) for x in input().split()] cnt = 0 for i in range(n): if p[i] == i + 1: cnt += 1 if i != n - 1: p[i], p[i + 1] = p[i + 1], p[i] else: print(cnt)
n = int(eval(input())) p = [int(x) for x in input().split()] skip = False cnt = 0 for i in range(n): if skip: skip = False elif p[i] == i + 1: cnt += 1 skip = True else: print(cnt)
false
15.384615
[ "+skip = False", "- if p[i] == i + 1:", "+ if skip:", "+ skip = False", "+ elif p[i] == i + 1:", "- if i != n - 1:", "- p[i], p[i + 1] = p[i + 1], p[i]", "+ skip = True" ]
false
0.113276
0.046853
2.417683
[ "s220602041", "s659808455" ]
u970197315
p03627
python
s684777539
s883036734
101
79
18,600
18,600
Accepted
Accepted
21.78
from collections import Counter n=eval(input()) a=list(map(int,input().split())) a=Counter(a) f,t=[],[] for k in a: if a[k]>=4: f.append(k) if a[k]>=2: t.append(k) # print('f:',f) # print('t:',t) ans1=0 for ff in f: ans1=max(ans1,ff**2) ans2=0 t.sort(reverse=True) if len(t...
from collections import Counter n=int(eval(input())) a=list(map(int,input().split())) c=Counter(a) l4,l2=[],[] for k,v in list(c.items()): if v>=4:l4.append(k) if v>=2:l2.append(k) l4.sort(reverse=True) l2.sort(reverse=True) if len(l4)<=2:l4+=[0,0] if len(l2)<=2:l2+=[0,0] print((max(l4[0]*l4[1],l4[0...
22
15
365
333
from collections import Counter n = eval(input()) a = list(map(int, input().split())) a = Counter(a) f, t = [], [] for k in a: if a[k] >= 4: f.append(k) if a[k] >= 2: t.append(k) # print('f:',f) # print('t:',t) ans1 = 0 for ff in f: ans1 = max(ans1, ff**2) ans2 = 0 t.sort(reverse=True) if l...
from collections import Counter n = int(eval(input())) a = list(map(int, input().split())) c = Counter(a) l4, l2 = [], [] for k, v in list(c.items()): if v >= 4: l4.append(k) if v >= 2: l2.append(k) l4.sort(reverse=True) l2.sort(reverse=True) if len(l4) <= 2: l4 += [0, 0] if len(l2) <= 2: ...
false
31.818182
[ "-n = eval(input())", "+n = int(eval(input()))", "-a = Counter(a)", "-f, t = [], []", "-for k in a:", "- if a[k] >= 4:", "- f.append(k)", "- if a[k] >= 2:", "- t.append(k)", "-# print('f:',f)", "-# print('t:',t)", "-ans1 = 0", "-for ff in f:", "- ans1 = max(ans1, ff*...
false
0.046692
0.04673
0.99918
[ "s684777539", "s883036734" ]
u790710233
p03102
python
s995825468
s457628921
162
17
13,160
2,940
Accepted
Accepted
89.51
import numpy as np n, m, c = list(map(int, input().split())) b = np.array(list(map(int, input().split()))) ans = [] for i in range(n): a = np.array(list(map(int, input().split()))) if b.dot(a)+c > 0: ans.append(i+1) print((len(ans)))
n, m, c = list(map(int, input().split())) b_l = list(map(int, input().split())) ans = [] for i in range(n): a_l = list(map(int, input().split())) if sum(a*b for a, b in zip(a_l, b_l)) + c > 0: ans.append(i) print((len(ans)))
10
8
252
240
import numpy as np n, m, c = list(map(int, input().split())) b = np.array(list(map(int, input().split()))) ans = [] for i in range(n): a = np.array(list(map(int, input().split()))) if b.dot(a) + c > 0: ans.append(i + 1) print((len(ans)))
n, m, c = list(map(int, input().split())) b_l = list(map(int, input().split())) ans = [] for i in range(n): a_l = list(map(int, input().split())) if sum(a * b for a, b in zip(a_l, b_l)) + c > 0: ans.append(i) print((len(ans)))
false
20
[ "-import numpy as np", "-", "-b = np.array(list(map(int, input().split())))", "+b_l = list(map(int, input().split()))", "- a = np.array(list(map(int, input().split())))", "- if b.dot(a) + c > 0:", "- ans.append(i + 1)", "+ a_l = list(map(int, input().split()))", "+ if sum(a * b fo...
false
0.253695
0.037004
6.855807
[ "s995825468", "s457628921" ]
u408260374
p00874
python
s570055819
s803161223
40
20
7,880
6,624
Accepted
Accepted
50
from collections import Counter while True: W, D = list(map(int, input().split())) if not (W | D): break hw = [int(x) for x in input().split()] hd = [int(x) for x in input().split()] print((sum(hw) + sum(hd) - sum(k * v for k, v in list((Counter(hw) & Counter(hd)).items()))))
from collections import Counter import sys if sys.version[0] == '2': range, input = xrange, raw_input while True: W, D = list(map(int, input().split())) if not (W | D): break hw = [int(x) for x in input().split()] hd = [int(x) for x in input().split()] print((sum(hw) + sum(hd) ...
8
11
297
374
from collections import Counter while True: W, D = list(map(int, input().split())) if not (W | D): break hw = [int(x) for x in input().split()] hd = [int(x) for x in input().split()] print( ( sum(hw) + sum(hd) - sum(k * v for k, v in list((Counter...
from collections import Counter import sys if sys.version[0] == "2": range, input = xrange, raw_input while True: W, D = list(map(int, input().split())) if not (W | D): break hw = [int(x) for x in input().split()] hd = [int(x) for x in input().split()] print( ( sum(h...
false
27.272727
[ "+import sys", "+if sys.version[0] == \"2\":", "+ range, input = xrange, raw_input" ]
false
0.041968
0.042529
0.986788
[ "s570055819", "s803161223" ]
u761320129
p02889
python
s139525732
s304645917
1,861
1,086
96,348
99,992
Accepted
Accepted
41.64
import sys input = sys.stdin.readline N,M,L = map(int,input().split()) ABC = [tuple(map(int,input().split())) for i in range(M)] Q = int(input()) ST = [tuple(map(int,input().split())) for i in range(Q)] INF = 10**20 g = [[INF]*N for _ in range(N)] for a,b,c in ABC: a,b = a-1,b-1 g[a][b] = g[b][a] = ...
import sys input = sys.stdin.readline N,M,L = map(int,input().split()) ABC = [tuple(map(int,input().split())) for i in range(M)] Q = int(input()) ST = [tuple(map(int,input().split())) for i in range(Q)] INF = float('inf') ds = [[INF]*N for i in range(N)] for a,b,c in ABC: a,b = a-1,b-1 ds[a][b] = ds...
41
37
1,023
932
import sys input = sys.stdin.readline N, M, L = map(int, input().split()) ABC = [tuple(map(int, input().split())) for i in range(M)] Q = int(input()) ST = [tuple(map(int, input().split())) for i in range(Q)] INF = 10**20 g = [[INF] * N for _ in range(N)] for a, b, c in ABC: a, b = a - 1, b - 1 g[a][b] = g[b][a...
import sys input = sys.stdin.readline N, M, L = map(int, input().split()) ABC = [tuple(map(int, input().split())) for i in range(M)] Q = int(input()) ST = [tuple(map(int, input().split())) for i in range(Q)] INF = float("inf") ds = [[INF] * N for i in range(N)] for a, b, c in ABC: a, b = a - 1, b - 1 ds[a][b] ...
false
9.756098
[ "-INF = 10**20", "-g = [[INF] * N for _ in range(N)]", "+INF = float(\"inf\")", "+ds = [[INF] * N for i in range(N)]", "- g[a][b] = g[b][a] = c", "+ ds[a][b] = ds[b][a] = c", "- g[i][i] = 0", "+ ds[i][i] = 0", "- if g[i][j] > g[i][k] + g[k][j]:", "- g[i][j] = ...
false
0.038447
0.037493
1.025459
[ "s139525732", "s304645917" ]
u561083515
p03963
python
s020703046
s679503467
18
16
2,940
2,940
Accepted
Accepted
11.11
N,K = [int(i) for i in input().split()] ans = K for _ in range(N-1): ans *= K - 1 print(ans)
N,K = list(map(int, input().split())) ans = K for _ in range(N - 1): ans *= K - 1 print(ans)
7
6
104
96
N, K = [int(i) for i in input().split()] ans = K for _ in range(N - 1): ans *= K - 1 print(ans)
N, K = list(map(int, input().split())) ans = K for _ in range(N - 1): ans *= K - 1 print(ans)
false
14.285714
[ "-N, K = [int(i) for i in input().split()]", "+N, K = list(map(int, input().split()))" ]
false
0.037043
0.042989
0.8617
[ "s020703046", "s679503467" ]
u609061751
p02921
python
s643466205
s042229459
170
17
38,460
2,940
Accepted
Accepted
90
S=list(eval(input())) T=list(eval(input())) cnt = 0 for i in range(3): if S[i] == T[i]: cnt += 1 print(cnt)
import sys input = sys.stdin.readline s = input().rstrip() t = input().rstrip() cnt = 0 for i in range(3): if s[i] == t[i]: cnt += 1 print(cnt)
7
15
113
179
S = list(eval(input())) T = list(eval(input())) cnt = 0 for i in range(3): if S[i] == T[i]: cnt += 1 print(cnt)
import sys input = sys.stdin.readline s = input().rstrip() t = input().rstrip() cnt = 0 for i in range(3): if s[i] == t[i]: cnt += 1 print(cnt)
false
53.333333
[ "-S = list(eval(input()))", "-T = list(eval(input()))", "+import sys", "+", "+input = sys.stdin.readline", "+s = input().rstrip()", "+t = input().rstrip()", "- if S[i] == T[i]:", "+ if s[i] == t[i]:" ]
false
0.121572
0.041995
2.894903
[ "s643466205", "s042229459" ]
u163320134
p02616
python
s942942420
s771488515
237
199
31,636
31,696
Accepted
Accepted
16.03
mod=10**9+7 n,k=list(map(int,input().split())) arr=list(map(int,input().split())) arr=sorted(arr,reverse=True,key=lambda x:abs(x)) if k==n: ans=1 for i in range(n): ans*=arr[i] ans%=mod print(ans) else: if k%2==1 and max(arr)<0: ans=1 for i in range(k): ans*=arr[n-1-i] ...
mod=10**9+7 n,k=list(map(int,input().split())) arr=list(map(int,input().split())) cnt_plus=0 cnt_zero=0 cnt_minus=0 arr_plus=[] arr_minus=[] for i in range(n): if arr[i]>0: cnt_plus+=1 arr_plus.append(arr[i]) elif arr[i]<0: cnt_minus+=1 arr_minus.append(-arr[i]) else: cnt_zero+...
75
95
1,658
1,957
mod = 10**9 + 7 n, k = list(map(int, input().split())) arr = list(map(int, input().split())) arr = sorted(arr, reverse=True, key=lambda x: abs(x)) if k == n: ans = 1 for i in range(n): ans *= arr[i] ans %= mod print(ans) else: if k % 2 == 1 and max(arr) < 0: ans = 1 for i...
mod = 10**9 + 7 n, k = list(map(int, input().split())) arr = list(map(int, input().split())) cnt_plus = 0 cnt_zero = 0 cnt_minus = 0 arr_plus = [] arr_minus = [] for i in range(n): if arr[i] > 0: cnt_plus += 1 arr_plus.append(arr[i]) elif arr[i] < 0: cnt_minus += 1 arr_minus.appe...
false
21.052632
[ "-arr = sorted(arr, reverse=True, key=lambda x: abs(x))", "+cnt_plus = 0", "+cnt_zero = 0", "+cnt_minus = 0", "+arr_plus = []", "+arr_minus = []", "+for i in range(n):", "+ if arr[i] > 0:", "+ cnt_plus += 1", "+ arr_plus.append(arr[i])", "+ elif arr[i] < 0:", "+ cnt_...
false
0.0721
0.09509
0.758226
[ "s942942420", "s771488515" ]
u562935282
p03579
python
s817793622
s070567474
789
580
75,500
35,216
Accepted
Accepted
26.49
from collections import deque n, m = list(map(int, input().split())) e = [set() for _ in range(n)] for _ in range(m): a, b = list(map(int, input().split())) a -= 1 b -= 1 e[a].add(b) e[b].add(a) dq = deque() dq.append(0) p = [None] * n p[0] = 0 is_bipartite = True while dq: ...
from collections import deque n, m = list(map(int, input().split())) g = [set() for _ in range(n)] for _ in range(m): a, b = (int(x) - 1 for x in input().split()) g[a].add(b) g[b].add(a) par = [-1] * n def is_bipartite(): dq = deque() dq.append(0) par[0] = 0 while dq:...
39
49
724
1,011
from collections import deque n, m = list(map(int, input().split())) e = [set() for _ in range(n)] for _ in range(m): a, b = list(map(int, input().split())) a -= 1 b -= 1 e[a].add(b) e[b].add(a) dq = deque() dq.append(0) p = [None] * n p[0] = 0 is_bipartite = True while dq: v = dq.popleft() ...
from collections import deque n, m = list(map(int, input().split())) g = [set() for _ in range(n)] for _ in range(m): a, b = (int(x) - 1 for x in input().split()) g[a].add(b) g[b].add(a) par = [-1] * n def is_bipartite(): dq = deque() dq.append(0) par[0] = 0 while dq: v = dq.pople...
false
20.408163
[ "-e = [set() for _ in range(n)]", "+g = [set() for _ in range(n)]", "- a, b = list(map(int, input().split()))", "- a -= 1", "- b -= 1", "- e[a].add(b)", "- e[b].add(a)", "-dq = deque()", "-dq.append(0)", "-p = [None] * n", "-p[0] = 0", "-is_bipartite = True", "-while dq:", "...
false
0.036598
0.0331
1.105695
[ "s817793622", "s070567474" ]
u159994501
p03127
python
s578724354
s151008987
126
85
14,252
14,252
Accepted
Accepted
32.54
def gcd(a, b): if b == 0: return a else: return gcd(b, a % b) N = int(eval(input())) A = list(map(int,input().split())) A.sort(reverse=True) a = A[0] for i in range(1,N): a = gcd(a,A[i]) print(a)
def gcd(a, b): if b > a: a,b = b,a if b == 0: return a else: return gcd(b, a % b) N = int(eval(input())) A = list(map(int,input().split())) a = A[0] for i in range(1,N): a = gcd(a,A[i]) print(a)
12
13
229
241
def gcd(a, b): if b == 0: return a else: return gcd(b, a % b) N = int(eval(input())) A = list(map(int, input().split())) A.sort(reverse=True) a = A[0] for i in range(1, N): a = gcd(a, A[i]) print(a)
def gcd(a, b): if b > a: a, b = b, a if b == 0: return a else: return gcd(b, a % b) N = int(eval(input())) A = list(map(int, input().split())) a = A[0] for i in range(1, N): a = gcd(a, A[i]) print(a)
false
7.692308
[ "+ if b > a:", "+ a, b = b, a", "-A.sort(reverse=True)" ]
false
0.081472
0.035657
2.284901
[ "s578724354", "s151008987" ]
u260036763
p02713
python
s154165344
s165609397
1,901
446
9,576
9,568
Accepted
Accepted
76.54
import math # from itertools import product from functools import reduce def main(): # def gcd(*numbers): return reduce(math.gcd, numbers) K = int(eval(input())) ans = 0 # valiation = list(itertools.product(range(1, K+1), repeat=3)) # for v in valiation: # ans += gcd(v) for i...
import math # from itertools import product from functools import reduce def main(): # def gcd(*numbers): return reduce(math.gcd, numbers) K = int(eval(input())) ans = 0 # valiation = list(itertools.product(range(1, K+1), repeat=3)) # for v in valiation: # ans += gcd(v) for i...
20
26
526
729
import math # from itertools import product from functools import reduce def main(): # def gcd(*numbers): return reduce(math.gcd, numbers) K = int(eval(input())) ans = 0 # valiation = list(itertools.product(range(1, K+1), repeat=3)) # for v in valiation: # ans += gcd(v) ...
import math # from itertools import product from functools import reduce def main(): # def gcd(*numbers): return reduce(math.gcd, numbers) K = int(eval(input())) ans = 0 # valiation = list(itertools.product(range(1, K+1), repeat=3)) # for v in valiation: # ans += gcd(v) ...
false
23.076923
[ "- for j in range(1, K + 1):", "- for k in range(1, K + 1):", "- ans += math.gcd(math.gcd(i, j), k)", "+ for j in range(i, K + 1):", "+ for k in range(j, K + 1):", "+ x = math.gcd(math.gcd(i, j), k)", "+ if i == j == k:", ...
false
0.11196
0.053914
2.076629
[ "s154165344", "s165609397" ]
u124498235
p02813
python
s255668768
s290131957
114
98
3,064
6,040
Accepted
Accepted
14.04
import itertools n = int(eval(input())) p = list(map(int, input().split())) pp = "".join((str(n) for n in p)) q = list(map(int, input().split())) qq = "".join((str(n) for n in q)) a = [i+1 for i in range(n)] b = 0 c = 0 d = 0 for i in itertools.permutations(a): d += 1 x = "".join((str(n) for n in i)) if...
import itertools n = int(eval(input())) p = list(map(int, input().split())) pp = "".join([str(i) for i in p]) q = list(map(int, input().split())) qq = "".join([str(i) for i in q]) x = [i+1 for i in range(n)] z = [] for v in itertools.permutations(x): y = "".join([str(i) for i in v]) z.append(y) a = z.index...
18
14
373
353
import itertools n = int(eval(input())) p = list(map(int, input().split())) pp = "".join((str(n) for n in p)) q = list(map(int, input().split())) qq = "".join((str(n) for n in q)) a = [i + 1 for i in range(n)] b = 0 c = 0 d = 0 for i in itertools.permutations(a): d += 1 x = "".join((str(n) for n in i)) if ...
import itertools n = int(eval(input())) p = list(map(int, input().split())) pp = "".join([str(i) for i in p]) q = list(map(int, input().split())) qq = "".join([str(i) for i in q]) x = [i + 1 for i in range(n)] z = [] for v in itertools.permutations(x): y = "".join([str(i) for i in v]) z.append(y) a = z.index(p...
false
22.222222
[ "-pp = \"\".join((str(n) for n in p))", "+pp = \"\".join([str(i) for i in p])", "-qq = \"\".join((str(n) for n in q))", "-a = [i + 1 for i in range(n)]", "-b = 0", "-c = 0", "-d = 0", "-for i in itertools.permutations(a):", "- d += 1", "- x = \"\".join((str(n) for n in i))", "- if pp ==...
false
0.049455
0.048639
1.01677
[ "s255668768", "s290131957" ]
u780962115
p02838
python
s234456965
s030985985
1,948
1,164
38,968
178,600
Accepted
Accepted
40.25
import sys input=sys.stdin.readline n=int(eval(input())) lists=list(map(int,input().split())) length=61 use=[0 for i in range(61)] a,b=divmod(n,9) anslist=[0 for i in range(a+1)] for j in range(n): k=format(lists[j],"0%ib"%length) k=k[::-1] p,q=divmod(j,9) if p>a: anslist.append(st...
#昔はtleの回答、今は通る? import sys input=sys.stdin.readline n=int(eval(input())) lists=list(map(int,input().split())) aa=[0 for i in range(n)] bb=[0 for i in range(n)] length=61 use=[0 for i in range(61)] for j in range(n): k=format(lists[j],"0%ib"%length) k=k[::-1] aa[j]=k[:30] bb[j]=k[30:] fo...
27
25
620
578
import sys input = sys.stdin.readline n = int(eval(input())) lists = list(map(int, input().split())) length = 61 use = [0 for i in range(61)] a, b = divmod(n, 9) anslist = [0 for i in range(a + 1)] for j in range(n): k = format(lists[j], "0%ib" % length) k = k[::-1] p, q = divmod(j, 9) if p > a: ...
# 昔はtleの回答、今は通る? import sys input = sys.stdin.readline n = int(eval(input())) lists = list(map(int, input().split())) aa = [0 for i in range(n)] bb = [0 for i in range(n)] length = 61 use = [0 for i in range(61)] for j in range(n): k = format(lists[j], "0%ib" % length) k = k[::-1] aa[j] = k[:30] bb[j] ...
false
7.407407
[ "+# 昔はtleの回答、今は通る?", "+aa = [0 for i in range(n)]", "+bb = [0 for i in range(n)]", "-a, b = divmod(n, 9)", "-anslist = [0 for i in range(a + 1)]", "- p, q = divmod(j, 9)", "- if p > a:", "- anslist.append(str(k))", "- else:", "- anslist[p] += int(k)", "+ aa[j] = k[:30]"...
false
0.037377
0.066571
0.561457
[ "s234456965", "s030985985" ]
u301624971
p02873
python
s093538507
s504489354
345
192
35,292
30,652
Accepted
Accepted
44.35
def modelAnswer(S:list) -> int: l = [0 for i in range(len(S)+1)] for n,s in enumerate(S): if(s == "<"): l[n+1] = l[n] + 1 for n,s in enumerate(S[::-1]): if(s == ">"): tmp = l[len(S) - n] + 1 if (tmp > l[len(S) - n - 1]): l[len(S) -n - 1] = tmp r...
def myAnswer(S:list) -> int: N = len(S)+1 ans = [0]*N for i in range(len(S)-1,-1,-1): if(S[i] == ">"): ans[i] = ans[i+1]+1 # print(ans) for i in range(len(S)): if(S[i]== "<"): if(ans[i] >= ans[i + 1]): ans[i + 1] = ans[i]+1 # print(ans) return s...
17
29
435
759
def modelAnswer(S: list) -> int: l = [0 for i in range(len(S) + 1)] for n, s in enumerate(S): if s == "<": l[n + 1] = l[n] + 1 for n, s in enumerate(S[::-1]): if s == ">": tmp = l[len(S) - n] + 1 if tmp > l[len(S) - n - 1]: l[len(S) - n - 1...
def myAnswer(S: list) -> int: N = len(S) + 1 ans = [0] * N for i in range(len(S) - 1, -1, -1): if S[i] == ">": ans[i] = ans[i + 1] + 1 # print(ans) for i in range(len(S)): if S[i] == "<": if ans[i] >= ans[i + 1]: ans[i + 1] = ans[i] + 1 # p...
false
41.37931
[ "+def myAnswer(S: list) -> int:", "+ N = len(S) + 1", "+ ans = [0] * N", "+ for i in range(len(S) - 1, -1, -1):", "+ if S[i] == \">\":", "+ ans[i] = ans[i + 1] + 1", "+ # print(ans)", "+ for i in range(len(S)):", "+ if S[i] == \"<\":", "+ if ans[i...
false
0.138106
0.035404
3.90082
[ "s093538507", "s504489354" ]
u912237403
p00033
python
s528203069
s192314905
20
10
4,200
4,204
Accepted
Accepted
50
n=eval(input()) for i in range(n): dt=list(map(int, input().split())) a1=0 a2=0 for e in dt: if e>a1: a1=e elif e>a2: a2=e else: print("NO") break else: print("YES")
def f(x): a,b=0,0 for e in x: if e>a: a=e elif e>b: b=e else: return False return True n=eval(input()) for i in range(n): dt=list(map(int, input().split())) if f(dt): print("YES") else: print("NO")
13
13
243
248
n = eval(input()) for i in range(n): dt = list(map(int, input().split())) a1 = 0 a2 = 0 for e in dt: if e > a1: a1 = e elif e > a2: a2 = e else: print("NO") break else: print("YES")
def f(x): a, b = 0, 0 for e in x: if e > a: a = e elif e > b: b = e else: return False return True n = eval(input()) for i in range(n): dt = list(map(int, input().split())) if f(dt): print("YES") else: print("NO")
false
0
[ "+def f(x):", "+ a, b = 0, 0", "+ for e in x:", "+ if e > a:", "+ a = e", "+ elif e > b:", "+ b = e", "+ else:", "+ return False", "+ return True", "+", "+", "- a1 = 0", "- a2 = 0", "- for e in dt:", "- if e...
false
0.115029
0.047068
2.443893
[ "s528203069", "s192314905" ]
u193264896
p02999
python
s696511461
s915846870
35
17
5,076
3,060
Accepted
Accepted
51.43
from collections import deque from collections import Counter from itertools import product, permutations,combinations from operator import itemgetter from heapq import heappop, heappush from bisect import bisect_left, bisect_right, bisect #pypyではscipy, numpyは使えない #from scipy.sparse.csgraph import shortest_path,...
import sys readline = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 8) INF = float('inf') MOD = 10 ** 9 + 7 def main(): X, A = list(map(int, readline().split())) if X<A: print('0') else: print('10') if __name__ == '__main__': main()
32
15
892
282
from collections import deque from collections import Counter from itertools import product, permutations, combinations from operator import itemgetter from heapq import heappop, heappush from bisect import bisect_left, bisect_right, bisect # pypyではscipy, numpyは使えない # from scipy.sparse.csgraph import shortest_path, fl...
import sys readline = sys.stdin.buffer.readline sys.setrecursionlimit(10**8) INF = float("inf") MOD = 10**9 + 7 def main(): X, A = list(map(int, readline().split())) if X < A: print("0") else: print("10") if __name__ == "__main__": main()
false
53.125
[ "-from collections import deque", "-from collections import Counter", "-from itertools import product, permutations, combinations", "-from operator import itemgetter", "-from heapq import heappop, heappush", "-from bisect import bisect_left, bisect_right, bisect", "-", "-# pypyではscipy, numpyは使えない", ...
false
0.045313
0.045474
0.996479
[ "s696511461", "s915846870" ]
u690536347
p03722
python
s425673877
s245794398
1,316
315
3,316
44,904
Accepted
Accepted
76.06
n,m=list(map(int,input().split())) inf=float("inf") l=[tuple(map(int,input().split())) for i in range(m)] d=[inf]*n d[0]=0 for i in range(n): for a,b,c in l: a,b,c=a-1,b-1,-c if d[a]!=inf and d[b]>d[a]+c: d[b]=d[a]+c if i==n-1 and b==n-1: print("inf") exit() print...
n,m=list(map(int,input().split())) es=[list(map(int,input().split())) for _ in range(m)] inf=float("inf") d=[-inf]*(n+1) d[1]=0 def bellman_ford(): for i in range(n): isUpdated=False for e_from,e_to,cost in es: if d[e_to]<d[e_from]+cost: d[e_to]=d[e_from]+cost isUpdated=True...
16
19
322
432
n, m = list(map(int, input().split())) inf = float("inf") l = [tuple(map(int, input().split())) for i in range(m)] d = [inf] * n d[0] = 0 for i in range(n): for a, b, c in l: a, b, c = a - 1, b - 1, -c if d[a] != inf and d[b] > d[a] + c: d[b] = d[a] + c if i == n - 1 and b ==...
n, m = list(map(int, input().split())) es = [list(map(int, input().split())) for _ in range(m)] inf = float("inf") d = [-inf] * (n + 1) d[1] = 0 def bellman_ford(): for i in range(n): isUpdated = False for e_from, e_to, cost in es: if d[e_to] < d[e_from] + cost: d[e_to]...
false
15.789474
[ "+es = [list(map(int, input().split())) for _ in range(m)]", "-l = [tuple(map(int, input().split())) for i in range(m)]", "-d = [inf] * n", "-d[0] = 0", "-for i in range(n):", "- for a, b, c in l:", "- a, b, c = a - 1, b - 1, -c", "- if d[a] != inf and d[b] > d[a] + c:", "- ...
false
0.087617
0.129801
0.675008
[ "s425673877", "s245794398" ]
u384124931
p02690
python
s718807303
s590824739
73
64
64,612
9,108
Accepted
Accepted
12.33
import sys x = int(eval(input())) for i in range(-200, 200): for j in range(-200, 200): if i**5-j**5 ==x: print((i,j)) sys.exit()
import sys def main(): x = int(eval(input())) for i in range(-200, 200): for j in range(-200, 200): if i**5-j**5 ==x: print((i,j)) sys.exit() if __name__ == "__main__": main()
7
10
145
204
import sys x = int(eval(input())) for i in range(-200, 200): for j in range(-200, 200): if i**5 - j**5 == x: print((i, j)) sys.exit()
import sys def main(): x = int(eval(input())) for i in range(-200, 200): for j in range(-200, 200): if i**5 - j**5 == x: print((i, j)) sys.exit() if __name__ == "__main__": main()
false
30
[ "-x = int(eval(input()))", "-for i in range(-200, 200):", "- for j in range(-200, 200):", "- if i**5 - j**5 == x:", "- print((i, j))", "- sys.exit()", "+", "+def main():", "+ x = int(eval(input()))", "+ for i in range(-200, 200):", "+ for j in range(-...
false
0.133391
0.086824
1.536345
[ "s718807303", "s590824739" ]
u425177436
p03146
python
s317129764
s258314416
27
17
10,740
2,940
Accepted
Accepted
37.04
a = int(eval(input())) t = [0]*1000000 t[a] = 1 for i in range(2,1000001): if a % 2 == 0: a //= 2 else: a = 3*a + 1 if t[a]: break t[a] = 1 print(i)
a = int(eval(input())) t = set() t.add(a) for i in range(2,1000001): if a % 2 == 0: a //= 2 else: a = 3*a + 1 if a in t: break t.add(a) print(i)
12
12
193
189
a = int(eval(input())) t = [0] * 1000000 t[a] = 1 for i in range(2, 1000001): if a % 2 == 0: a //= 2 else: a = 3 * a + 1 if t[a]: break t[a] = 1 print(i)
a = int(eval(input())) t = set() t.add(a) for i in range(2, 1000001): if a % 2 == 0: a //= 2 else: a = 3 * a + 1 if a in t: break t.add(a) print(i)
false
0
[ "-t = [0] * 1000000", "-t[a] = 1", "+t = set()", "+t.add(a)", "- if t[a]:", "+ if a in t:", "- t[a] = 1", "+ t.add(a)" ]
false
0.04432
0.040844
1.085112
[ "s317129764", "s258314416" ]
u968166680
p02726
python
s817417446
s987575906
128
110
74,312
74,464
Accepted
Accepted
14.06
import sys from collections import deque read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): N, X, Y = list(map(int, readline().split())) X -= 1 Y -= 1 ans = [0] * N for...
import sys from collections import deque read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): N, X, Y = list(map(int, readline().split())) X -= 1 Y -= 1 ans = [0] * N for...
30
30
579
550
import sys from collections import deque read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): N, X, Y = list(map(int, readline().split())) X -= 1 Y -= 1 ans = [0] * N for i in range(N - 1): ...
import sys from collections import deque read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): N, X, Y = list(map(int, readline().split())) X -= 1 Y -= 1 ans = [0] * N for i in range(N - 1): ...
false
0
[ "- d = min(j - i, abs(i - X) + 1 + abs(Y - j), abs(j - X) + 1 + abs(X - i))", "+ d = min(j - i, abs(i - X) + 1 + abs(Y - j))" ]
false
0.035563
0.047178
0.753797
[ "s817417446", "s987575906" ]
u340781749
p02591
python
s450115815
s964433109
1,951
389
108,424
32,604
Accepted
Accepted
80.06
import sys h, *ppp = list(map(int, sys.stdin.buffer.read().split())) n = 1 << (h - 1) ppp = [p + n - 1 for p in ppp] MOD = 10 ** 9 + 7 cumprods = [1] * (2 * n) # 根から頂点vまでの経路の累積積 cumprods_rev = [1] * n # ..の逆数 cumprods_through = [0] * n # 木1の根から木2の根まで、木1の i 番目の葉を経由する経路の積 for i in range(2, 2 * n): cum...
import os import sys import numpy as np def solve(inp): def mod_pow(x, a, MOD): ret = 1 cur = x while a: if a & 1: ret = ret * cur % MOD cur = cur * cur % MOD a >>= 1 return ret h = inp[0] ppp = inp[1:]...
51
92
1,725
2,655
import sys h, *ppp = list(map(int, sys.stdin.buffer.read().split())) n = 1 << (h - 1) ppp = [p + n - 1 for p in ppp] MOD = 10**9 + 7 cumprods = [1] * (2 * n) # 根から頂点vまでの経路の累積積 cumprods_rev = [1] * n # ..の逆数 cumprods_through = [0] * n # 木1の根から木2の根まで、木1の i 番目の葉を経由する経路の積 for i in range(2, 2 * n): cumprods[i] = cum...
import os import sys import numpy as np def solve(inp): def mod_pow(x, a, MOD): ret = 1 cur = x while a: if a & 1: ret = ret * cur % MOD cur = cur * cur % MOD a >>= 1 return ret h = inp[0] ppp = inp[1:] n = 1 << (h - ...
false
44.565217
[ "+import os", "+import numpy as np", "-h, *ppp = list(map(int, sys.stdin.buffer.read().split()))", "-n = 1 << (h - 1)", "-ppp = [p + n - 1 for p in ppp]", "-MOD = 10**9 + 7", "-cumprods = [1] * (2 * n) # 根から頂点vまでの経路の累積積", "-cumprods_rev = [1] * n # ..の逆数", "-cumprods_through = [0] * n # 木1の根から木2の...
false
0.041209
0.950986
0.043333
[ "s450115815", "s964433109" ]
u569960318
p02277
python
s186976808
s473132945
2,400
1,350
42,512
42,572
Accepted
Accepted
43.75
from collections import namedtuple Card = namedtuple('Card', 'suit value') def partition(A,p,r): x = A[r] i = p for j in range(p,r): if A[j].value <= x.value: A[i],A[j] = A[j],A[i] i += 1 A[i],A[r] = A[r],A[i] return i def quickSort(A,p,r): if p < ...
from collections import namedtuple Card = namedtuple('Card', 'suit value') def partition(A,p,r): x = A[r] i = p for j in range(p,r): if A[j].value <= x.value: A[i],A[j] = A[j],A[i] i += 1 A[i],A[r] = A[r],A[i] return i def quickSort(A,p,r): if p < ...
48
36
1,160
897
from collections import namedtuple Card = namedtuple("Card", "suit value") def partition(A, p, r): x = A[r] i = p for j in range(p, r): if A[j].value <= x.value: A[i], A[j] = A[j], A[i] i += 1 A[i], A[r] = A[r], A[i] return i def quickSort(A, p, r): if p < r:...
from collections import namedtuple Card = namedtuple("Card", "suit value") def partition(A, p, r): x = A[r] i = p for j in range(p, r): if A[j].value <= x.value: A[i], A[j] = A[j], A[i] i += 1 A[i], A[r] = A[r], A[i] return i def quickSort(A, p, r): if p < r:...
false
25
[ "-def merge(L, R):", "- global cnt", "- n = len(L) + len(R)", "- A = []", "- i = j = 0", "- L.append(Card(\"X\", -1))", "- R.append(Card(\"X\", -1))", "- for _ in range(n):", "- if L[i].value > R[j].value:", "- A.append(L[i])", "- i += 1", "- ...
false
0.077978
0.037795
2.06318
[ "s186976808", "s473132945" ]
u564589929
p02714
python
s441589916
s091873918
1,011
169
9,228
68,524
Accepted
Accepted
83.28
# import sys # sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())) def LLI(rows_number): return [LI() for _ in range(...
import sys sys.setrecursionlimit(10 ** 6) # input = sys.stdin.readline #### int1 = lambda x: int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())) def LI1(): retur...
41
59
945
1,258
# import sys # sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())) def LLI(rows_number): return [L...
import sys sys.setrecursionlimit(10**6) # input = sys.stdin.readline #### int1 = lambda x: int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())) def...
false
30.508475
[ "-# import sys", "-# sys.setrecursionlimit(10 ** 6)", "+import sys", "+", "+sys.setrecursionlimit(10**6)", "+# input = sys.stdin.readline ####", "+def LI1():", "+ return list(map(int1, input().split()))", "+", "+", "+", "+", "+INF = float(\"inf\")", "+ # print(S)", "+ n = len...
false
0.054614
0.054739
0.997716
[ "s441589916", "s091873918" ]
u597622207
p03745
python
s761359694
s083974118
121
99
14,484
14,052
Accepted
Accepted
18.18
N = int(eval(input())) A = list(map(int, input().split())) count = 1 state = "" for i in range(N-1): if A[i] > A[i+1] and state == "": state = "minus" elif A[i] > A[i+1] and state == "plus": state = "" count += 1 elif A[i] > A[i+1] and state == "minus": continue ...
""" 覚えておきたい """ n,*a=list(map(int,open(0).read().split())) ans=1 tmp=0 for i in range(1,n): if (a[i]-a[i-1])*tmp<0: ans+=1 tmp=0 elif not a[i]-a[i-1]==0: tmp=a[i]-a[i-1] print(ans)
23
14
570
204
N = int(eval(input())) A = list(map(int, input().split())) count = 1 state = "" for i in range(N - 1): if A[i] > A[i + 1] and state == "": state = "minus" elif A[i] > A[i + 1] and state == "plus": state = "" count += 1 elif A[i] > A[i + 1] and state == "minus": continue e...
""" 覚えておきたい """ n, *a = list(map(int, open(0).read().split())) ans = 1 tmp = 0 for i in range(1, n): if (a[i] - a[i - 1]) * tmp < 0: ans += 1 tmp = 0 elif not a[i] - a[i - 1] == 0: tmp = a[i] - a[i - 1] print(ans)
false
39.130435
[ "-N = int(eval(input()))", "-A = list(map(int, input().split()))", "-count = 1", "-state = \"\"", "-for i in range(N - 1):", "- if A[i] > A[i + 1] and state == \"\":", "- state = \"minus\"", "- elif A[i] > A[i + 1] and state == \"plus\":", "- state = \"\"", "- count += 1...
false
0.035297
0.030613
1.153004
[ "s761359694", "s083974118" ]
u604839890
p02639
python
s267516311
s416384121
85
68
61,820
61,700
Accepted
Accepted
20
x = list(map(int, input().split())) for i in range(5): if x[i] == 0: print((i+1)) exit()
x = list(map(int, input().split())) print((x.index(0)+1))
5
2
101
56
x = list(map(int, input().split())) for i in range(5): if x[i] == 0: print((i + 1)) exit()
x = list(map(int, input().split())) print((x.index(0) + 1))
false
60
[ "-for i in range(5):", "- if x[i] == 0:", "- print((i + 1))", "- exit()", "+print((x.index(0) + 1))" ]
false
0.034588
0.03552
0.973742
[ "s267516311", "s416384121" ]
u463775490
p03325
python
s181795075
s541630650
92
76
4,148
4,148
Accepted
Accepted
17.39
n = int(eval(input())) a = [int(i) for i in input().split()] ans = 0 for i in a: while i % 2 == 0: i //= 2 ans += 1 print(ans)
n = int(eval(input())) a = list(map(int, input().split())) ans = 0 for i in a: while not (i & 1): ans += 1 i //= 2 print(ans)
8
8
147
146
n = int(eval(input())) a = [int(i) for i in input().split()] ans = 0 for i in a: while i % 2 == 0: i //= 2 ans += 1 print(ans)
n = int(eval(input())) a = list(map(int, input().split())) ans = 0 for i in a: while not (i & 1): ans += 1 i //= 2 print(ans)
false
0
[ "-a = [int(i) for i in input().split()]", "+a = list(map(int, input().split()))", "- while i % 2 == 0:", "+ while not (i & 1):", "+ ans += 1", "- ans += 1" ]
false
0.112255
0.04656
2.410997
[ "s181795075", "s541630650" ]
u219417113
p03168
python
s301053190
s052356519
879
746
252,296
275,464
Accepted
Accepted
15.13
N = int(eval(input())) P = list(map(float, input().split())) """ dp[i][j]: i枚投げた時にj枚表の確率 """ dp = [[0] * (N+1) for _ in range(N+1)] dp[1][0] = 1 - P[0] dp[1][1] = P[0] for i in range(1, N+1): for j in range(1, N+1): dp[i][j] += dp[i-1][j-1] * P[i-1] dp[i][j-1] += dp[i-1][j-1] * (1-P[i...
import sys input = sys.stdin.readline def main(): N = int(eval(input())) P = list(map(float, input().split())) dp = [[0] * (N+1) for _ in range((N+1))] dp[0][0] = 1 for i in range(1, N+1): for j in range(i+1): dp[i][j] = dp[i-1][j]*(1-P[i-1]) + dp[i-1][j-1]*P[i-1] ...
20
15
407
383
N = int(eval(input())) P = list(map(float, input().split())) """ dp[i][j]: i枚投げた時にj枚表の確率 """ dp = [[0] * (N + 1) for _ in range(N + 1)] dp[1][0] = 1 - P[0] dp[1][1] = P[0] for i in range(1, N + 1): for j in range(1, N + 1): dp[i][j] += dp[i - 1][j - 1] * P[i - 1] dp[i][j - 1] += dp[i - 1][j - 1] * (...
import sys input = sys.stdin.readline def main(): N = int(eval(input())) P = list(map(float, input().split())) dp = [[0] * (N + 1) for _ in range((N + 1))] dp[0][0] = 1 for i in range(1, N + 1): for j in range(i + 1): dp[i][j] = dp[i - 1][j] * (1 - P[i - 1]) + dp[i - 1][j - 1]...
false
25
[ "-N = int(eval(input()))", "-P = list(map(float, input().split()))", "-\"\"\"", "-dp[i][j]: i枚投げた時にj枚表の確率", "-\"\"\"", "-dp = [[0] * (N + 1) for _ in range(N + 1)]", "-dp[1][0] = 1 - P[0]", "-dp[1][1] = P[0]", "-for i in range(1, N + 1):", "- for j in range(1, N + 1):", "- dp[i][j] += ...
false
0.037135
0.086195
0.430821
[ "s301053190", "s052356519" ]
u197968862
p03288
python
s133503592
s772246210
19
17
2,940
2,940
Accepted
Accepted
10.53
r = int(eval(input())) if r < 1200: print('ABC') elif r < 2800: print('ARC') else: print('AGC')
r = int(eval(input())) if r < 1200: print('ABC') elif 1200 <= r < 2800: print('ARC') else: print('AGC')
7
7
107
115
r = int(eval(input())) if r < 1200: print("ABC") elif r < 2800: print("ARC") else: print("AGC")
r = int(eval(input())) if r < 1200: print("ABC") elif 1200 <= r < 2800: print("ARC") else: print("AGC")
false
0
[ "-elif r < 2800:", "+elif 1200 <= r < 2800:" ]
false
0.05784
0.053127
1.08871
[ "s133503592", "s772246210" ]
u790012205
p03479
python
s932859448
s807116408
19
17
3,060
2,940
Accepted
Accepted
10.53
X, Y = list(map(int, input().split())) Z = X c = 0 while Z <= Y: c += 1 Z = 2 * Z print(c)
X, Y = list(map(int, input().split())) n = 0 A = X while A <= Y: n += 1 A *= 2 print(n)
7
7
98
95
X, Y = list(map(int, input().split())) Z = X c = 0 while Z <= Y: c += 1 Z = 2 * Z print(c)
X, Y = list(map(int, input().split())) n = 0 A = X while A <= Y: n += 1 A *= 2 print(n)
false
0
[ "-Z = X", "-c = 0", "-while Z <= Y:", "- c += 1", "- Z = 2 * Z", "-print(c)", "+n = 0", "+A = X", "+while A <= Y:", "+ n += 1", "+ A *= 2", "+print(n)" ]
false
0.042781
0.043867
0.975248
[ "s932859448", "s807116408" ]
u711539583
p02726
python
s418497835
s477845804
1,063
886
71,904
59,612
Accepted
Accepted
16.65
import heapq # 単一始点最短経路。2地点間ではなく、始点が一つで各点へのコストを計算する # eは隣接リストでe[v] = [(u1,cost1), (u2,cost2)]みたいな形を想定 # 辺の重みは正である必要がある # O(ElogV) def dijkstra(e,n,s): inf = 10**18 d = [inf]*n d[s] = 0 q = [(d[s],s)] # priority queueのソートキーが第一要素 heapq.heapify([q]) while len(q)>0: _,v = heapq...
from heapq import heappush, heappop INF = 10 ** 18 def dijkstra(n, G, s): dist = [INF] * n dist[s] = 0 h = [] heappush(h, (0, s)) while h: # 使っていない頂点のうち、現時点で最も距離の近いものを選びvとする d, v = heappop(h) if dist[v] < d: continue # vから到達可能な頂点について、距離が短...
39
42
848
841
import heapq # 単一始点最短経路。2地点間ではなく、始点が一つで各点へのコストを計算する # eは隣接リストでe[v] = [(u1,cost1), (u2,cost2)]みたいな形を想定 # 辺の重みは正である必要がある # O(ElogV) def dijkstra(e, n, s): inf = 10**18 d = [inf] * n d[s] = 0 q = [(d[s], s)] # priority queueのソートキーが第一要素 heapq.heapify([q]) while len(q) > 0: _, v = heapq.hea...
from heapq import heappush, heappop INF = 10**18 def dijkstra(n, G, s): dist = [INF] * n dist[s] = 0 h = [] heappush(h, (0, s)) while h: # 使っていない頂点のうち、現時点で最も距離の近いものを選びvとする d, v = heappop(h) if dist[v] < d: continue # vから到達可能な頂点について、距離が短くなれば更新 fo...
false
7.142857
[ "-import heapq", "+from heapq import heappush, heappop", "-# 単一始点最短経路。2地点間ではなく、始点が一つで各点へのコストを計算する", "-# eは隣接リストでe[v] = [(u1,cost1), (u2,cost2)]みたいな形を想定", "-# 辺の重みは正である必要がある", "-# O(ElogV)", "-def dijkstra(e, n, s):", "- inf = 10**18", "- d = [inf] * n", "- d[s] = 0", "- q = [(d[s], s...
false
0.076491
0.037762
2.025605
[ "s418497835", "s477845804" ]
u901447859
p02928
python
s167920234
s900129570
238
33
3,188
3,316
Accepted
Accepted
86.13
N,K=list(map(int, input().split())) A=list(map(int, input().split())) MOD=10**9+7 def count(A,N): arr=[0]*N for i, ai in enumerate(A[:-1]): cnt=0 for aj in A[i+1:]: if ai > aj: cnt+=1 arr[i]=cnt return arr s1=sum(count(A,N)) s2=sum(count...
MOD = 10 ** 9 + 7 def MAP(): return list(map(int, input().split())) class BinaryIndexedTree: def __init__(self, tree_size): self.tree_size = tree_size self.tree = [0] * (self.tree_size + 1) def add(self, i, x): while 0 < i <= self.tree_size: self.tree[i...
19
48
385
1,007
N, K = list(map(int, input().split())) A = list(map(int, input().split())) MOD = 10**9 + 7 def count(A, N): arr = [0] * N for i, ai in enumerate(A[:-1]): cnt = 0 for aj in A[i + 1 :]: if ai > aj: cnt += 1 arr[i] = cnt return arr s1 = sum(count(A, N)) s...
MOD = 10**9 + 7 def MAP(): return list(map(int, input().split())) class BinaryIndexedTree: def __init__(self, tree_size): self.tree_size = tree_size self.tree = [0] * (self.tree_size + 1) def add(self, i, x): while 0 < i <= self.tree_size: self.tree[i] += x ...
false
60.416667
[ "-N, K = list(map(int, input().split()))", "-A = list(map(int, input().split()))", "-def count(A, N):", "- arr = [0] * N", "- for i, ai in enumerate(A[:-1]):", "- cnt = 0", "- for aj in A[i + 1 :]:", "- if ai > aj:", "- cnt += 1", "- arr[i] = cn...
false
0.053347
0.037056
1.439644
[ "s167920234", "s900129570" ]
u143509139
p02954
python
s738428769
s544403587
214
190
51,952
51,264
Accepted
Accepted
11.21
s = eval(input()) n = len(s) i = 0 ans = [0] * n for i in range(n - 1): if s[i] == 'R' and s[i + 1] == 'L': j = 0 while i - j >= 0 and s[i - j] == 'R': if j % 2: ans[i + 1] += 1 else: ans[i] += 1 j += 1 j = 1 ...
s = eval(input()) n = len(s) l = [0] for i in range(n - 1): if s[i] != s[i + 1]: l.append(i + 1) l.append(n) ans = [0] * n for i in range(1, len(l) - 1, 2): p = l[i] - l[i - 1] q = l[i + 1] - l[i] ans[l[i] - 1] = (p + 1) // 2 + q // 2 ans[l[i]] = p // 2 + (q + 1) // 2 print((' '...
21
14
513
335
s = eval(input()) n = len(s) i = 0 ans = [0] * n for i in range(n - 1): if s[i] == "R" and s[i + 1] == "L": j = 0 while i - j >= 0 and s[i - j] == "R": if j % 2: ans[i + 1] += 1 else: ans[i] += 1 j += 1 j = 1 while i...
s = eval(input()) n = len(s) l = [0] for i in range(n - 1): if s[i] != s[i + 1]: l.append(i + 1) l.append(n) ans = [0] * n for i in range(1, len(l) - 1, 2): p = l[i] - l[i - 1] q = l[i + 1] - l[i] ans[l[i] - 1] = (p + 1) // 2 + q // 2 ans[l[i]] = p // 2 + (q + 1) // 2 print((" ".join(map(str...
false
33.333333
[ "-i = 0", "+l = [0]", "+for i in range(n - 1):", "+ if s[i] != s[i + 1]:", "+ l.append(i + 1)", "+l.append(n)", "-for i in range(n - 1):", "- if s[i] == \"R\" and s[i + 1] == \"L\":", "- j = 0", "- while i - j >= 0 and s[i - j] == \"R\":", "- if j % 2:", "...
false
0.038557
0.16622
0.231966
[ "s738428769", "s544403587" ]
u998435601
p02396
python
s108103558
s781436824
40
30
6,312
6,320
Accepted
Accepted
25
i = 1 while True: a = input() if a == '0': break print("Case %d: %s" % (i,a)) i += 1
i = 1 while True: a = input() if a == '0': break print("Case %s: %s" % (i,a)) i += 1
7
7
99
99
i = 1 while True: a = input() if a == "0": break print("Case %d: %s" % (i, a)) i += 1
i = 1 while True: a = input() if a == "0": break print("Case %s: %s" % (i, a)) i += 1
false
0
[ "- print(\"Case %d: %s\" % (i, a))", "+ print(\"Case %s: %s\" % (i, a))" ]
false
0.048481
0.048414
1.001387
[ "s108103558", "s781436824" ]
u133936772
p02983
python
s903005436
s775545863
539
420
2,940
2,940
Accepted
Accepted
22.08
l,r=list(map(int,input().split())) M=2019;s=list(range(l,r+1)) print((0 if r//M-l//M>0 else min(i*j%M for i in s for j in s if i<j)))
M=2019;l,r=list(map(int,input().split())) print((0 if r//M-l//M>0 else min(i*j%M for i in range(l,r) for j in range(i+1,r+1))))
3
2
121
120
l, r = list(map(int, input().split())) M = 2019 s = list(range(l, r + 1)) print((0 if r // M - l // M > 0 else min(i * j % M for i in s for j in s if i < j)))
M = 2019 l, r = list(map(int, input().split())) print( ( 0 if r // M - l // M > 0 else min(i * j % M for i in range(l, r) for j in range(i + 1, r + 1)) ) )
false
33.333333
[ "+M = 2019", "-M = 2019", "-s = list(range(l, r + 1))", "-print((0 if r // M - l // M > 0 else min(i * j % M for i in s for j in s if i < j)))", "+print(", "+ (", "+ 0", "+ if r // M - l // M > 0", "+ else min(i * j % M for i in range(l, r) for j in range(i + 1, r + 1))", "...
false
0.09104
0.101796
0.894342
[ "s903005436", "s775545863" ]
u980205854
p03665
python
s351832561
s188924585
318
77
21,048
65,720
Accepted
Accepted
75.79
# A - Biscuits import numpy as np N, P = list(map(int, input().split())) A = list(map(int, input().split())) odd = len([i for i in A if i%2!=0]) if odd==0 and P==0: ans = 2**N elif odd==0 and P==1: ans = 0 else: ans = 2**(N-1) print(ans)
import sys from sys import exit from collections import deque from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値) from heapq import heapify, heappop, heappush from math import * sys.setrecursionlimit(10**6) INF = 10**20 eps = 1.0e-20 MOD = 10**9+7 def lcm(x,y): return...
13
38
256
892
# A - Biscuits import numpy as np N, P = list(map(int, input().split())) A = list(map(int, input().split())) odd = len([i for i in A if i % 2 != 0]) if odd == 0 and P == 0: ans = 2**N elif odd == 0 and P == 1: ans = 0 else: ans = 2 ** (N - 1) print(ans)
import sys from sys import exit from collections import deque from bisect import bisect_left, bisect_right, insort_left, insort_right # func(リスト,値) from heapq import heapify, heappop, heappush from math import * sys.setrecursionlimit(10**6) INF = 10**20 eps = 1.0e-20 MOD = 10**9 + 7 def lcm(x, y): return x * y ...
false
65.789474
[ "-# A - Biscuits", "-import numpy as np", "+import sys", "+from sys import exit", "+from collections import deque", "+from bisect import bisect_left, bisect_right, insort_left, insort_right # func(リスト,値)", "+from heapq import heapify, heappop, heappush", "+from math import *", "-N, P = list(map(int...
false
0.061146
0.061403
0.9958
[ "s351832561", "s188924585" ]
u130900604
p03775
python
s246117551
s466064682
35
30
2,940
3,060
Accepted
Accepted
14.29
#n 10**10 #sqrtn 10**5 ans=10**6 n=int(eval(input())) for i in range(1,int(n**0.5)+1): if n%i==0: ans=min(len(str(n//i)),ans) print(ans)
def F(a,b): return max(len(str(a)),len(str(b))) n=int(eval(input())) ans=10**15 for i in range(1,int(n**0.5)+1): if n%i==0: a=i b=n//i ans=min(ans,F(a,b)) print(ans)
9
12
149
192
# n 10**10 # sqrtn 10**5 ans = 10**6 n = int(eval(input())) for i in range(1, int(n**0.5) + 1): if n % i == 0: ans = min(len(str(n // i)), ans) print(ans)
def F(a, b): return max(len(str(a)), len(str(b))) n = int(eval(input())) ans = 10**15 for i in range(1, int(n**0.5) + 1): if n % i == 0: a = i b = n // i ans = min(ans, F(a, b)) print(ans)
false
25
[ "-# n 10**10", "-# sqrtn 10**5", "-ans = 10**6", "+def F(a, b):", "+ return max(len(str(a)), len(str(b)))", "+", "+", "+ans = 10**15", "- ans = min(len(str(n // i)), ans)", "+ a = i", "+ b = n // i", "+ ans = min(ans, F(a, b))" ]
false
0.045044
0.050506
0.891861
[ "s246117551", "s466064682" ]
u098012509
p03329
python
s556808590
s896028087
239
92
3,828
73,340
Accepted
Accepted
61.51
import sys input = sys.stdin.readline def main(): N = int(eval(input())) dp = [0] * (10 ** 5 + 1) dp[1] = 1 x = [1] x.extend([6 ** x for x in range(1, 8)]) x.extend([9 ** x for x in range(1, 6)]) for i in range(2, 10 ** 5 + 1): tmp = [] for v in x: ...
N = int(eval(input())) dp = [0] * 100001 dp[1] = 1 for i in range(2, N + 1): dp[i] = dp[i - 1] + 1 j = 1 while 6 ** j <= i: dp[i] = min(dp[i], dp[i - (6 ** j)] + 1) j += 1 j = 1 while 9 ** j <= i: dp[i] = min(dp[i], dp[i - (9 ** j)] + 1) j += 1 pr...
29
18
471
325
import sys input = sys.stdin.readline def main(): N = int(eval(input())) dp = [0] * (10**5 + 1) dp[1] = 1 x = [1] x.extend([6**x for x in range(1, 8)]) x.extend([9**x for x in range(1, 6)]) for i in range(2, 10**5 + 1): tmp = [] for v in x: if i >= v: ...
N = int(eval(input())) dp = [0] * 100001 dp[1] = 1 for i in range(2, N + 1): dp[i] = dp[i - 1] + 1 j = 1 while 6**j <= i: dp[i] = min(dp[i], dp[i - (6**j)] + 1) j += 1 j = 1 while 9**j <= i: dp[i] = min(dp[i], dp[i - (9**j)] + 1) j += 1 print((dp[N]))
false
37.931034
[ "-import sys", "-", "-input = sys.stdin.readline", "-", "-", "-def main():", "- N = int(eval(input()))", "- dp = [0] * (10**5 + 1)", "- dp[1] = 1", "- x = [1]", "- x.extend([6**x for x in range(1, 8)])", "- x.extend([9**x for x in range(1, 6)])", "- for i in range(2, 10*...
false
1.22556
0.72485
1.690778
[ "s556808590", "s896028087" ]
u680851063
p03161
python
s742909542
s624971731
423
376
58,332
58,332
Accepted
Accepted
11.11
import sys input = sys.stdin.readline n,k = list(map(int,input().split())) h = tuple(map(int,input().split())) dp = [0] + [float("inf")]*(n-1) #print(dp) for i in range(1,n): for j in range(max(0,i-k),i): dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j])) #print(dp) print((dp[-1]))
import sys input = sys.stdin.readline n,k = map(int,input().split()) h = tuple(map(int,input().split())) def frog_2(N, H, K): dp = [0] + [float("inf")]*(n-1) #print(dp) for i in range(1,n): for j in range(max(0,i-k),i): dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j])) ...
15
20
294
380
import sys input = sys.stdin.readline n, k = list(map(int, input().split())) h = tuple(map(int, input().split())) dp = [0] + [float("inf")] * (n - 1) # print(dp) for i in range(1, n): for j in range(max(0, i - k), i): dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j])) # print(dp) print((dp[-1]))
import sys input = sys.stdin.readline n, k = map(int, input().split()) h = tuple(map(int, input().split())) def frog_2(N, H, K): dp = [0] + [float("inf")] * (n - 1) # print(dp) for i in range(1, n): for j in range(max(0, i - k), i): dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j])) # p...
false
25
[ "-n, k = list(map(int, input().split()))", "+n, k = map(int, input().split())", "-dp = [0] + [float(\"inf\")] * (n - 1)", "-# print(dp)", "-for i in range(1, n):", "- for j in range(max(0, i - k), i):", "- dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]))", "-# print(dp)", "-print((dp[-1]))", ...
false
0.036952
0.039577
0.933689
[ "s742909542", "s624971731" ]
u576432509
p02989
python
s964889299
s958090435
88
76
14,428
13,992
Accepted
Accepted
13.64
n=int(eval(input())) # print(n) di=[] for i in map(int,input().split()): di.append(i) di.sort() n1=int(n/2) m=di[n1] -di[n1-1] print(m)
n=int(eval(input())) d=list(map(int,input().split())) d.sort() print((d[n//2]-d[n//2-1]))
9
7
141
91
n = int(eval(input())) # print(n) di = [] for i in map(int, input().split()): di.append(i) di.sort() n1 = int(n / 2) m = di[n1] - di[n1 - 1] print(m)
n = int(eval(input())) d = list(map(int, input().split())) d.sort() print((d[n // 2] - d[n // 2 - 1]))
false
22.222222
[ "-# print(n)", "-di = []", "-for i in map(int, input().split()):", "- di.append(i)", "-di.sort()", "-n1 = int(n / 2)", "-m = di[n1] - di[n1 - 1]", "-print(m)", "+d = list(map(int, input().split()))", "+d.sort()", "+print((d[n // 2] - d[n // 2 - 1]))" ]
false
0.035205
0.066852
0.526614
[ "s964889299", "s958090435" ]
u306664745
p02983
python
s653814058
s877695480
945
72
2,940
3,060
Accepted
Accepted
92.38
l, r=list(map(int, input().split())) x, y=l//2019, r//2019 p=0 if x==y: p=2019 for i in range(l, r): for j in range(i+1, r+1): p=min(p, (((i%2019)*(j%2019))%2019)) print(p)
l, r=list(map(int, input().split())) x, y=l//2019, r//2019 p=0 if x==y: p=2019 for i in range(l, r): for j in range(i+1, r+1): p=min(p, (((i%2019)*(j%2019))%2019)) if not p: break if not p: break print(p)
9
13
181
229
l, r = list(map(int, input().split())) x, y = l // 2019, r // 2019 p = 0 if x == y: p = 2019 for i in range(l, r): for j in range(i + 1, r + 1): p = min(p, (((i % 2019) * (j % 2019)) % 2019)) print(p)
l, r = list(map(int, input().split())) x, y = l // 2019, r // 2019 p = 0 if x == y: p = 2019 for i in range(l, r): for j in range(i + 1, r + 1): p = min(p, (((i % 2019) * (j % 2019)) % 2019)) if not p: break if not p: break print(p)
false
30.769231
[ "+ if not p:", "+ break", "+ if not p:", "+ break" ]
false
0.11381
0.0344
3.308435
[ "s653814058", "s877695480" ]
u225388820
p02936
python
s708964516
s447161328
767
638
93,716
60,692
Accepted
Accepted
16.82
import sys input = sys.stdin.readline from collections import deque def main(): n,q = list(map(int,input().split())) node = [[]for _ in range(n)] looked = [1]*n for i in range(n-1): a,b = list(map(int,input().split())) node[b-1].append(a-1) node[a-1].append(b-1) co...
from collections import deque import os import io input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline def main(): n, q = list(map(int, input().split())) node = [[]for _ in range(n)] looked = [1] * n for i in range(n - 1): a, b = list(map(int, input().split())) node...
26
30
693
766
import sys input = sys.stdin.readline from collections import deque def main(): n, q = list(map(int, input().split())) node = [[] for _ in range(n)] looked = [1] * n for i in range(n - 1): a, b = list(map(int, input().split())) node[b - 1].append(a - 1) node[a - 1].append(b - ...
from collections import deque import os import io input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline def main(): n, q = list(map(int, input().split())) node = [[] for _ in range(n)] looked = [1] * n for i in range(n - 1): a, b = list(map(int, input().split())) node[b - 1].ap...
false
13.333333
[ "-import sys", "+from collections import deque", "+import os", "+import io", "-input = sys.stdin.readline", "-from collections import deque", "+input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline" ]
false
0.063515
0.070063
0.906543
[ "s708964516", "s447161328" ]
u984276646
p03381
python
s099288055
s672857732
1,088
447
47,552
25,228
Accepted
Accepted
58.92
N = int(eval(input())) X = list(map(int, input().split())) L = [] for i in range(N): L.append([X[i], i]) L.sort() for i in range(N): if i < N // 2: L[i].append(L[N // 2][0]) else: L[i].append(L[N // 2 - 1][0]) for i in range(N): L[i][0], L[i][1] = L[i][1], L[i][0] L.sort() for i in range(N...
N = int(eval(input())) X = list(map(int, input().split())) L = [0 for _ in range(N)] for i in range(N): X[i] = X[i] * N + i X.sort() d = N // 2 for i in range(N): if i < d: L[X[i]%N] = X[d] // N else: L[X[i]%N] = X[d-1] // N for i in range(N): print((L[i]))
16
14
334
278
N = int(eval(input())) X = list(map(int, input().split())) L = [] for i in range(N): L.append([X[i], i]) L.sort() for i in range(N): if i < N // 2: L[i].append(L[N // 2][0]) else: L[i].append(L[N // 2 - 1][0]) for i in range(N): L[i][0], L[i][1] = L[i][1], L[i][0] L.sort() for i in range...
N = int(eval(input())) X = list(map(int, input().split())) L = [0 for _ in range(N)] for i in range(N): X[i] = X[i] * N + i X.sort() d = N // 2 for i in range(N): if i < d: L[X[i] % N] = X[d] // N else: L[X[i] % N] = X[d - 1] // N for i in range(N): print((L[i]))
false
12.5
[ "-L = []", "+L = [0 for _ in range(N)]", "- L.append([X[i], i])", "-L.sort()", "+ X[i] = X[i] * N + i", "+X.sort()", "+d = N // 2", "- if i < N // 2:", "- L[i].append(L[N // 2][0])", "+ if i < d:", "+ L[X[i] % N] = X[d] // N", "- L[i].append(L[N // 2 - 1][0])",...
false
0.047124
0.047715
0.987615
[ "s099288055", "s672857732" ]
u119148115
p02588
python
s033301255
s153425833
266
244
87,388
91,656
Accepted
Accepted
8.27
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり def LI2(): return list(map(int,sys.stdin.readline().rstrip())) #空白なし def ...
import sys def I(): return int(sys.stdin.readline().rstrip()) def LS2(): return list(sys.stdin.readline().rstrip()) #空白なし N = I() A = [] # A[i] = A_iが2,5で各々何回割り切れるか for _ in range(N): a = LS2() if not '.' in a: a = int(''.join(a)) b,c = 0,0 while a % 2 == 0: a ...
63
56
1,493
1,185
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return list(map(int, sys.stdin.readline().rstrip().split())) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり def LI2(): return list(map(int, sys.stdin.readline().r...
import sys def I(): return int(sys.stdin.readline().rstrip()) def LS2(): return list(sys.stdin.readline().rstrip()) # 空白なし N = I() A = [] # A[i] = A_iが2,5で各々何回割り切れるか for _ in range(N): a = LS2() if not "." in a: a = int("".join(a)) b, c = 0, 0 while a % 2 == 0: ...
false
11.111111
[ "-", "-sys.setrecursionlimit(10**7)", "-", "-", "-def MI():", "- return list(map(int, sys.stdin.readline().rstrip().split()))", "-", "-", "-def LI():", "- return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり", "-", "-", "-def LI2():", "- return list(map(int, sys.st...
false
0.050017
0.110527
0.452529
[ "s033301255", "s153425833" ]
u075012704
p02954
python
s756472764
s852174672
127
117
9,712
6,508
Accepted
Accepted
7.87
from math import ceil import re S = input() N = len(S) X = re.findall('R+L+', S) ans = [0] * N i = 0 for x in X: x_len = len(x) start = x.find('RL') ans[i + start] += (x_len - start - 1) // 2 + ceil((start + 1) / 2) ans[i + start + 1] += (start + 1) // 2 + ceil((x_len - start - 1) / 2) ...
S = input() N = len(S) ans = [0] * N cnt = 0 for i, s in enumerate(S): if s == 'R': cnt += 1 else: ans[i] += cnt // 2 ans[i - 1] += (cnt + 1) // 2 cnt = 0 cnt = 0 ans = ans[::-1] for i, s in enumerate(S[::-1]): if s == 'L': cnt += 1 else: ...
19
26
362
432
from math import ceil import re S = input() N = len(S) X = re.findall("R+L+", S) ans = [0] * N i = 0 for x in X: x_len = len(x) start = x.find("RL") ans[i + start] += (x_len - start - 1) // 2 + ceil((start + 1) / 2) ans[i + start + 1] += (start + 1) // 2 + ceil((x_len - start - 1) / 2) i += x_len p...
S = input() N = len(S) ans = [0] * N cnt = 0 for i, s in enumerate(S): if s == "R": cnt += 1 else: ans[i] += cnt // 2 ans[i - 1] += (cnt + 1) // 2 cnt = 0 cnt = 0 ans = ans[::-1] for i, s in enumerate(S[::-1]): if s == "L": cnt += 1 else: ans[i] += cnt // ...
false
26.923077
[ "-from math import ceil", "-import re", "-", "-X = re.findall(\"R+L+\", S)", "-i = 0", "-for x in X:", "- x_len = len(x)", "- start = x.find(\"RL\")", "- ans[i + start] += (x_len - start - 1) // 2 + ceil((start + 1) / 2)", "- ans[i + start + 1] += (start + 1) // 2 + ceil((x_len - start...
false
0.13799
0.045633
3.023933
[ "s756472764", "s852174672" ]
u964494353
p03252
python
s642697374
s091992147
164
125
6,716
3,632
Accepted
Accepted
23.78
S = eval(input()) T = eval(input()) sid = {} tid = {} ss = [] tt = [] sn = 0 tn = 0 for i in range(len(S)): if not S[i] in sid: sid[S[i]] = sn sn += 1 ss += [sid[S[i]]] if not T[i] in tid: tid[T[i]] = tn tn += 1 tt += [tid[T[i]]] if ss == tt: print('...
S = eval(input()) T = eval(input()) for i in range(len(S)): if S.find(S[i]) != T.find(T[i]): print('No') exit() print('Yes')
21
7
337
138
S = eval(input()) T = eval(input()) sid = {} tid = {} ss = [] tt = [] sn = 0 tn = 0 for i in range(len(S)): if not S[i] in sid: sid[S[i]] = sn sn += 1 ss += [sid[S[i]]] if not T[i] in tid: tid[T[i]] = tn tn += 1 tt += [tid[T[i]]] if ss == tt: print("Yes") else: pr...
S = eval(input()) T = eval(input()) for i in range(len(S)): if S.find(S[i]) != T.find(T[i]): print("No") exit() print("Yes")
false
66.666667
[ "-sid = {}", "-tid = {}", "-ss = []", "-tt = []", "-sn = 0", "-tn = 0", "- if not S[i] in sid:", "- sid[S[i]] = sn", "- sn += 1", "- ss += [sid[S[i]]]", "- if not T[i] in tid:", "- tid[T[i]] = tn", "- tn += 1", "- tt += [tid[T[i]]]", "-if ss == tt:...
false
0.037867
0.070876
0.534269
[ "s642697374", "s091992147" ]
u077291787
p03821
python
s804679676
s811177140
186
87
17,380
25,124
Accepted
Accepted
53.23
# AGC009A - Multiple Array # greedy algorithm import sys input = sys.stdin.readline def main(): n = int(eval(input())) A = tuple(tuple(map(int, input().split())) for _ in range(n)) ans = 0 for i, j in A[::-1]: # # decide from the last one ans += -(i + ans) % j print(ans) if...
# AGC009A - Multiple Array def main(): N, *AB = list(map(int, open(0).read().split())) ans = 0 for i, j in zip(*[iter(AB[::-1])] * 2): # decide from the last one greedily ans += -(j + ans) % i print(ans) if __name__ == "__main__": main()
16
11
350
272
# AGC009A - Multiple Array # greedy algorithm import sys input = sys.stdin.readline def main(): n = int(eval(input())) A = tuple(tuple(map(int, input().split())) for _ in range(n)) ans = 0 for i, j in A[::-1]: # # decide from the last one ans += -(i + ans) % j print(ans) if __name__ ==...
# AGC009A - Multiple Array def main(): N, *AB = list(map(int, open(0).read().split())) ans = 0 for i, j in zip(*[iter(AB[::-1])] * 2): # decide from the last one greedily ans += -(j + ans) % i print(ans) if __name__ == "__main__": main()
false
31.25
[ "-# greedy algorithm", "-import sys", "-", "-input = sys.stdin.readline", "-", "-", "- n = int(eval(input()))", "- A = tuple(tuple(map(int, input().split())) for _ in range(n))", "+ N, *AB = list(map(int, open(0).read().split()))", "- for i, j in A[::-1]: # # decide from the last one"...
false
0.079797
0.0424
1.882005
[ "s804679676", "s811177140" ]
u923279197
p03060
python
s256245768
s309364334
181
18
38,704
3,060
Accepted
Accepted
90.06
n = int(eval(input())) v = list(map(int,input().split())) c = list(map(int,input().split())) ans = 0 for i in range(n): ans += max(v[i]-c[i],0) print(ans)
n = int(eval(input())) v = list(map(int,input().split())) c = list(map(int,input().split())) ans = 0 for i in range(n): if v[i]-c[i] >0: ans += v[i]-c[i] print(ans)
8
10
160
181
n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) ans = 0 for i in range(n): ans += max(v[i] - c[i], 0) print(ans)
n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) ans = 0 for i in range(n): if v[i] - c[i] > 0: ans += v[i] - c[i] print(ans)
false
20
[ "- ans += max(v[i] - c[i], 0)", "+ if v[i] - c[i] > 0:", "+ ans += v[i] - c[i]" ]
false
0.05502
0.035484
1.550554
[ "s256245768", "s309364334" ]
u094999522
p02580
python
s758850830
s372179546
504
348
68,332
127,216
Accepted
Accepted
30.95
(h,w,m),*s=[[*list(map(int,i.split()))]for i in open(0)] r,c=[0]*-~h,[0]*-~w for x,y in s: r[x]+=1 c[y]+=1 print(((R:=max(r))+(C:=max(c))-(r.count(R)*c.count(C)==sum(r[x]+c[y]==R+C for x,y in s))))
(h,w,m),*s=[[*list(map(int,i.split()))]for i in open(0)] r,c=[0]*-~h,[0]*-~w for x,y in s: r[x]+=1 c[y]+=1 R,C=max(r),max(c) print((R+C-(r.count(R)*c.count(C)==sum(r[x]+c[y]==R+C for x,y in s))))
6
7
203
202
(h, w, m), *s = [[*list(map(int, i.split()))] for i in open(0)] r, c = [0] * -~h, [0] * -~w for x, y in s: r[x] += 1 c[y] += 1 print( ( (R := max(r)) + (C := max(c)) - (r.count(R) * c.count(C) == sum(r[x] + c[y] == R + C for x, y in s)) ) )
(h, w, m), *s = [[*list(map(int, i.split()))] for i in open(0)] r, c = [0] * -~h, [0] * -~w for x, y in s: r[x] += 1 c[y] += 1 R, C = max(r), max(c) print((R + C - (r.count(R) * c.count(C) == sum(r[x] + c[y] == R + C for x, y in s))))
false
14.285714
[ "-print(", "- (", "- (R := max(r))", "- + (C := max(c))", "- - (r.count(R) * c.count(C) == sum(r[x] + c[y] == R + C for x, y in s))", "- )", "-)", "+R, C = max(r), max(c)", "+print((R + C - (r.count(R) * c.count(C) == sum(r[x] + c[y] == R + C for x, y in s))))" ]
false
0.046713
0.039831
1.172772
[ "s758850830", "s372179546" ]
u803848678
p03702
python
s834499700
s905210324
1,128
884
7,892
7,192
Accepted
Accepted
21.63
n, a, b = list(map(int, input().split())) h = [int(eval(input())) for i in range(n)] h.sort() def check(k): top = 0 tmp = h[::] for i in range(n): amari = tmp[i] - b*k if amari > 0: top += -(-amari//(a-b)) return top <= k # 二分探索 left = 0 right = -(-1*sum(h)//...
n, a, b = list(map(int, input().split())) h = [int(eval(input())) for i in range(n)] def check(k): cnt = 0 for i in h: hp = i - k*b if hp > 0: cnt += -(-hp//(a-b)) return cnt <= k left = 0 right = 10**10 while right - left>1: mid = (right + left)//2 if ch...
23
20
473
384
n, a, b = list(map(int, input().split())) h = [int(eval(input())) for i in range(n)] h.sort() def check(k): top = 0 tmp = h[::] for i in range(n): amari = tmp[i] - b * k if amari > 0: top += -(-amari // (a - b)) return top <= k # 二分探索 left = 0 right = -(-1 * sum(h) // b) ...
n, a, b = list(map(int, input().split())) h = [int(eval(input())) for i in range(n)] def check(k): cnt = 0 for i in h: hp = i - k * b if hp > 0: cnt += -(-hp // (a - b)) return cnt <= k left = 0 right = 10**10 while right - left > 1: mid = (right + left) // 2 if check...
false
13.043478
[ "-h.sort()", "- top = 0", "- tmp = h[::]", "- for i in range(n):", "- amari = tmp[i] - b * k", "- if amari > 0:", "- top += -(-amari // (a - b))", "- return top <= k", "+ cnt = 0", "+ for i in h:", "+ hp = i - k * b", "+ if hp > 0:", "...
false
0.049662
0.124662
0.398376
[ "s834499700", "s905210324" ]
u489959379
p02756
python
s593253028
s780999906
622
468
8,676
33,652
Accepted
Accepted
24.76
from collections import deque s = list(eval(input())) q = int(eval(input())) s = deque(s) flg = "order" for i in range(q): t, *f = list(map(str, input().split())) if t == "1": if flg == "order": flg = "reverse" else: flg = "order" else: if f[0...
import sys from collections import deque sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): s = eval(input()) q = int(eval(input())) query = [list(input().split()) for _ in range(q)] S = deque([s]) flg = 1 for i in range(q): if query[...
31
31
656
653
from collections import deque s = list(eval(input())) q = int(eval(input())) s = deque(s) flg = "order" for i in range(q): t, *f = list(map(str, input().split())) if t == "1": if flg == "order": flg = "reverse" else: flg = "order" else: if f[0] == "1": ...
import sys from collections import deque sys.setrecursionlimit(10**7) f_inf = float("inf") mod = 10**9 + 7 def resolve(): s = eval(input()) q = int(eval(input())) query = [list(input().split()) for _ in range(q)] S = deque([s]) flg = 1 for i in range(q): if query[i][0] == "1": ...
false
0
[ "+import sys", "-s = list(eval(input()))", "-q = int(eval(input()))", "-s = deque(s)", "-flg = \"order\"", "-for i in range(q):", "- t, *f = list(map(str, input().split()))", "- if t == \"1\":", "- if flg == \"order\":", "- flg = \"reverse\"", "+sys.setrecursionlimit(10**...
false
0.070898
0.042928
1.651549
[ "s593253028", "s780999906" ]
u947883560
p02796
python
s665932510
s800121338
631
414
27,540
52,316
Accepted
Accepted
34.39
#!/usr/bin/env python3 import sys INF = float("inf") def solve(N: int, X: "List[int]", L: "List[int]"): # 区間に変換する segs = [(x-l, x+l) for x, l in zip(X, L)] segs.sort(key=lambda x: x[1]) # 尻でソート # DP i個目の区間まで考えた時の残せる数 DP = [0]*N DP[0] = 1 for i in range(1, N): # 重な...
#!/usr/bin/env python3 import sys INF = float("inf") def solve(N: int, X: "List[int]", L: "List[int]"): # 区間に変換する segs = [(x-l, x+l) for x, l in zip(X, L)] segs.sort(key=lambda x: x[1]) # 尻でソート last = -INF count = 0 for i in range(N): if last <= segs[i][0]: ...
59
40
1,420
856
#!/usr/bin/env python3 import sys INF = float("inf") def solve(N: int, X: "List[int]", L: "List[int]"): # 区間に変換する segs = [(x - l, x + l) for x, l in zip(X, L)] segs.sort(key=lambda x: x[1]) # 尻でソート # DP i個目の区間まで考えた時の残せる数 DP = [0] * N DP[0] = 1 for i in range(1, N): # 重なっていなければ ...
#!/usr/bin/env python3 import sys INF = float("inf") def solve(N: int, X: "List[int]", L: "List[int]"): # 区間に変換する segs = [(x - l, x + l) for x, l in zip(X, L)] segs.sort(key=lambda x: x[1]) # 尻でソート last = -INF count = 0 for i in range(N): if last <= segs[i][0]: last = seg...
false
32.20339
[ "- # DP i個目の区間まで考えた時の残せる数", "- DP = [0] * N", "- DP[0] = 1", "- for i in range(1, N):", "- # 重なっていなければ", "- if segs[i - 1][1] <= segs[i][0]:", "- DP[i] = DP[i - 1] + 1", "- else:", "- # 加えないか", "- DP[i] = DP[i - 1]", "- ...
false
0.042115
0.040338
1.044037
[ "s665932510", "s800121338" ]
u515740713
p02536
python
s829952074
s206582327
1,695
207
966,480
79,252
Accepted
Accepted
87.79
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10**6) read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N,M = list(map(int,readline().split())) road = [[] for _ in range(N+1)] visit = [0]*(N+1) for i in range(M): x,y = list(map(int,read...
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10**6) read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines #Union Find #xの根を求める def find(x): if par[x] < 0: return x else: par[x] = find(par[x]) return par[x] ...
33
48
684
914
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10**6) read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, M = list(map(int, readline().split())) road = [[] for _ in range(N + 1)] visit = [0] * (N + 1) for i in range(M): x, y = list(map(int, readline...
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10**6) read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines # Union Find # xの根を求める def find(x): if par[x] < 0: return x else: par[x] = find(par[x]) return par[x] # xとyの属する集合の併合...
false
31.25
[ "-N, M = list(map(int, readline().split()))", "-road = [[] for _ in range(N + 1)]", "-visit = [0] * (N + 1)", "-for i in range(M):", "- x, y = list(map(int, readline().split()))", "- road[x].append(y)", "- road[y].append(x)", "+# Union Find", "+# xの根を求める", "+def find(x):", "+ if par[...
false
0.061354
0.036201
1.694825
[ "s829952074", "s206582327" ]
u539281377
p02953
python
s531971572
s263296538
85
61
15,020
14,396
Accepted
Accepted
28.24
N=int(eval(input())) H=list(map(int,input().split())) flag=True for i in range(1,N): if H[i]>H[i-1]: H[i]-=1 elif H[i]==H[i-1]: pass elif H[i]<H[i-1]: flag=False print(("Yes" if flag else "No"))
N=int(eval(input())) H=list(map(int,input().split())) pre=0 for h in H: if h<pre: print("No");exit() elif h>pre: pre=h-1 print("Yes")
11
9
232
159
N = int(eval(input())) H = list(map(int, input().split())) flag = True for i in range(1, N): if H[i] > H[i - 1]: H[i] -= 1 elif H[i] == H[i - 1]: pass elif H[i] < H[i - 1]: flag = False print(("Yes" if flag else "No"))
N = int(eval(input())) H = list(map(int, input().split())) pre = 0 for h in H: if h < pre: print("No") exit() elif h > pre: pre = h - 1 print("Yes")
false
18.181818
[ "-flag = True", "-for i in range(1, N):", "- if H[i] > H[i - 1]:", "- H[i] -= 1", "- elif H[i] == H[i - 1]:", "- pass", "- elif H[i] < H[i - 1]:", "- flag = False", "-print((\"Yes\" if flag else \"No\"))", "+pre = 0", "+for h in H:", "+ if h < pre:", "+ ...
false
0.03416
0.033912
1.00731
[ "s531971572", "s263296538" ]
u226849101
p02693
python
s363688900
s248573902
21
19
9,104
9,068
Accepted
Accepted
9.52
k =int(eval(input())) a , b=list(map(int,input().split())) flag = False if b-a >= k: flag=True else: for i in range(a,b+1): if i%k==0: flag=True if flag : print("OK") else: print("NG")
k =int(eval(input())) a , b=list(map(int,input().split())) flag = False for i in range(a,b+1):#range(a,b+1)=[a,a+1,a+2,.....,b] if i % k == 0: flag=True if flag : print("OK") else: print("NG")
16
15
218
219
k = int(eval(input())) a, b = list(map(int, input().split())) flag = False if b - a >= k: flag = True else: for i in range(a, b + 1): if i % k == 0: flag = True if flag: print("OK") else: print("NG")
k = int(eval(input())) a, b = list(map(int, input().split())) flag = False for i in range(a, b + 1): # range(a,b+1)=[a,a+1,a+2,.....,b] if i % k == 0: flag = True if flag: print("OK") else: print("NG")
false
6.25
[ "-if b - a >= k:", "- flag = True", "-else:", "- for i in range(a, b + 1):", "- if i % k == 0:", "- flag = True", "+for i in range(a, b + 1): # range(a,b+1)=[a,a+1,a+2,.....,b]", "+ if i % k == 0:", "+ flag = True" ]
false
0.036174
0.091665
0.394627
[ "s363688900", "s248573902" ]
u971811058
p03338
python
s685468011
s960427547
32
28
9,056
9,056
Accepted
Accepted
12.5
n = int(eval(input())) s = eval(input()) M = 0 for i in range(1, n): cnt = 0 s1 = s[:i] s2 = s[i:] t = {} for x in s1: if x not in t: t[x]=1 for k in s2: if k not in t: t[k]=0 if t[k] == 1: t[k]+=1 for x, y in list(t.items()): if y==2: cnt+=1 ...
n = int(eval(input())) s = eval(input()) ans = 0 for i in range(1,len(s)): s1 = set(s[:i]) s2 = set(s[i:]) ans = max(ans, len(s1&s2)) print(ans)
17
8
329
151
n = int(eval(input())) s = eval(input()) M = 0 for i in range(1, n): cnt = 0 s1 = s[:i] s2 = s[i:] t = {} for x in s1: if x not in t: t[x] = 1 for k in s2: if k not in t: t[k] = 0 if t[k] == 1: t[k] += 1 for x, y in list(t.items()):...
n = int(eval(input())) s = eval(input()) ans = 0 for i in range(1, len(s)): s1 = set(s[:i]) s2 = set(s[i:]) ans = max(ans, len(s1 & s2)) print(ans)
false
52.941176
[ "-M = 0", "-for i in range(1, n):", "- cnt = 0", "- s1 = s[:i]", "- s2 = s[i:]", "- t = {}", "- for x in s1:", "- if x not in t:", "- t[x] = 1", "- for k in s2:", "- if k not in t:", "- t[k] = 0", "- if t[k] == 1:", "- ...
false
0.039826
0.143276
0.277965
[ "s685468011", "s960427547" ]
u223264651
p02598
python
s088056088
s559349060
419
303
104,416
104,396
Accepted
Accepted
27.68
N,K = list(map(int,input().split())) A = list(map(int,input().split())) left = 1 right= max(A) import math dict_X = {} while True: cl = 0 for i in range(N): cl += math.ceil(A[i]/left) - 1 cr = 0 for i in range(N): cr += math.ceil(A[i]/right) - 1 mid = (left + right)//2 cm...
N,K = list(map(int,input().split())) A = list(map(int,input().split())) left = 1 right= max(A) import math while True: cl = 0 for i in range(N): cl += math.ceil(A[i]/left) - 1 mid = (left + right)//2 cm = 0 for i in range(N): cm += math.ceil(A[i]/mid) - 1 if(cl<=K): r...
50
46
583
500
N, K = list(map(int, input().split())) A = list(map(int, input().split())) left = 1 right = max(A) import math dict_X = {} while True: cl = 0 for i in range(N): cl += math.ceil(A[i] / left) - 1 cr = 0 for i in range(N): cr += math.ceil(A[i] / right) - 1 mid = (left + right) // 2 ...
N, K = list(map(int, input().split())) A = list(map(int, input().split())) left = 1 right = max(A) import math while True: cl = 0 for i in range(N): cl += math.ceil(A[i] / left) - 1 mid = (left + right) // 2 cm = 0 for i in range(N): cm += math.ceil(A[i] / mid) - 1 if cl <= K: ...
false
8
[ "-dict_X = {}", "- cr = 0", "- for i in range(N):", "- cr += math.ceil(A[i] / right) - 1", "- elif cm <= K:", "+ if cm <= K:", "- if left >= right - 1:", "+ if abs(left - right) <= 1:" ]
false
0.085747
0.036281
2.363431
[ "s088056088", "s559349060" ]
u667024514
p03130
python
s224650642
s028996385
20
18
3,316
3,060
Accepted
Accepted
10
from collections import Counter lis = [0 for i in range(4)] for i in range(3): a,b = list(map(int,input().split())) lis[a-1] += 1 lis[b-1] += 1 if lis.count(2) == 2: print("YES") else:print("NO")
lis = [1,2,2,3,3,4] li = [] for i in range(3): a,b, = list(map(int,input().split())) li.append(a) li.append(b) li.sort() if li == lis: print("YES") else: print("NO")
9
11
213
189
from collections import Counter lis = [0 for i in range(4)] for i in range(3): a, b = list(map(int, input().split())) lis[a - 1] += 1 lis[b - 1] += 1 if lis.count(2) == 2: print("YES") else: print("NO")
lis = [1, 2, 2, 3, 3, 4] li = [] for i in range(3): ( a, b, ) = list(map(int, input().split())) li.append(a) li.append(b) li.sort() if li == lis: print("YES") else: print("NO")
false
18.181818
[ "-from collections import Counter", "-", "-lis = [0 for i in range(4)]", "+lis = [1, 2, 2, 3, 3, 4]", "+li = []", "- a, b = list(map(int, input().split()))", "- lis[a - 1] += 1", "- lis[b - 1] += 1", "-if lis.count(2) == 2:", "+ (", "+ a,", "+ b,", "+ ) = list(ma...
false
0.159486
0.253216
0.62984
[ "s224650642", "s028996385" ]
u894258749
p03103
python
s300853618
s202469212
1,235
466
15,576
29,024
Accepted
Accepted
62.27
import numpy as np N,M = list(map(int,input().split())) A = np.empty(N,dtype=np.int64) B = np.empty(N,dtype=np.int64) for i in range(N): A[i],B[i] = list(map(np.int64, input().split())) order = A.argsort() A = A[order] B = B[order] Y = 0 for i in range(N): if B[i] >= M: Y += A[i]*M ...
inpl = lambda: list(map(int,input().split())) N,M = inpl() A = [] for i in range(N): A.append(inpl()) A.sort(key=lambda x: x[0]) Y = 0 for i in range(N): if A[i][1] >= M: Y += A[i][0]*M break else: Y += A[i][0]*A[i][1] M -= A[i][1] print(Y)
20
17
381
302
import numpy as np N, M = list(map(int, input().split())) A = np.empty(N, dtype=np.int64) B = np.empty(N, dtype=np.int64) for i in range(N): A[i], B[i] = list(map(np.int64, input().split())) order = A.argsort() A = A[order] B = B[order] Y = 0 for i in range(N): if B[i] >= M: Y += A[i] * M break...
inpl = lambda: list(map(int, input().split())) N, M = inpl() A = [] for i in range(N): A.append(inpl()) A.sort(key=lambda x: x[0]) Y = 0 for i in range(N): if A[i][1] >= M: Y += A[i][0] * M break else: Y += A[i][0] * A[i][1] M -= A[i][1] print(Y)
false
15
[ "-import numpy as np", "-", "-N, M = list(map(int, input().split()))", "-A = np.empty(N, dtype=np.int64)", "-B = np.empty(N, dtype=np.int64)", "+inpl = lambda: list(map(int, input().split()))", "+N, M = inpl()", "+A = []", "- A[i], B[i] = list(map(np.int64, input().split()))", "-order = A.argso...
false
0.311191
0.042119
7.388442
[ "s300853618", "s202469212" ]
u747602774
p03745
python
s163772501
s868943339
94
86
14,440
14,252
Accepted
Accepted
8.51
N = int(eval(input())) A = list(map(int,input().split())) ans = 1 #state0は未定、1は広義単調増加、2は広義単調減少 state = 0 m = A[0] i = 1 while i <= N-1: if m < A[i]: if state == 0: state = 1 m = A[i] elif state == 1: m = A[i] else: ans += 1...
N = int(eval(input())) A = list(map(int,input().split())) ans = 1 #state0は未定、1は広義単調増加、2は広義単調減少 state = 0 m = A[0] i = 1 while i <= N-1: if m < A[i]: if state == 0: state = 1 elif state == 2: ans += 1 state = 0 elif m > A[i]: if sta...
33
27
603
457
N = int(eval(input())) A = list(map(int, input().split())) ans = 1 # state0は未定、1は広義単調増加、2は広義単調減少 state = 0 m = A[0] i = 1 while i <= N - 1: if m < A[i]: if state == 0: state = 1 m = A[i] elif state == 1: m = A[i] else: ans += 1 stat...
N = int(eval(input())) A = list(map(int, input().split())) ans = 1 # state0は未定、1は広義単調増加、2は広義単調減少 state = 0 m = A[0] i = 1 while i <= N - 1: if m < A[i]: if state == 0: state = 1 elif state == 2: ans += 1 state = 0 elif m > A[i]: if state == 0: ...
false
18.181818
[ "- m = A[i]", "- elif state == 1:", "- m = A[i]", "- else:", "+ elif state == 2:", "- m = A[i]", "- m = A[i]", "- m = A[i]", "- else:", "- m = A[i]", "+ m = A[i]" ]
false
0.035161
0.121255
0.289976
[ "s163772501", "s868943339" ]