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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u073852194 | p03599 | python | s199892115 | s168482694 | 631 | 47 | 43,116 | 3,064 | Accepted | Accepted | 92.55 | a,b,c,d,e,f = list(map(int,input().split()))
total = 0
sugar = 0
max_concentration = 0
for i in range(f//(100*a)+1):
for j in range(f//(100*b)+1):
for k in range(f//c+1):
for l in range(f//d+1):
if 0 < 100*(a*i+b*j)+(c*k+d*l)<=f and c*k+d*l<=e*(a*i+b*j):
... | A, B, C, D, E, F = list(map(int, input().split()))
water = [0 for _ in range(30 + 1)]
sugar = [0 for _ in range(3000 + 1)]
water[0] = 1
sugar[0] = 1
for i in range(30):
if water[i]:
if i + A <= 30:
water[i + A] = 1
if i + B <= 30:
water[i + B] = 1
for j in ... | 16 | 38 | 583 | 874 | a, b, c, d, e, f = list(map(int, input().split()))
total = 0
sugar = 0
max_concentration = 0
for i in range(f // (100 * a) + 1):
for j in range(f // (100 * b) + 1):
for k in range(f // c + 1):
for l in range(f // d + 1):
if 0 < 100 * (a * i + b * j) + (
c * k ... | A, B, C, D, E, F = list(map(int, input().split()))
water = [0 for _ in range(30 + 1)]
sugar = [0 for _ in range(3000 + 1)]
water[0] = 1
sugar[0] = 1
for i in range(30):
if water[i]:
if i + A <= 30:
water[i + A] = 1
if i + B <= 30:
water[i + B] = 1
for j in range(3000):
if... | false | 57.894737 | [
"-a, b, c, d, e, f = list(map(int, input().split()))",
"-total = 0",
"-sugar = 0",
"-max_concentration = 0",
"-for i in range(f // (100 * a) + 1):",
"- for j in range(f // (100 * b) + 1):",
"- for k in range(f // c + 1):",
"- for l in range(f // d + 1):",
"- if 0 ... | false | 0.006409 | 0.047189 | 0.135808 | [
"s199892115",
"s168482694"
] |
u295361373 | p02627 | python | s893333809 | s344928218 | 180 | 92 | 67,308 | 69,768 | Accepted | Accepted | 48.89 | from collections import deque,defaultdict as dd
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(eval(input()))
def si():return eval(input())
def mi():return ... | '''
Auther: ghoshashis545 Ashis Ghosh
College: jalpaiguri Govt Enggineering College
'''
from os import path
import sys
from functools import cmp_to_key as ctk
from collections import deque,defaultdict as dd
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itert... | 47 | 59 | 916 | 1,109 | from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd
def ii():
return int(eval(input()))
def si():
return eval(input())
... | """
Auther: ghoshashis545 Ashis Ghosh
College: jalpaiguri Govt Enggineering College
"""
from os import path
import sys
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools i... | false | 20.338983 | [
"+\"\"\"",
"+ Auther: ghoshashis545 Ashis Ghosh",
"+ College: jalpaiguri Govt Enggineering College",
"+\"\"\"",
"+from os import path",
"+import sys",
"+from functools import cmp_to_key as ctk",
"-abd = {",
"- \"a\": 0,",
"- \"b\": 1,",
"- \"c\": 2,",
"- \"d\": 3,",
"- \... | false | 0.05544 | 0.034213 | 1.620448 | [
"s893333809",
"s344928218"
] |
u411203878 | p02684 | python | s828693496 | s300440097 | 129 | 116 | 96,628 | 99,500 | Accepted | Accepted | 10.08 | n,k = list(map(int,input().split()))
t = list(map(int,input().split()))
memo = [0]*(n+1)
for i in range(n):
memo[i+1] = t[i]
move = 1
count = 0
check = [0]*(n+1)
while check[move] == 0 and count < k-1:
check[move] += 1
move=memo[move]
count += 1
if k == count:
print((mem... | N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
check = [0]*N
jump = 0
count = 0
while check[A[jump]-1] == 0 and count < K:
n_jump = A[jump]-1
check[n_jump] = check[jump]+1
count += 1
jump = n_jump
if count == K:
key = max(check)
ans = check.index(... | 32 | 37 | 558 | 740 | n, k = list(map(int, input().split()))
t = list(map(int, input().split()))
memo = [0] * (n + 1)
for i in range(n):
memo[i + 1] = t[i]
move = 1
count = 0
check = [0] * (n + 1)
while check[move] == 0 and count < k - 1:
check[move] += 1
move = memo[move]
count += 1
if k == count:
print((memo[move]))
el... | N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
check = [0] * N
jump = 0
count = 0
while check[A[jump] - 1] == 0 and count < K:
n_jump = A[jump] - 1
check[n_jump] = check[jump] + 1
count += 1
jump = n_jump
if count == K:
key = max(check)
ans = check.index(key) + 1
else... | false | 13.513514 | [
"-n, k = list(map(int, input().split()))",
"-t = list(map(int, input().split()))",
"-memo = [0] * (n + 1)",
"-for i in range(n):",
"- memo[i + 1] = t[i]",
"-move = 1",
"+N, K = list(map(int, input().split()))",
"+A = list(map(int, input().split()))",
"+check = [0] * N",
"+jump = 0",
"-check =... | false | 0.041876 | 0.04222 | 0.991855 | [
"s828693496",
"s300440097"
] |
u539692012 | p02627 | python | s082561917 | s111666297 | 32 | 29 | 9,072 | 8,916 | Accepted | Accepted | 9.38 | print(('a' if input().islower() else 'A'))
| print(('Aa'[input().islower()])) | 1 | 1 | 41 | 30 | print(("a" if input().islower() else "A"))
| print(("Aa"[input().islower()]))
| false | 0 | [
"-print((\"a\" if input().islower() else \"A\"))",
"+print((\"Aa\"[input().islower()]))"
] | false | 0.090862 | 0.038092 | 2.385312 | [
"s082561917",
"s111666297"
] |
u102461423 | p02702 | python | s740022149 | s285042631 | 858 | 593 | 108,872 | 29,016 | Accepted | Accepted | 30.89 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
from numba import njit
@njit('(i4[:],)', cache=True)
def solve(S):
dp = np.zeros(2019, np.int64)
pow10 = 1
answer = 0
for x in S[::-1]:
dp[0] += 1
... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
def solve(S):
dp = np.zeros(2019, np.int64)
pow10 = 1
answer = 0
for x in S[::-1]:
dp[0] += 1
x = x * pow10 % 2019
newdp = np.zer... | 27 | 39 | 641 | 807 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
from numba import njit
@njit("(i4[:],)", cache=True)
def solve(S):
dp = np.zeros(2019, np.int64)
pow10 = 1
answer = 0
for x in S[::-1]:
dp[0] += 1
x =... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
def solve(S):
dp = np.zeros(2019, np.int64)
pow10 = 1
answer = 0
for x in S[::-1]:
dp[0] += 1
x = x * pow10 % 2019
newdp = np.zeros_like(dp)
... | false | 30.769231 | [
"-from numba import njit",
"-@njit(\"(i4[:],)\", cache=True)",
"+def cc_export():",
"+ from numba.pycc import CC",
"+",
"+ cc = CC(\"my_module\")",
"+ cc.export(\"solve\", \"(i4[:],)\")(solve)",
"+ cc.compile()",
"+",
"+",
"+try:",
"+ from my_module import solve",
"+except:",
... | false | 0.216998 | 0.223169 | 0.972351 | [
"s740022149",
"s285042631"
] |
u906428167 | p03181 | python | s984095079 | s589635607 | 1,076 | 761 | 146,388 | 112,492 | Accepted | Accepted | 29.28 | import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
class Tree:
def __init__(self, crdinal, adjgrph, root):
self.n = crdinal
self.g = adjgrph
self.root = root
self.parent = [-1]*self.n
self.depth = [-1]*self.n
self.subsize = [1]*self.n
... | import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
class Tree:
def __init__(self, crdinal, adjgrph, root):
self.n = crdinal
self.g = adjgrph
self.root = root
self.parent = [-1]*self.n
self.depth = [-1]*self.n
self.subsize = [1]*self.n
... | 92 | 94 | 2,757 | 3,082 | import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
class Tree:
def __init__(self, crdinal, adjgrph, root):
self.n = crdinal
self.g = adjgrph
self.root = root
self.parent = [-1] * self.n
self.depth = [-1] * self.n
self.subsize = [1] * self.n
... | import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
class Tree:
def __init__(self, crdinal, adjgrph, root):
self.n = crdinal
self.g = adjgrph
self.root = root
self.parent = [-1] * self.n
self.depth = [-1] * self.n
self.subsize = [1] * self.n
... | false | 2.12766 | [
"- # Edit the result you want using self.depth, self.subsize, etc..",
"+ # Edit the item you want by using self.depth, self.subsize, etc..",
"+ # Modify below if you want to use rerooting",
"+ ans = [0] * n",
"+ ans[self.root] = self.result[self.root]",
"- ans = [... | false | 0.201201 | 0.037196 | 5.409225 | [
"s984095079",
"s589635607"
] |
u384679440 | p03325 | python | s792955249 | s083342341 | 165 | 142 | 4,140 | 4,148 | Accepted | Accepted | 13.94 | N = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
while True:
odd = 0
for i in range(N):
if a[i] % 2 != 0:
odd += 1
else:
a[i] /= 2
ans += 1
if odd == len(a):
break
print(ans) | N = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
while True:
odd = 0
for i in range(len(a)):
if a[i] % 2 != 0:
odd += 1
else:
a[i] /= 2
ans += 1
if odd == len(a):
break
print(ans) | 14 | 14 | 217 | 224 | N = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
while True:
odd = 0
for i in range(N):
if a[i] % 2 != 0:
odd += 1
else:
a[i] /= 2
ans += 1
if odd == len(a):
break
print(ans)
| N = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
while True:
odd = 0
for i in range(len(a)):
if a[i] % 2 != 0:
odd += 1
else:
a[i] /= 2
ans += 1
if odd == len(a):
break
print(ans)
| false | 0 | [
"- for i in range(N):",
"+ for i in range(len(a)):"
] | false | 0.043845 | 0.037447 | 1.170833 | [
"s792955249",
"s083342341"
] |
u319957725 | p02676 | python | s692991008 | s265992924 | 23 | 21 | 9,124 | 9,092 | Accepted | Accepted | 8.7 | '''
問題文
S: 文字列,英小文字
条件1(長さK以下)→Sをそのまま出力
条件2(長さK以上)→先頭K文字+'...'を出力
アルゴリズム
1. Sの文字数を取得(len(S))
2. Sの文字数とKを比較
2-a. if(len(S)<=K)Sを出力
2-b. if(len(S)>K)先頭K文字+'...'を出力,for文を使って先頭K文字の配列を作り直して'...'を結合し出力.
'''
K = int(eval(input()))
S = eval(input())
if(len(S)<=K):
print(S)
else:
S_K = ''
fo... | K = int(input())
S = input()
for i, s in enumerate(S):
if(i == K):
print('...')
break
print(s, end='')
print('')
| 26 | 9 | 374 | 146 | """
問題文
S: 文字列,英小文字
条件1(長さK以下)→Sをそのまま出力
条件2(長さK以上)→先頭K文字+'...'を出力
アルゴリズム
1. Sの文字数を取得(len(S))
2. Sの文字数とKを比較
2-a. if(len(S)<=K)Sを出力
2-b. if(len(S)>K)先頭K文字+'...'を出力,for文を使って先頭K文字の配列を作り直して'...'を結合し出力.
"""
K = int(eval(input()))
S = eval(input())
if len(S) <= K:
print(S)
else:
S_K = ""
for i in range(K):
... | K = int(input())
S = input()
for i, s in enumerate(S):
if i == K:
print("...")
break
print(s, end="")
print("")
| false | 65.384615 | [
"-\"\"\"",
"-問題文",
"-S: 文字列,英小文字",
"-条件1(長さK以下)→Sをそのまま出力",
"-条件2(長さK以上)→先頭K文字+'...'を出力",
"-アルゴリズム",
"-1. Sの文字数を取得(len(S))",
"-2. Sの文字数とKを比較",
"-2-a. if(len(S)<=K)Sを出力",
"-2-b. if(len(S)>K)先頭K文字+'...'を出力,for文を使って先頭K文字の配列を作り直して'...'を結合し出力.",
"-\"\"\"",
"-K = int(eval(input()))",
"-S = eval(inp... | false | 0.037092 | 0.034993 | 1.059979 | [
"s692991008",
"s265992924"
] |
u037430802 | p02803 | python | s399271650 | s421627136 | 305 | 267 | 48,220 | 45,916 | Accepted | Accepted | 12.46 | from collections import deque
H,W = list(map(int, input().split()))
S = [eval(input()) for _ in range(H)]
ans = 0
dyx = [(1,0), (0,1),(-1,0), (0,-1)]
for i in range(H):
for j in range(W):
if S[i][j] == "#": continue
dist = [[0 for _ in range(W)] for _ in range(H)]
visited =... | H,W = list(map(int,input().split()))
S = [eval(input()) for i in range(H)]
dxy = [(0,1),(1,0),(0,-1),(-1,0)]
from collections import deque
ans = 0
for y in range(H):
for x in range(W):
if S[y][x] == '#': continue
dist = [[0]*W for i in range(H)]
visited = [[0]*W for i in range(H)]... | 33 | 31 | 898 | 927 | from collections import deque
H, W = list(map(int, input().split()))
S = [eval(input()) for _ in range(H)]
ans = 0
dyx = [(1, 0), (0, 1), (-1, 0), (0, -1)]
for i in range(H):
for j in range(W):
if S[i][j] == "#":
continue
dist = [[0 for _ in range(W)] for _ in range(H)]
visited ... | H, W = list(map(int, input().split()))
S = [eval(input()) for i in range(H)]
dxy = [(0, 1), (1, 0), (0, -1), (-1, 0)]
from collections import deque
ans = 0
for y in range(H):
for x in range(W):
if S[y][x] == "#":
continue
dist = [[0] * W for i in range(H)]
visited = [[0] * W for... | false | 6.060606 | [
"+H, W = list(map(int, input().split()))",
"+S = [eval(input()) for i in range(H)]",
"+dxy = [(0, 1), (1, 0), (0, -1), (-1, 0)]",
"-H, W = list(map(int, input().split()))",
"-S = [eval(input()) for _ in range(H)]",
"-dyx = [(1, 0), (0, 1), (-1, 0), (0, -1)]",
"-for i in range(H):",
"- for j in rang... | false | 0.089089 | 0.037121 | 2.399954 | [
"s399271650",
"s421627136"
] |
u531603069 | p02787 | python | s934388898 | s784635659 | 1,810 | 1,429 | 3,832 | 44,508 | Accepted | Accepted | 21.05 | import sys
h, n = list(map(int, input().split()))
# A = [0] * n
# B = [0] * n
# for i in range(n):
# A[i], B[i] = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(n)]
min_hp = h
max_hp = h + max(a for a, b in (AB))
dp = [sys.maxsize] * (max_hp + 1)
dp[0] = 0
for i in ran... | import sys
h, n = list(map(int, input().split()))
A = [0] * n
B = [0] * n
for i in range(n):
A[i], B[i] = list(map(int, input().split()))
min_hp = h
max_hp = h + max(A)
dp = [sys.maxsize] * (max_hp + 1)
dp[0] = 0
for i in range(1, max_hp + 1):
dp[i] = min(dp[i - A[j]] + B[j] for j in range(n))
... | 17 | 15 | 458 | 327 | import sys
h, n = list(map(int, input().split()))
# A = [0] * n
# B = [0] * n
# for i in range(n):
# A[i], B[i] = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(n)]
min_hp = h
max_hp = h + max(a for a, b in (AB))
dp = [sys.maxsize] * (max_hp + 1)
dp[0] = 0
for i in range(1, max_hp +... | import sys
h, n = list(map(int, input().split()))
A = [0] * n
B = [0] * n
for i in range(n):
A[i], B[i] = list(map(int, input().split()))
min_hp = h
max_hp = h + max(A)
dp = [sys.maxsize] * (max_hp + 1)
dp[0] = 0
for i in range(1, max_hp + 1):
dp[i] = min(dp[i - A[j]] + B[j] for j in range(n))
print((min(dp[h:... | false | 11.764706 | [
"-# A = [0] * n",
"-# B = [0] * n",
"-# for i in range(n):",
"-# A[i], B[i] = map(int, input().split())",
"-AB = [list(map(int, input().split())) for _ in range(n)]",
"+A = [0] * n",
"+B = [0] * n",
"+for i in range(n):",
"+ A[i], B[i] = list(map(int, input().split()))",
"-max_hp = h + max(... | false | 0.081502 | 0.104137 | 0.782644 | [
"s934388898",
"s784635659"
] |
u816631826 | p02724 | python | s655753884 | s159090289 | 571 | 17 | 2,940 | 2,940 | Accepted | Accepted | 97.02 | n = int(eval(input()))
happy = 0
if n%500 == 0:
print((2*n))
else:
while n > 0:
if n == 0:
break
n-=500
if n<0:
n+=500
n-=5
if n<0:
n+=5
break
else:
happy+=5
... | x = int(eval(input()))
total = 0
a = int(x / 500)
b = x % 500
c = int(b / 5)
total = a * 1000 + c *5
print(total) | 20 | 7 | 364 | 113 | n = int(eval(input()))
happy = 0
if n % 500 == 0:
print((2 * n))
else:
while n > 0:
if n == 0:
break
n -= 500
if n < 0:
n += 500
n -= 5
if n < 0:
n += 5
break
else:
happy += 5
... | x = int(eval(input()))
total = 0
a = int(x / 500)
b = x % 500
c = int(b / 5)
total = a * 1000 + c * 5
print(total)
| false | 65 | [
"-n = int(eval(input()))",
"-happy = 0",
"-if n % 500 == 0:",
"- print((2 * n))",
"-else:",
"- while n > 0:",
"- if n == 0:",
"- break",
"- n -= 500",
"- if n < 0:",
"- n += 500",
"- n -= 5",
"- if n < 0:",
"- ... | false | 0.103178 | 0.040789 | 2.529549 | [
"s655753884",
"s159090289"
] |
u033606236 | p03290 | python | s367076067 | s738073203 | 168 | 29 | 3,064 | 3,064 | Accepted | Accepted | 82.74 | d,g = list(map(int,input().split()))
a = [list(map(int,input().split())) for _ in range(d)]
s = set(range(d))
ans = float("Inf")
x = []
for i in zip(*a):
x.append(list(i))
c = []
for i in range(2**d):
b = []
for j in range(d):
if i>>j & 1:
b.append(j)
c.append(b)
for i ... | d,g = list(map(int,input().split()))
ary = [list(map(int,input().split())) for _ in range(d)]
s = set(i for i in range(d))
ans = float("Inf")
for i in range(2**d):
a = []
total,count = 0,0
for j in range(d):
if i >> j & 1:
a.append(j)
for x in a:
total += 100*(x+1)... | 30 | 26 | 720 | 765 | d, g = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(d)]
s = set(range(d))
ans = float("Inf")
x = []
for i in zip(*a):
x.append(list(i))
c = []
for i in range(2**d):
b = []
for j in range(d):
if i >> j & 1:
b.append(j)
c.append(b)
for i in c:
... | d, g = list(map(int, input().split()))
ary = [list(map(int, input().split())) for _ in range(d)]
s = set(i for i in range(d))
ans = float("Inf")
for i in range(2**d):
a = []
total, count = 0, 0
for j in range(d):
if i >> j & 1:
a.append(j)
for x in a:
total += 100 * (x + 1) *... | false | 13.333333 | [
"-a = [list(map(int, input().split())) for _ in range(d)]",
"-s = set(range(d))",
"+ary = [list(map(int, input().split())) for _ in range(d)]",
"+s = set(i for i in range(d))",
"-x = []",
"-for i in zip(*a):",
"- x.append(list(i))",
"-c = []",
"- b = []",
"+ a = []",
"+ total, count ... | false | 0.066377 | 0.038068 | 1.743664 | [
"s367076067",
"s738073203"
] |
u800704240 | p03268 | python | s445761071 | s119692471 | 93 | 39 | 3,060 | 5,332 | Accepted | Accepted | 58.06 | n,k = list(map(int,input().split()))
ans1 = 0
ans2 = 0
ans = 0
for x in range(1,n+1):
if x % k ==0:
ans1 +=1
if k % 2 == 0:
for y in range(1,n+1):
if y % k == k/2:
ans2 +=1
print((ans1**3+ans2**3)) | from decimal import Decimal, ROUND_HALF_UP
n,k = list(map(int,input().split()))
ans = 0
if k % 2 ==0:
p = Decimal(n/k).quantize(Decimal('0'),rounding=ROUND_HALF_UP)
ans = p**3 +(n//k)**3
else:
ans = (n // k)**3
print(ans) | 12 | 9 | 236 | 235 | n, k = list(map(int, input().split()))
ans1 = 0
ans2 = 0
ans = 0
for x in range(1, n + 1):
if x % k == 0:
ans1 += 1
if k % 2 == 0:
for y in range(1, n + 1):
if y % k == k / 2:
ans2 += 1
print((ans1**3 + ans2**3))
| from decimal import Decimal, ROUND_HALF_UP
n, k = list(map(int, input().split()))
ans = 0
if k % 2 == 0:
p = Decimal(n / k).quantize(Decimal("0"), rounding=ROUND_HALF_UP)
ans = p**3 + (n // k) ** 3
else:
ans = (n // k) ** 3
print(ans)
| false | 25 | [
"+from decimal import Decimal, ROUND_HALF_UP",
"+",
"-ans1 = 0",
"-ans2 = 0",
"-for x in range(1, n + 1):",
"- if x % k == 0:",
"- ans1 += 1",
"- for y in range(1, n + 1):",
"- if y % k == k / 2:",
"- ans2 += 1",
"-print((ans1**3 + ans2**3))",
"+ p = Decimal(n... | false | 0.03466 | 0.035863 | 0.966452 | [
"s445761071",
"s119692471"
] |
u034128150 | p02913 | python | s348135835 | s657337613 | 1,109 | 100 | 97,884 | 71,200 | Accepted | Accepted | 90.98 | class RollingHash:
def __init__(self, string, root, mod):
self.root = root
self.mod = mod
self.hs = [0] * (len(string) + 1)
self.pw = [1] * (len(string) + 1)
for i in range(len(string)):
self.hs[i + 1] = self.hs[i] * self.root + ord(string[i]) % self.mod
... | class RollingHash:
def __init__(self, string, root, mod):
self.root = root
self.mod = mod
self.hs = [0] * (len(string) + 1)
self.pw = [1] * (len(string) + 1)
for i in range(len(string)):
self.hs[i + 1] = (self.hs[i] * self.root + ord(string[i])) % self.mo... | 83 | 83 | 2,364 | 2,366 | class RollingHash:
def __init__(self, string, root, mod):
self.root = root
self.mod = mod
self.hs = [0] * (len(string) + 1)
self.pw = [1] * (len(string) + 1)
for i in range(len(string)):
self.hs[i + 1] = self.hs[i] * self.root + ord(string[i]) % self.mod
... | class RollingHash:
def __init__(self, string, root, mod):
self.root = root
self.mod = mod
self.hs = [0] * (len(string) + 1)
self.pw = [1] * (len(string) + 1)
for i in range(len(string)):
self.hs[i + 1] = (self.hs[i] * self.root + ord(string[i])) % self.mod
... | false | 0 | [
"- self.hs[i + 1] = self.hs[i] * self.root + ord(string[i]) % self.mod",
"+ self.hs[i + 1] = (self.hs[i] * self.root + ord(string[i])) % self.mod"
] | false | 0.12654 | 0.045231 | 2.797625 | [
"s348135835",
"s657337613"
] |
u623687794 | p02712 | python | s733671189 | s464692402 | 158 | 70 | 9,160 | 64,988 | Accepted | Accepted | 55.7 | n=int(eval(input()))
ans=0
for i in range(1,n+1):
if i%3 * i%5 != 0:ans+=i
print(ans) | n = int(eval(input()))
ans = 0
for i in range(n+1):
if i%3 != 0 and i%5 != 0:
ans = ans + i
print(ans) | 5 | 6 | 85 | 107 | n = int(eval(input()))
ans = 0
for i in range(1, n + 1):
if i % 3 * i % 5 != 0:
ans += i
print(ans)
| n = int(eval(input()))
ans = 0
for i in range(n + 1):
if i % 3 != 0 and i % 5 != 0:
ans = ans + i
print(ans)
| false | 16.666667 | [
"-for i in range(1, n + 1):",
"- if i % 3 * i % 5 != 0:",
"- ans += i",
"+for i in range(n + 1):",
"+ if i % 3 != 0 and i % 5 != 0:",
"+ ans = ans + i"
] | false | 0.166123 | 0.169016 | 0.982887 | [
"s733671189",
"s464692402"
] |
u533232830 | p03557 | python | s340517091 | s967621628 | 279 | 258 | 30,964 | 29,348 | Accepted | Accepted | 7.53 | from bisect import bisect_left
n = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
# print(A)
# print(B)
# print(C)
A_B = []
for i in range(n):
A_B.append(bisect_left(A, B[i]))
ruiseki... | from bisect import bisect_left, bisect_right
n = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
C.sort()
ans = 0
for i in range(n):
ans += bisect_left(A, B[i]) * (n - bisect_right(C, B[i]))
print(ans)
| 35 | 16 | 557 | 308 | from bisect import bisect_left
n = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
# print(A)
# print(B)
# print(C)
A_B = []
for i in range(n):
A_B.append(bisect_left(A, B[i]))
ruisekiwa = [A_B[0]]
for i in ra... | from bisect import bisect_left, bisect_right
n = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
C.sort()
ans = 0
for i in range(n):
ans += bisect_left(A, B[i]) * (n - bisect_right(C, B[i]))
print(ans)
| false | 54.285714 | [
"-from bisect import bisect_left",
"+from bisect import bisect_left, bisect_right",
"-B.sort()",
"-# print(A)",
"-# print(B)",
"-# print(C)",
"-A_B = []",
"-for i in range(n):",
"- A_B.append(bisect_left(A, B[i]))",
"-ruisekiwa = [A_B[0]]",
"-for i in range(1, n):",
"- ruisekiwa.append(r... | false | 0.049924 | 0.093937 | 0.531462 | [
"s340517091",
"s967621628"
] |
u546338822 | p02803 | python | s795015608 | s983459984 | 1,618 | 543 | 12,500 | 12,424 | Accepted | Accepted | 66.44 | def main():
import numpy as np
def bfs(S,s,h,w):
dist = np.ones((h,w))*-1
dist[s[0],s[1]]=0
que = [s]
while len(que)>0:
v = que.pop(0)
if v[0]+1<h:
if S[v[0]+1][v[1]]=='.' and dist[v[0]+1][v[1]] == -1:
dist[v[0... | def main():
import numpy as np
h,w = list(map(int,input().split()))
maize = []
for i in range(h):
s = eval(input())
maize.append(s)
ans = 0
for i in range(h):
for j in range(w):
que = [[i,j]]
if maize[i][j] == '.':
dis =... | 47 | 48 | 1,473 | 1,825 | def main():
import numpy as np
def bfs(S, s, h, w):
dist = np.ones((h, w)) * -1
dist[s[0], s[1]] = 0
que = [s]
while len(que) > 0:
v = que.pop(0)
if v[0] + 1 < h:
if S[v[0] + 1][v[1]] == "." and dist[v[0] + 1][v[1]] == -1:
... | def main():
import numpy as np
h, w = list(map(int, input().split()))
maize = []
for i in range(h):
s = eval(input())
maize.append(s)
ans = 0
for i in range(h):
for j in range(w):
que = [[i, j]]
if maize[i][j] == ".":
dis = [[-1 fo... | false | 2.083333 | [
"- def bfs(S, s, h, w):",
"- dist = np.ones((h, w)) * -1",
"- dist[s[0], s[1]] = 0",
"- que = [s]",
"- while len(que) > 0:",
"- v = que.pop(0)",
"- if v[0] + 1 < h:",
"- if S[v[0] + 1][v[1]] == \".\" and dist[v[0] + 1][v[1]] == -1:",
... | false | 0.212161 | 0.192321 | 1.103159 | [
"s795015608",
"s983459984"
] |
u706929073 | p03111 | python | s116427460 | s130657193 | 78 | 72 | 3,064 | 3,064 | Accepted | Accepted | 7.69 | n, A, B, C = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(n)]
inf = 10 ** 18
def dfs(i, a, b, c):
if i == n:
if a < 1 or b < 1 or c < 1:
return inf
return abs(A - a) + abs(B - b) + abs(C - c)
res = dfs(i + 1, a, b, c)
res = min([res, dfs(i +... | n, A, B, C = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(n)]
def dfs(i, a, b, c):
if n == i:
if a < 1 or b < 1 or c < 1:
return 10 ** 18
return abs(A - a) + abs(B - b) + abs(C - c)
res = dfs(i + 1, a, b, c)
res = min([res, dfs(i + 1, a + l... | 18 | 18 | 543 | 534 | n, A, B, C = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(n)]
inf = 10**18
def dfs(i, a, b, c):
if i == n:
if a < 1 or b < 1 or c < 1:
return inf
return abs(A - a) + abs(B - b) + abs(C - c)
res = dfs(i + 1, a, b, c)
res = min([res, dfs(i + 1, a + l[i],... | n, A, B, C = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(n)]
def dfs(i, a, b, c):
if n == i:
if a < 1 or b < 1 or c < 1:
return 10**18
return abs(A - a) + abs(B - b) + abs(C - c)
res = dfs(i + 1, a, b, c)
res = min([res, dfs(i + 1, a + l[i], b, c) + (... | false | 0 | [
"-inf = 10**18",
"- if i == n:",
"+ if n == i:",
"- return inf",
"+ return 10**18"
] | false | 0.070895 | 0.070791 | 1.001476 | [
"s116427460",
"s130657193"
] |
u924691798 | p02793 | python | s229589102 | s223205999 | 1,898 | 861 | 6,112 | 4,852 | Accepted | Accepted | 54.64 | from fractions import gcd
MOD = 10**9+7
N = int(eval(input()))
A = list(map(int, input().split()))
now = A[0]
ans = 0
for i in range(1,N):
now = now//gcd(now, A[i])*A[i]
for i in range(N):
ans += now//A[i]
print((ans%MOD)) | from collections import defaultdict
def prime_factors(n):
d = defaultdict(int)
while n%2 == 0:
d[2] += 1
n //= 2
i = 3
while i*i <= n:
while n%i == 0:
d[i] += 1
n //= i
i += 2
if n > 2:
d[n] += 1
return d
MOD = 10... | 11 | 34 | 232 | 667 | from fractions import gcd
MOD = 10**9 + 7
N = int(eval(input()))
A = list(map(int, input().split()))
now = A[0]
ans = 0
for i in range(1, N):
now = now // gcd(now, A[i]) * A[i]
for i in range(N):
ans += now // A[i]
print((ans % MOD))
| from collections import defaultdict
def prime_factors(n):
d = defaultdict(int)
while n % 2 == 0:
d[2] += 1
n //= 2
i = 3
while i * i <= n:
while n % i == 0:
d[i] += 1
n //= i
i += 2
if n > 2:
d[n] += 1
return d
MOD = 10**9 + 7
N... | false | 67.647059 | [
"-from fractions import gcd",
"+from collections import defaultdict",
"+",
"+",
"+def prime_factors(n):",
"+ d = defaultdict(int)",
"+ while n % 2 == 0:",
"+ d[2] += 1",
"+ n //= 2",
"+ i = 3",
"+ while i * i <= n:",
"+ while n % i == 0:",
"+ d[i] ... | false | 0.109145 | 0.159082 | 0.686096 | [
"s229589102",
"s223205999"
] |
u576432509 | p03495 | python | s668123140 | s787240477 | 360 | 128 | 31,396 | 25,376 | Accepted | Accepted | 64.44 | n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
a.sort()
s=[]
ai=a[0]
acnt=-1
for i in range(n):
if a[i]>ai:
s.append([acnt+1,ai])
acnt=0
ai=a[i]
else:
acnt=acnt+1
s.append([acnt+1,ai])
if len(s)<=k:
print((0))
else:
s.... | n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
c=[0]*(n+1)
for i in range(n):
c[a[i]]+=1
c.sort(reverse=True)
csum=0
for i in range(k):
csum+=c[i]
print((n-csum)) | 28 | 11 | 430 | 194 | n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
s = []
ai = a[0]
acnt = -1
for i in range(n):
if a[i] > ai:
s.append([acnt + 1, ai])
acnt = 0
ai = a[i]
else:
acnt = acnt + 1
s.append([acnt + 1, ai])
if len(s) <= k:
print((0))
else:
s.so... | n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
c = [0] * (n + 1)
for i in range(n):
c[a[i]] += 1
c.sort(reverse=True)
csum = 0
for i in range(k):
csum += c[i]
print((n - csum))
| false | 60.714286 | [
"-a.sort()",
"-s = []",
"-ai = a[0]",
"-acnt = -1",
"+c = [0] * (n + 1)",
"- if a[i] > ai:",
"- s.append([acnt + 1, ai])",
"- acnt = 0",
"- ai = a[i]",
"- else:",
"- acnt = acnt + 1",
"-s.append([acnt + 1, ai])",
"-if len(s) <= k:",
"- print((0))",
"-... | false | 0.039453 | 0.038785 | 1.017246 | [
"s668123140",
"s787240477"
] |
u515740713 | p02613 | python | s688151368 | s138113265 | 70 | 48 | 9,256 | 16,564 | Accepted | Accepted | 31.43 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
cnt = [0]*4
for i in range(N):
S = readline().decode().rstrip()
if S == 'AC':
cnt[0] +=1
if S == 'WA':
cnt[1] +=1
if S == 'TLE':
c... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
S = read().decode().rstrip().split()
for s in ['AC','WA','TLE','RE']:
print(("{0} x {1}".format(s,S.count(s)))) | 20 | 8 | 481 | 257 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
cnt = [0] * 4
for i in range(N):
S = readline().decode().rstrip()
if S == "AC":
cnt[0] += 1
if S == "WA":
cnt[1] += 1
if S == "TLE":
cnt[2] += ... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
S = read().decode().rstrip().split()
for s in ["AC", "WA", "TLE", "RE"]:
print(("{0} x {1}".format(s, S.count(s))))
| false | 60 | [
"-cnt = [0] * 4",
"-for i in range(N):",
"- S = readline().decode().rstrip()",
"- if S == \"AC\":",
"- cnt[0] += 1",
"- if S == \"WA\":",
"- cnt[1] += 1",
"- if S == \"TLE\":",
"- cnt[2] += 1",
"- if S == \"RE\":",
"- cnt[3] += 1",
"-print((\"AC x \" ... | false | 0.047123 | 0.047343 | 0.99534 | [
"s688151368",
"s138113265"
] |
u548303713 | p03835 | python | s088283550 | s059837918 | 1,970 | 240 | 3,060 | 40,940 | Accepted | Accepted | 87.82 | #ABC51-B
K,S=list(map(int,input().split()))
sum=0
count=0
for i in range(K+1):
sum+=i
a=sum
L=S-sum
#print(L)
LL=min(L,K)
for j in range(LL+1):
sum+=j
if S-sum>=0 and S-sum<=K :
count+=1
#print(str(i)+" "+str(j))
sum=a #jを足す前に戻す
... | k,s=list(map(int,input().split()))
ans=0
for i in range(k+1):
for j in range(k+1):
if 0<=s-(i+j)<=k:
ans+=1
print(ans) | 19 | 7 | 346 | 142 | # ABC51-B
K, S = list(map(int, input().split()))
sum = 0
count = 0
for i in range(K + 1):
sum += i
a = sum
L = S - sum
# print(L)
LL = min(L, K)
for j in range(LL + 1):
sum += j
if S - sum >= 0 and S - sum <= K:
count += 1
# print(str(i)+" "+str(j))
... | k, s = list(map(int, input().split()))
ans = 0
for i in range(k + 1):
for j in range(k + 1):
if 0 <= s - (i + j) <= k:
ans += 1
print(ans)
| false | 63.157895 | [
"-# ABC51-B",
"-K, S = list(map(int, input().split()))",
"-sum = 0",
"-count = 0",
"-for i in range(K + 1):",
"- sum += i",
"- a = sum",
"- L = S - sum",
"- # print(L)",
"- LL = min(L, K)",
"- for j in range(LL + 1):",
"- sum += j",
"- if S - sum >= 0 and S - ... | false | 0.036758 | 0.036957 | 0.994625 | [
"s088283550",
"s059837918"
] |
u780475861 | p02794 | python | s324254622 | s194848738 | 312 | 227 | 62,412 | 61,392 | Accepted | Accepted | 27.24 | # https://atcoder.jp/contests/abc152/submissions/9619555
import sys
readline = sys.stdin.readline
import numpy as np
N = int(readline())
AB = list(list(map(int, readline().split())) for _ in range(N - 1))
M = int(readline())
UV = list(list(map(int, readline().split())) for _ in range(M))
graph = [[] for... | # https://atcoder.jp/contests/abc152/submissions/9619555
import sys
readline = sys.stdin.readline
import numpy as np
N = int(readline())
AB = list(list(map(int, readline().split())) for _ in range(N - 1))
M = int(readline())
UV = list(list(map(int, readline().split())) for _ in range(M))
graph = [[] for... | 64 | 64 | 1,678 | 1,701 | # https://atcoder.jp/contests/abc152/submissions/9619555
import sys
readline = sys.stdin.readline
import numpy as np
N = int(readline())
AB = list(list(map(int, readline().split())) for _ in range(N - 1))
M = int(readline())
UV = list(list(map(int, readline().split())) for _ in range(M))
graph = [[] for _ in range(N ... | # https://atcoder.jp/contests/abc152/submissions/9619555
import sys
readline = sys.stdin.readline
import numpy as np
N = int(readline())
AB = list(list(map(int, readline().split())) for _ in range(N - 1))
M = int(readline())
UV = list(list(map(int, readline().split())) for _ in range(M))
graph = [[] for _ in range(N ... | false | 0 | [
"-sgn = np.where(popcnt(np.arange(1 << M)) % 2, -1, 1)",
"+sgn = np.ones(1 << M, np.int64)",
"+ sgn[1 << i : 1 << (i + 1)] = -sgn[: 1 << i]",
"-answer = np.sum(x * sgn)",
"+answer = (x * sgn).sum()"
] | false | 0.293811 | 0.540176 | 0.543917 | [
"s324254622",
"s194848738"
] |
u814781830 | p02882 | python | s634747048 | s025084017 | 181 | 29 | 38,896 | 3,064 | Accepted | Accepted | 83.98 | import math
PI = math.pi
EPS = 0.0000000001
a, b, x = list(map(int, input().split()))
def f(a, b, theta):
# theta = pi/2-theta
if a * math.tan(theta) <= b:
return a * a * b - a * a * a * math.tan(theta) / 2
else:
return b * b / math.tan(theta) * a / 2
def solve():
ok =... | import math
a, b, x = list(map(int, input().split()))
x /= a
half = a * b // 2
# 引数の角度で入る水の量を計算する
def check(theta):
if x <= half:
theta = math.radians(theta)
return b ** 2 / 2 * math.tan(theta)
else:
theta = math.radians(90-theta)
return a * b - (0.5 * a ** 2 * math.ta... | 26 | 24 | 517 | 477 | import math
PI = math.pi
EPS = 0.0000000001
a, b, x = list(map(int, input().split()))
def f(a, b, theta):
# theta = pi/2-theta
if a * math.tan(theta) <= b:
return a * a * b - a * a * a * math.tan(theta) / 2
else:
return b * b / math.tan(theta) * a / 2
def solve():
ok = PI / 2
ng... | import math
a, b, x = list(map(int, input().split()))
x /= a
half = a * b // 2
# 引数の角度で入る水の量を計算する
def check(theta):
if x <= half:
theta = math.radians(theta)
return b**2 / 2 * math.tan(theta)
else:
theta = math.radians(90 - theta)
return a * b - (0.5 * a**2 * math.tan(theta))
... | false | 7.692308 | [
"-PI = math.pi",
"-EPS = 0.0000000001",
"+x /= a",
"+half = a * b // 2",
"+# 引数の角度で入る水の量を計算する",
"+def check(theta):",
"+ if x <= half:",
"+ theta = math.radians(theta)",
"+ return b**2 / 2 * math.tan(theta)",
"+ else:",
"+ theta = math.radians(90 - theta)",
"+ ... | false | 0.457113 | 0.047567 | 9.60987 | [
"s634747048",
"s025084017"
] |
u849334482 | p02659 | python | s704852155 | s535826693 | 28 | 21 | 10,076 | 9,096 | Accepted | Accepted | 25 | import math
from decimal import Decimal
A = input().split()
answer = Decimal(A[0]) * Decimal(A[1])
print((math.floor(answer))) | a, b = input().split()
a = int(a)
b = int(b.replace(".", ""))
ans = a * b // 100
print(ans) | 7 | 7 | 132 | 99 | import math
from decimal import Decimal
A = input().split()
answer = Decimal(A[0]) * Decimal(A[1])
print((math.floor(answer)))
| a, b = input().split()
a = int(a)
b = int(b.replace(".", ""))
ans = a * b // 100
print(ans)
| false | 0 | [
"-import math",
"-from decimal import Decimal",
"-",
"-A = input().split()",
"-answer = Decimal(A[0]) * Decimal(A[1])",
"-print((math.floor(answer)))",
"+a, b = input().split()",
"+a = int(a)",
"+b = int(b.replace(\".\", \"\"))",
"+ans = a * b // 100",
"+print(ans)"
] | false | 0.044996 | 0.06768 | 0.66483 | [
"s704852155",
"s535826693"
] |
u989345508 | p03127 | python | s071381928 | s691569152 | 184 | 158 | 14,224 | 14,252 | Accepted | Accepted | 14.13 | #priority_queueで管理
#普通にソートすればいいじゃん
n=int(eval(input()))
a=sorted([int(i) for i in input().split()])
#print(a)
while len(a)!=1:
b=a[0]
for i in range(1,n):
a[i]-=b*(a[i]//b)
a=sorted([i for i in a if i!=0])
n=len(a)
#print(a)
print((a[0]))
| n=int(eval(input()))
a=list(map(int,input().split()))
while len(a)>1:
l=len(a)
a.sort()
b=[a[0] if i==0 else a[i]%a[0] for i in range(l)]
a=[b[i] for i in range(l) if b[i]!=0]
print((a[0]))
| 14 | 8 | 273 | 205 | # priority_queueで管理
# 普通にソートすればいいじゃん
n = int(eval(input()))
a = sorted([int(i) for i in input().split()])
# print(a)
while len(a) != 1:
b = a[0]
for i in range(1, n):
a[i] -= b * (a[i] // b)
a = sorted([i for i in a if i != 0])
n = len(a)
# print(a)
print((a[0]))
| n = int(eval(input()))
a = list(map(int, input().split()))
while len(a) > 1:
l = len(a)
a.sort()
b = [a[0] if i == 0 else a[i] % a[0] for i in range(l)]
a = [b[i] for i in range(l) if b[i] != 0]
print((a[0]))
| false | 42.857143 | [
"-# priority_queueで管理",
"-# 普通にソートすればいいじゃん",
"-a = sorted([int(i) for i in input().split()])",
"-# print(a)",
"-while len(a) != 1:",
"- b = a[0]",
"- for i in range(1, n):",
"- a[i] -= b * (a[i] // b)",
"- a = sorted([i for i in a if i != 0])",
"- n = len(a)",
"- # print(a)... | false | 0.070708 | 0.038906 | 1.817381 | [
"s071381928",
"s691569152"
] |
u969850098 | p03212 | python | s081838821 | s383417742 | 480 | 91 | 7,272 | 3,060 | Accepted | Accepted | 81.04 | import sys
readline = sys.stdin.readline
from collections import deque
def main():
N = int(readline())
que = []
for val in ['357', '375', '537', '573', '735', '753']:
if int(val) <= N:
que.append(val)
res = set(que)
que = deque(que)
while que:
pre = que.... | import sys
readline = sys.stdin.readline
N = int(readline())
def dfs(num):
if int(num) > N:
return 0
if all(num.count(n) > 0 for n in '753'):
res = 1
else:
res = 0
for n in '753':
res += dfs(num + n)
return res
def main():
print((df... | 25 | 23 | 645 | 368 | import sys
readline = sys.stdin.readline
from collections import deque
def main():
N = int(readline())
que = []
for val in ["357", "375", "537", "573", "735", "753"]:
if int(val) <= N:
que.append(val)
res = set(que)
que = deque(que)
while que:
pre = que.popleft()
... | import sys
readline = sys.stdin.readline
N = int(readline())
def dfs(num):
if int(num) > N:
return 0
if all(num.count(n) > 0 for n in "753"):
res = 1
else:
res = 0
for n in "753":
res += dfs(num + n)
return res
def main():
print((dfs("0")))
if __name__ == "... | false | 8 | [
"-from collections import deque",
"+N = int(readline())",
"+",
"+",
"+def dfs(num):",
"+ if int(num) > N:",
"+ return 0",
"+ if all(num.count(n) > 0 for n in \"753\"):",
"+ res = 1",
"+ else:",
"+ res = 0",
"+ for n in \"753\":",
"+ res += dfs(num + n)... | false | 0.392549 | 0.118104 | 3.323749 | [
"s081838821",
"s383417742"
] |
u501451051 | p03013 | python | s615101812 | s576318285 | 617 | 155 | 463,476 | 14,464 | Accepted | Accepted | 74.88 | n, m = list(map(int, input().split()))
mod = 10**9 + 7
no = [False] * (n+1)
for _ in range(m):
a = int(eval(input()))
no[a] = True
dp = [0] * (n+1)
dp[0] = 1
for i in range(n):
if (no[i]):
dp[i] = 0
if i + 1 <= n:
dp[i+1] += dp[i]
if i + 2 <= n:
... | n , m = list(map(int, input().split()))
lis = [int(eval(input())) for _ in range(m)]
mod = 10**9+7
ans =[1] + [1] + [-1] * (n-1)
for i in lis:
ans[i] = 0
for i in range(2, n+1):
if ans[i] != 0:
ans[i] = (ans[i-1] + ans[i-2]) % mod
print((ans[n])) | 23 | 15 | 359 | 267 | n, m = list(map(int, input().split()))
mod = 10**9 + 7
no = [False] * (n + 1)
for _ in range(m):
a = int(eval(input()))
no[a] = True
dp = [0] * (n + 1)
dp[0] = 1
for i in range(n):
if no[i]:
dp[i] = 0
if i + 1 <= n:
dp[i + 1] += dp[i]
if i + 2 <= n:
dp[i + 2] += dp[i]
print((... | n, m = list(map(int, input().split()))
lis = [int(eval(input())) for _ in range(m)]
mod = 10**9 + 7
ans = [1] + [1] + [-1] * (n - 1)
for i in lis:
ans[i] = 0
for i in range(2, n + 1):
if ans[i] != 0:
ans[i] = (ans[i - 1] + ans[i - 2]) % mod
print((ans[n]))
| false | 34.782609 | [
"+lis = [int(eval(input())) for _ in range(m)]",
"-no = [False] * (n + 1)",
"-for _ in range(m):",
"- a = int(eval(input()))",
"- no[a] = True",
"-dp = [0] * (n + 1)",
"-dp[0] = 1",
"-for i in range(n):",
"- if no[i]:",
"- dp[i] = 0",
"- if i + 1 <= n:",
"- dp[i + 1] ... | false | 0.035195 | 0.034344 | 1.024781 | [
"s615101812",
"s576318285"
] |
u591589288 | p02577 | python | s241337512 | s322464600 | 80 | 70 | 74,500 | 73,772 | Accepted | Accepted | 12.5 | from functools import reduce
print(("Yes" if reduce(lambda a, b: (a+b)%9, list(map(int, eval(input()))), 0) == 0 else "No"))
| n = eval(input())
if (sum(map(int, n))) % 9 == 0:
print("Yes")
else:
print("No") | 3 | 6 | 114 | 89 | from functools import reduce
print(
(
"Yes"
if reduce(lambda a, b: (a + b) % 9, list(map(int, eval(input()))), 0) == 0
else "No"
)
)
| n = eval(input())
if (sum(map(int, n))) % 9 == 0:
print("Yes")
else:
print("No")
| false | 50 | [
"-from functools import reduce",
"-",
"-print(",
"- (",
"- \"Yes\"",
"- if reduce(lambda a, b: (a + b) % 9, list(map(int, eval(input()))), 0) == 0",
"- else \"No\"",
"- )",
"-)",
"+n = eval(input())",
"+if (sum(map(int, n))) % 9 == 0:",
"+ print(\"Yes\")",
"+els... | false | 0.043343 | 0.044247 | 0.979584 | [
"s241337512",
"s322464600"
] |
u285891772 | p04021 | python | s199489240 | s336692905 | 180 | 149 | 26,888 | 25,988 | Accepted | Accepted | 17.22 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemge... | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemge... | 35 | 31 | 1,170 | 1,160 | import sys, re
from collections import deque, defaultdict, Counter
from math import (
ceil,
sqrt,
hypot,
factorial,
pi,
sin,
cos,
tan,
asin,
acos,
atan,
radians,
degrees,
log2,
gcd,
)
from itertools import (
accumulate,
permutations,
combinations,
... | import sys, re
from collections import deque, defaultdict, Counter
from math import (
ceil,
sqrt,
hypot,
factorial,
pi,
sin,
cos,
tan,
asin,
acos,
atan,
radians,
degrees,
log2,
gcd,
)
from itertools import (
accumulate,
permutations,
combinations,
... | false | 11.428571 | [
"-A = [[INT(), i] for i in range(N)]",
"-A.sort(key=lambda x: x[0])",
"-cnt = 0",
"-for i, (x, idx) in enumerate(A):",
"- if i % 2 != idx % 2:",
"- cnt += 1",
"-print((cnt // 2))",
"+A = [INT() for _ in range(N)]",
"+zipped = {x: i + 1 for i, x in enumerate(sorted(A))}",
"+A = [zipped[x]... | false | 0.039787 | 0.03745 | 1.062397 | [
"s199489240",
"s336692905"
] |
u532966492 | p03574 | python | s922060515 | s792084477 | 24 | 22 | 3,444 | 3,188 | Accepted | Accepted | 8.33 | H,W=map(int,input().split())
S=["."]*(W+2)
S=[["."]*(W+2)] + [list("."+input()+".") for _ in range(H)] + [["."]*(W+2)]
for i in range(1,H+1):
for j in range(1,W+1):
if S[i][j] == "#":
print("#",end="")
else:
print((S[i-1][j-1]+S[i-1][j]+S[i-1][j+1]+S[i][j-1]+S[i][j+1]... | H,W=map(int,input().split())
#H×Wのマス目入力の周りに"."を付け加える関数
def pixel_input(H,W,border="."):
pixel = [[border]*(W+2)] + \
[[border] + list(input()) + [border] for _ in range(H)] + \
[[border]*(W+2)]
return pixel
#マス目型2次元配列を出力する関数
def pixel_print(pixel):
for i in range(len(pixel)):
print... | 10 | 21 | 387 | 677 | H, W = map(int, input().split())
S = ["."] * (W + 2)
S = (
[["."] * (W + 2)]
+ [list("." + input() + ".") for _ in range(H)]
+ [["."] * (W + 2)]
)
for i in range(1, H + 1):
for j in range(1, W + 1):
if S[i][j] == "#":
print("#", end="")
else:
print(
... | H, W = map(int, input().split())
# H×Wのマス目入力の周りに"."を付け加える関数
def pixel_input(H, W, border="."):
pixel = (
[[border] * (W + 2)]
+ [[border] + list(input()) + [border] for _ in range(H)]
+ [[border] * (W + 2)]
)
return pixel
# マス目型2次元配列を出力する関数
def pixel_print(pixel):
for i in rang... | false | 52.380952 | [
"-S = [\".\"] * (W + 2)",
"-S = (",
"- [[\".\"] * (W + 2)]",
"- + [list(\".\" + input() + \".\") for _ in range(H)]",
"- + [[\".\"] * (W + 2)]",
"-)",
"+# H×Wのマス目入力の周りに\".\"を付け加える関数",
"+def pixel_input(H, W, border=\".\"):",
"+ pixel = (",
"+ [[border] * (W + 2)]",
"+ +... | false | 0.031948 | 0.036563 | 0.873773 | [
"s922060515",
"s792084477"
] |
u434630332 | p03795 | python | s552344449 | s873353197 | 27 | 22 | 8,956 | 8,988 | Accepted | Accepted | 18.52 | n = int(eval(input()))
if n >= 15:
x = n * 800
y = ( n // 15 ) * 200
print((x - y))
else:
print((n * 800)) | n = int(eval(input()))
if n >= 15:
print((n * 800 - ( n // 15 ) * 200))
else:
print((n * 800)) | 8 | 6 | 120 | 98 | n = int(eval(input()))
if n >= 15:
x = n * 800
y = (n // 15) * 200
print((x - y))
else:
print((n * 800))
| n = int(eval(input()))
if n >= 15:
print((n * 800 - (n // 15) * 200))
else:
print((n * 800))
| false | 25 | [
"- x = n * 800",
"- y = (n // 15) * 200",
"- print((x - y))",
"+ print((n * 800 - (n // 15) * 200))"
] | false | 0.039161 | 0.038921 | 1.006149 | [
"s552344449",
"s873353197"
] |
u624475441 | p03341 | python | s097266482 | s298542166 | 154 | 120 | 3,700 | 3,700 | Accepted | Accepted | 22.08 | eval(input())
S = eval(input())
res = cnt = S.count('E')
for c in S:
cnt -= c == 'E'
res = min(res, cnt)
cnt += c == 'W'
print(res) | eval(input())
S = eval(input())
res = cnt = S.count('E')
for c in S:
if c == 'E':
cnt -= 1
res = min(res, cnt)
else:
cnt += 1
print(res) | 8 | 10 | 138 | 165 | eval(input())
S = eval(input())
res = cnt = S.count("E")
for c in S:
cnt -= c == "E"
res = min(res, cnt)
cnt += c == "W"
print(res)
| eval(input())
S = eval(input())
res = cnt = S.count("E")
for c in S:
if c == "E":
cnt -= 1
res = min(res, cnt)
else:
cnt += 1
print(res)
| false | 20 | [
"- cnt -= c == \"E\"",
"- res = min(res, cnt)",
"- cnt += c == \"W\"",
"+ if c == \"E\":",
"+ cnt -= 1",
"+ res = min(res, cnt)",
"+ else:",
"+ cnt += 1"
] | false | 0.036136 | 0.034798 | 1.038445 | [
"s097266482",
"s298542166"
] |
u600402037 | p03111 | python | s900253872 | s911034623 | 259 | 231 | 3,064 | 3,064 | Accepted | Accepted | 10.81 | # coding: utf-8
import sys
import itertools
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
# N本の竹それぞれA, B, C, 使わないか
N, A, B, C = lr()
bamboo = [ir() for _ in range(N)]
answer = 10 ** 5
for pattern in itertools.product(list(range(4)), repeat=N):... | # coding: utf-8
import sys
import itertools
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
# Nは最大8まで、Aに使う竹はどれ?
N, A, B, C = lr()
bamboo = [ir() for _ in range(N)]
answer = 10 ** 5
for pattern in itertools.product(list(range(4)), repeat=N):
... | 31 | 29 | 858 | 659 | # coding: utf-8
import sys
import itertools
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
# N本の竹それぞれA, B, C, 使わないか
N, A, B, C = lr()
bamboo = [ir() for _ in range(N)]
answer = 10**5
for pattern in itertools.product(list(range(4)), repeat=N):
mp = 0
... | # coding: utf-8
import sys
import itertools
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
# Nは最大8まで、Aに使う竹はどれ?
N, A, B, C = lr()
bamboo = [ir() for _ in range(N)]
answer = 10**5
for pattern in itertools.product(list(range(4)), repeat=N):
use = [0] * 3
... | false | 6.451613 | [
"-# N本の竹それぞれA, B, C, 使わないか",
"+# Nは最大8まで、Aに使う竹はどれ?",
"+ use = [0] * 3",
"- Alist = []",
"- Blist = []",
"- Clist = []",
"- for i, p in enumerate(pattern):",
"- if p == 0:",
"- Alist.append(bamboo[i])",
"- elif p == 1:",
"- Blist.append(bamboo[i]... | false | 0.230147 | 0.24139 | 0.953424 | [
"s900253872",
"s911034623"
] |
u934442292 | p02973 | python | s896228209 | s405567166 | 1,686 | 96 | 13,580 | 16,908 | Accepted | Accepted | 94.31 | import sys
from bisect import bisect_left
input = sys.stdin.readline
def main():
N = int(eval(input()))
A = [0] * N
for i in range(N):
A[i] = int(eval(input()))
colors = []
for a in A:
idx = bisect_left(colors, a)
if idx == 0:
colors.insert(0, ... | import sys
from bisect import bisect_right
input = sys.stdin.readline
def main():
N = int(eval(input()))
A = [0] * N
for i in range(N):
A[i] = int(eval(input()))
A = [-a for a in A]
colors = []
for a in A:
idx = bisect_right(colors, a)
if idx == len(... | 26 | 28 | 444 | 476 | import sys
from bisect import bisect_left
input = sys.stdin.readline
def main():
N = int(eval(input()))
A = [0] * N
for i in range(N):
A[i] = int(eval(input()))
colors = []
for a in A:
idx = bisect_left(colors, a)
if idx == 0:
colors.insert(0, a)
else:
... | import sys
from bisect import bisect_right
input = sys.stdin.readline
def main():
N = int(eval(input()))
A = [0] * N
for i in range(N):
A[i] = int(eval(input()))
A = [-a for a in A]
colors = []
for a in A:
idx = bisect_right(colors, a)
if idx == len(colors):
... | false | 7.142857 | [
"-from bisect import bisect_left",
"+from bisect import bisect_right",
"+ A = [-a for a in A]",
"- idx = bisect_left(colors, a)",
"- if idx == 0:",
"- colors.insert(0, a)",
"+ idx = bisect_right(colors, a)",
"+ if idx == len(colors):",
"+ colors.a... | false | 0.076497 | 0.042082 | 1.817805 | [
"s896228209",
"s405567166"
] |
u644778646 | p02836 | python | s654676339 | s610325327 | 23 | 17 | 2,940 | 2,940 | Accepted | Accepted | 26.09 | s = eval(input())
ans = 0
for i in range(len(s)//2 + len(s)%2):
if s[i] != s[-i - 1]:
ans += 1
print(ans) | s = eval(input())
ans = 0
for i in range(len(s)//2):
if s[i] != s[-i - 1]:
ans += 1
print(ans) | 6 | 6 | 116 | 105 | s = eval(input())
ans = 0
for i in range(len(s) // 2 + len(s) % 2):
if s[i] != s[-i - 1]:
ans += 1
print(ans)
| s = eval(input())
ans = 0
for i in range(len(s) // 2):
if s[i] != s[-i - 1]:
ans += 1
print(ans)
| false | 0 | [
"-for i in range(len(s) // 2 + len(s) % 2):",
"+for i in range(len(s) // 2):"
] | false | 0.042051 | 0.0458 | 0.918138 | [
"s654676339",
"s610325327"
] |
u371763408 | p03221 | python | s456758214 | s048764725 | 802 | 738 | 32,832 | 43,160 | Accepted | Accepted | 7.98 | import bisect
n,m = map(int,input().split())
years = [[]for i in range(n)]
yearss = []
for i in range(m):
p,y = map(int,input().split())
years[p-1].append(y)
yearss.append([p,y])
for i in range(n):
years[i].sort()
for i in range(m):
print("{0:06d}".format(yearss[i][0]),"{0:06d}".format(bi... | from bisect import bisect_left
n,m=list(map(int,input().split()))
ls=[[] for i in range(n)]
py=[]
for i in range(m):
p,y=list(map(int,input().split()))
ls[p-1].append(y)
py.append([p,y])
ls=list([sorted(x) for x in ls])
for i in range(m):
p,y=py[i]
index= bisect_left(ls[p-1],y)
print((str(p).zfi... | 17 | 13 | 383 | 339 | import bisect
n, m = map(int, input().split())
years = [[] for i in range(n)]
yearss = []
for i in range(m):
p, y = map(int, input().split())
years[p - 1].append(y)
yearss.append([p, y])
for i in range(n):
years[i].sort()
for i in range(m):
print(
"{0:06d}".format(yearss[i][0]),
"{0... | from bisect import bisect_left
n, m = list(map(int, input().split()))
ls = [[] for i in range(n)]
py = []
for i in range(m):
p, y = list(map(int, input().split()))
ls[p - 1].append(y)
py.append([p, y])
ls = list([sorted(x) for x in ls])
for i in range(m):
p, y = py[i]
index = bisect_left(ls[p - 1],... | false | 23.529412 | [
"-import bisect",
"+from bisect import bisect_left",
"-n, m = map(int, input().split())",
"-years = [[] for i in range(n)]",
"-yearss = []",
"+n, m = list(map(int, input().split()))",
"+ls = [[] for i in range(n)]",
"+py = []",
"- p, y = map(int, input().split())",
"- years[p - 1].append(y)"... | false | 0.045918 | 0.044326 | 1.035908 | [
"s456758214",
"s048764725"
] |
u278855471 | p02773 | python | s673389499 | s729452349 | 540 | 404 | 49,380 | 38,720 | Accepted | Accepted | 25.19 | from collections import defaultdict
N = int(input())
s_counter = defaultdict(int)
for _ in range(N):
S = input()
s_counter[S] += 1
S_list = sorted(s_counter.items(), key=lambda x: x[1], reverse=True)
answer = []
for i in range(len(S_list)):
if S_list[0][1] != S_list[i][1]:
break
ans... | from collections import Counter
N = int(input())
counter = Counter([input() for _ in range(N)])
max_cnt = max(counter.values())
names = [name for name, cnt in counter.items() if cnt == max_cnt]
names.sort()
print(*names, sep='\n')
| 15 | 9 | 388 | 241 | from collections import defaultdict
N = int(input())
s_counter = defaultdict(int)
for _ in range(N):
S = input()
s_counter[S] += 1
S_list = sorted(s_counter.items(), key=lambda x: x[1], reverse=True)
answer = []
for i in range(len(S_list)):
if S_list[0][1] != S_list[i][1]:
break
answer.append(S... | from collections import Counter
N = int(input())
counter = Counter([input() for _ in range(N)])
max_cnt = max(counter.values())
names = [name for name, cnt in counter.items() if cnt == max_cnt]
names.sort()
print(*names, sep="\n")
| false | 40 | [
"-from collections import defaultdict",
"+from collections import Counter",
"-s_counter = defaultdict(int)",
"-for _ in range(N):",
"- S = input()",
"- s_counter[S] += 1",
"-S_list = sorted(s_counter.items(), key=lambda x: x[1], reverse=True)",
"-answer = []",
"-for i in range(len(S_list)):",
... | false | 0.042099 | 0.042792 | 0.983795 | [
"s673389499",
"s729452349"
] |
u729133443 | p03338 | python | s263061531 | s338571133 | 164 | 17 | 38,384 | 2,940 | Accepted | Accepted | 89.63 | eval(input());a=eval(input());print((max(len(set(a[:s])&set(a[s:]))for s in range(99)))) | _,a=open(0);print((max(len(set(a[:s])&set(a[s:]))for s in range(99)))) | 1 | 1 | 74 | 68 | eval(input())
a = eval(input())
print((max(len(set(a[:s]) & set(a[s:])) for s in range(99))))
| _, a = open(0)
print((max(len(set(a[:s]) & set(a[s:])) for s in range(99))))
| false | 0 | [
"-eval(input())",
"-a = eval(input())",
"+_, a = open(0)"
] | false | 0.103946 | 0.040955 | 2.538036 | [
"s263061531",
"s338571133"
] |
u774539708 | p02813 | python | s239238539 | s750972270 | 28 | 17 | 8,052 | 3,064 | Accepted | Accepted | 39.29 | import itertools as it
s=list(range(1,int(eval(input()))+1))
A=list(it.permutations(s))
P,Q=[tuple(map(int,input().split())) for i in range(2)]
print((abs(A.index(P)-A.index(Q)))) | import math
n=int(eval(input()))
A,B=[list(range(1,n+1)) for i in range(2)]
P,Q=[list(map(int,input().split())) for i in range(2)]
p=0
for i in range(n-1):
p+=(A.index(P[i]))*math.factorial(n-i-1)
A.remove(P[i])
q=0
for i in range(n-1):
q+=(B.index(Q[i]))*math.factorial(n-i-1)
B.remove(Q[i])
... | 5 | 13 | 175 | 330 | import itertools as it
s = list(range(1, int(eval(input())) + 1))
A = list(it.permutations(s))
P, Q = [tuple(map(int, input().split())) for i in range(2)]
print((abs(A.index(P) - A.index(Q))))
| import math
n = int(eval(input()))
A, B = [list(range(1, n + 1)) for i in range(2)]
P, Q = [list(map(int, input().split())) for i in range(2)]
p = 0
for i in range(n - 1):
p += (A.index(P[i])) * math.factorial(n - i - 1)
A.remove(P[i])
q = 0
for i in range(n - 1):
q += (B.index(Q[i])) * math.factorial(n - ... | false | 61.538462 | [
"-import itertools as it",
"+import math",
"-s = list(range(1, int(eval(input())) + 1))",
"-A = list(it.permutations(s))",
"-P, Q = [tuple(map(int, input().split())) for i in range(2)]",
"-print((abs(A.index(P) - A.index(Q))))",
"+n = int(eval(input()))",
"+A, B = [list(range(1, n + 1)) for i in range... | false | 0.203642 | 0.04506 | 4.519388 | [
"s239238539",
"s750972270"
] |
u241159583 | p02785 | python | s828368423 | s609445520 | 191 | 124 | 25,768 | 31,504 | Accepted | Accepted | 35.08 | N, K = list(map(int, input().split()))
H = list(map(int, input().split()))
H.sort()
for i in range(K):
if len(H) <= 0:
break
H.pop(-1)
print((sum(H) if len(H) > 0 else 0)) | n,k = list(map(int, input().split()))
H = sorted(list(map(int, input().split())))[::-1]
ans = 0
for h in H:
if k>0:
k -= 1
continue
ans += h
print(ans) | 8 | 9 | 178 | 177 | N, K = list(map(int, input().split()))
H = list(map(int, input().split()))
H.sort()
for i in range(K):
if len(H) <= 0:
break
H.pop(-1)
print((sum(H) if len(H) > 0 else 0))
| n, k = list(map(int, input().split()))
H = sorted(list(map(int, input().split())))[::-1]
ans = 0
for h in H:
if k > 0:
k -= 1
continue
ans += h
print(ans)
| false | 11.111111 | [
"-N, K = list(map(int, input().split()))",
"-H = list(map(int, input().split()))",
"-H.sort()",
"-for i in range(K):",
"- if len(H) <= 0:",
"- break",
"- H.pop(-1)",
"-print((sum(H) if len(H) > 0 else 0))",
"+n, k = list(map(int, input().split()))",
"+H = sorted(list(map(int, input().... | false | 0.057784 | 0.057742 | 1.000735 | [
"s828368423",
"s609445520"
] |
u374765578 | p02959 | python | s402934341 | s255930384 | 162 | 126 | 19,156 | 18,476 | Accepted | Accepted | 22.22 | n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = 0
for i in range(n):
if a[i] >= b[i]:
d += b[i]
else:
d += a[i]
b[i] = b[i] - a[i]
if a[i+1] - b[i] >= 0:
d += b[i]
a[i+1] = a[i+1] - b[i]
else:
... |
def main():
n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = 0
for i in range(n):
if a[i] >= b[i]:
d += b[i]
else:
d += a[i]
b[i] = b[i] - a[i]
if a[i+1] - b[i] >= 0:
d += b[i]
a[i+1] = a... | 24 | 31 | 369 | 442 | n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = 0
for i in range(n):
if a[i] >= b[i]:
d += b[i]
else:
d += a[i]
b[i] = b[i] - a[i]
if a[i + 1] - b[i] >= 0:
d += b[i]
a[i + 1] = a[i + 1] - b[i]
else... | def main():
n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = 0
for i in range(n):
if a[i] >= b[i]:
d += b[i]
else:
d += a[i]
b[i] = b[i] - a[i]
if a[i + 1] - b[i] >= 0:
d... | false | 22.580645 | [
"-n = int(eval(input()))",
"-a = list(map(int, input().split()))",
"-b = list(map(int, input().split()))",
"-d = 0",
"-for i in range(n):",
"- if a[i] >= b[i]:",
"- d += b[i]",
"- else:",
"- d += a[i]",
"- b[i] = b[i] - a[i]",
"- if a[i + 1] - b[i] >= 0:",
"+d... | false | 0.111474 | 0.053469 | 2.084816 | [
"s402934341",
"s255930384"
] |
u670180528 | p03354 | python | s863940086 | s076172327 | 473 | 418 | 35,324 | 35,324 | Accepted | Accepted | 11.63 | class UnionFind():
def __init__(self, n):
self.n = n
self.root = [-1]*(n+1)
self.rank = [0]*(n+1)
def find(self, x):
if self.root[x] < 0:
return x
else:
self.root[x] = self.find(self.root[x])
return self.root[x]
def unite(self, x, y):
x = self.find(x)
y = self.find(y)
if... | class UnionFind():
def __init__(self, n):
self.n = n
self.root = [-1]*(n+1)
self.rank = [0]*(n+1)
def find(self, x):
if self.root[x] < 0:
return x
else:
self.root[x] = self.find(self.root[x])
return self.root[x]
def unite(self, x, y):
x = self.find(x)
y = self.find(y)
if... | 39 | 40 | 867 | 913 | class UnionFind:
def __init__(self, n):
self.n = n
self.root = [-1] * (n + 1)
self.rank = [0] * (n + 1)
def find(self, x):
if self.root[x] < 0:
return x
else:
self.root[x] = self.find(self.root[x])
return self.root[x]
def unite(se... | class UnionFind:
def __init__(self, n):
self.n = n
self.root = [-1] * (n + 1)
self.rank = [0] * (n + 1)
def find(self, x):
if self.root[x] < 0:
return x
else:
self.root[x] = self.find(self.root[x])
return self.root[x]
def unite(se... | false | 2.5 | [
"- return self.find(x) == self.find(y)",
"+ return self.find(x) == self.find(y) or x == y",
"-n, m, *l = list(map(int, open(0).read().split()))",
"-p = l[:n]",
"-xy = l[n:]",
"-ids = [0] * (n + 1)",
"-for i in range(n):",
"- ids[p[i]] = i + 1",
"-uf = UnionFind(n)",
"-for x, y in ... | false | 0.041419 | 0.046326 | 0.894085 | [
"s863940086",
"s076172327"
] |
u672220554 | p02915 | python | s327064916 | s535540842 | 168 | 19 | 38,256 | 3,060 | Accepted | Accepted | 88.69 | n = int(eval(input()))
print((n*n*n)) | n = int(eval(input()))
print((n**3)) | 2 | 2 | 30 | 29 | n = int(eval(input()))
print((n * n * n))
| n = int(eval(input()))
print((n**3))
| false | 0 | [
"-print((n * n * n))",
"+print((n**3))"
] | false | 0.046795 | 0.007593 | 6.163075 | [
"s327064916",
"s535540842"
] |
u798181098 | p03288 | python | s796535607 | s277761748 | 17 | 10 | 2,940 | 2,568 | Accepted | Accepted | 41.18 | print(('A'+'BRG'[int(eval(input()))//100+4>>4]+'C')) | print('A%sC'%'BRG'[eval(input())/100+4>>4]) | 1 | 1 | 44 | 35 | print(("A" + "BRG"[int(eval(input())) // 100 + 4 >> 4] + "C"))
| print("A%sC" % "BRG"[eval(input()) / 100 + 4 >> 4])
| false | 0 | [
"-print((\"A\" + \"BRG\"[int(eval(input())) // 100 + 4 >> 4] + \"C\"))",
"+print(\"A%sC\" % \"BRG\"[eval(input()) / 100 + 4 >> 4])"
] | false | 0.035958 | 0.068385 | 0.52582 | [
"s796535607",
"s277761748"
] |
u497952650 | p03721 | python | s695288646 | s841258472 | 517 | 206 | 27,872 | 11,720 | Accepted | Accepted | 60.15 | N,K = list(map(int,input().split()))
ans = 0
m = 0
ab = []
for i in range(N):
ab.append(list(map(int,input().split())))
ab.sort()
tmp = 0
for a,b in ab:
tmp += b
if tmp >= K:
print(a)
break | N,K = list(map(int,input().split()))
n = [0]*(int(1e5)+1)
for i in range(N):
a,b = list(map(int,input().split()))
n[a] += b
for i in range(int(1e5)+1):
K -= n[i]
if K <= 0:
print(i)
break | 16 | 12 | 229 | 220 | N, K = list(map(int, input().split()))
ans = 0
m = 0
ab = []
for i in range(N):
ab.append(list(map(int, input().split())))
ab.sort()
tmp = 0
for a, b in ab:
tmp += b
if tmp >= K:
print(a)
break
| N, K = list(map(int, input().split()))
n = [0] * (int(1e5) + 1)
for i in range(N):
a, b = list(map(int, input().split()))
n[a] += b
for i in range(int(1e5) + 1):
K -= n[i]
if K <= 0:
print(i)
break
| false | 25 | [
"-ans = 0",
"-m = 0",
"-ab = []",
"+n = [0] * (int(1e5) + 1)",
"- ab.append(list(map(int, input().split())))",
"-ab.sort()",
"-tmp = 0",
"-for a, b in ab:",
"- tmp += b",
"- if tmp >= K:",
"- print(a)",
"+ a, b = list(map(int, input().split()))",
"+ n[a] += b",
"+for ... | false | 0.039035 | 0.044271 | 0.881716 | [
"s695288646",
"s841258472"
] |
u588341295 | p02798 | python | s005633831 | s555365864 | 1,884 | 1,257 | 104,496 | 104,368 | Accepted | Accepted | 33.28 | # -*- coding: utf-8 -*-
import sys
from itertools import accumulate
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in rang... | # -*- coding: utf-8 -*-
import sys
from itertools import accumulate
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in rang... | 69 | 69 | 2,012 | 2,014 | # -*- coding: utf-8 -*-
import sys
from itertools import accumulate
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [[c] * b for i in range(a)]
def list3d(a, b, c, d):
return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e):
return [[[[e] * d... | # -*- coding: utf-8 -*-
import sys
from itertools import accumulate
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [[c] * b for i in range(a)]
def list3d(a, b, c, d):
return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e):
return [[[[e] * d... | false | 0 | [
"- cur = cards[(i % 2) ^ (1 - popcnt % 2)][i]",
"+ cur = cards[(i & 1) ^ (1 - (popcnt & 1))][i]",
"- nxt = cards[(j % 2) ^ (popcnt % 2)][j]",
"+ nxt = cards[(j & 1) ^ (popcnt & 1)][j]"
] | false | 0.050706 | 0.042191 | 1.201821 | [
"s005633831",
"s555365864"
] |
u096616343 | p03045 | python | s224681989 | s921014401 | 730 | 493 | 104,692 | 23,648 | Accepted | Accepted | 32.47 | import sys
sys.setrecursionlimit(10 ** 7)
def dfs(s):
if visited[s]:
return
visited[s] = 1
for to in t[s]:
if visited[to]:
continue
dfs(to)
N, M = list(map(int,input().split()))
t = [[] for _ in range(N)]
visited = [0] * N
for _ in range(M):
X, Y... | N, M = list(map(int,input().split()))
t = [[] for _ in range(N)]
visited = [0] * N
for _ in range(M):
X, Y, Z = list(map(int,input().split()))
X -= 1
Y -= 1
t[X].append(Y)
t[Y].append(X)
ans = 0
for i in range(N):
if visited[i]:
continue
ans += 1
stack = [i]
wh... | 28 | 23 | 516 | 494 | import sys
sys.setrecursionlimit(10**7)
def dfs(s):
if visited[s]:
return
visited[s] = 1
for to in t[s]:
if visited[to]:
continue
dfs(to)
N, M = list(map(int, input().split()))
t = [[] for _ in range(N)]
visited = [0] * N
for _ in range(M):
X, Y, Z = list(map(int... | N, M = list(map(int, input().split()))
t = [[] for _ in range(N)]
visited = [0] * N
for _ in range(M):
X, Y, Z = list(map(int, input().split()))
X -= 1
Y -= 1
t[X].append(Y)
t[Y].append(X)
ans = 0
for i in range(N):
if visited[i]:
continue
ans += 1
stack = [i]
while stack:
... | false | 17.857143 | [
"-import sys",
"-",
"-sys.setrecursionlimit(10**7)",
"-",
"-",
"-def dfs(s):",
"- if visited[s]:",
"- return",
"- visited[s] = 1",
"- for to in t[s]:",
"- if visited[to]:",
"- continue",
"- dfs(to)",
"-",
"-",
"-for i in range(0, N):",
"+for i... | false | 0.046878 | 0.046656 | 1.004752 | [
"s224681989",
"s921014401"
] |
u189023301 | p03164 | python | s567416777 | s408016246 | 277 | 230 | 42,076 | 40,560 | Accepted | Accepted | 16.97 | n, m = list(map(int, input().split()))
inf = 10**11
dp = [inf] * (1000 * n + 1)
dp[0] = 0
for i in range(n):
w, v = list(map(int, input().split()))
for j in range(1000 * n - v, -1, -1):
if dp[j] != inf:
dp[j + v] = min(dp[j + v], dp[j] + w)
ans = 0
for a, b in enumerate(dp):
... | import sys
readline = sys.stdin.buffer.readline
def main():
n, m = list(map(int, readline().split()))
inf = 10**11
dp = [inf] * (1000 * n + 1)
dp[0] = 0
for i in range(n):
w, v = list(map(int, input().split()))
for j in range(1000 * n - v, -1, -1):
if dp[j] ... | 15 | 22 | 359 | 524 | n, m = list(map(int, input().split()))
inf = 10**11
dp = [inf] * (1000 * n + 1)
dp[0] = 0
for i in range(n):
w, v = list(map(int, input().split()))
for j in range(1000 * n - v, -1, -1):
if dp[j] != inf:
dp[j + v] = min(dp[j + v], dp[j] + w)
ans = 0
for a, b in enumerate(dp):
if b <= m:
... | import sys
readline = sys.stdin.buffer.readline
def main():
n, m = list(map(int, readline().split()))
inf = 10**11
dp = [inf] * (1000 * n + 1)
dp[0] = 0
for i in range(n):
w, v = list(map(int, input().split()))
for j in range(1000 * n - v, -1, -1):
if dp[j] != inf:
... | false | 31.818182 | [
"-n, m = list(map(int, input().split()))",
"-inf = 10**11",
"-dp = [inf] * (1000 * n + 1)",
"-dp[0] = 0",
"-for i in range(n):",
"- w, v = list(map(int, input().split()))",
"- for j in range(1000 * n - v, -1, -1):",
"- if dp[j] != inf:",
"- dp[j + v] = min(dp[j + v], dp[j] + ... | false | 0.007416 | 0.046146 | 0.160709 | [
"s567416777",
"s408016246"
] |
u254871849 | p02843 | python | s397410908 | s033176911 | 1,079 | 43 | 13,252 | 3,828 | Accepted | Accepted | 96.01 | import sys
import numpy as np
def main():
x = int(sys.stdin.readline().rstrip())
if x < 100:
print((0))
sys.exit()
if 100 <= x <= 105:
print((1))
sys.exit()
dp = np.zeros_like(np.arange(x+1), dtype=bool)
dp[100:106] = True
for i in range(106, x... | import sys
def main():
x = int(sys.stdin.readline().rstrip())
payable = [False] * (x + 1)
payable[0] = True
if x < 100:
print((0))
sys.exit()
if 100 <= x <= 105:
print((1))
sys.exit()
for i in range(100,106):
payable[i] = True
for ... | 21 | 24 | 427 | 456 | import sys
import numpy as np
def main():
x = int(sys.stdin.readline().rstrip())
if x < 100:
print((0))
sys.exit()
if 100 <= x <= 105:
print((1))
sys.exit()
dp = np.zeros_like(np.arange(x + 1), dtype=bool)
dp[100:106] = True
for i in range(106, x + 1):
d... | import sys
def main():
x = int(sys.stdin.readline().rstrip())
payable = [False] * (x + 1)
payable[0] = True
if x < 100:
print((0))
sys.exit()
if 100 <= x <= 105:
print((1))
sys.exit()
for i in range(100, 106):
payable[i] = True
for i in range(106, x ... | false | 12.5 | [
"-import numpy as np",
"+ payable = [False] * (x + 1)",
"+ payable[0] = True",
"- dp = np.zeros_like(np.arange(x + 1), dtype=bool)",
"- dp[100:106] = True",
"+ for i in range(100, 106):",
"+ payable[i] = True",
"- dp[i] = np.any(dp[i - 105 : i - 99])",
"- print((dp[x]... | false | 0.525359 | 0.03571 | 14.711686 | [
"s397410908",
"s033176911"
] |
u761529120 | p03220 | python | s824526087 | s587622132 | 245 | 18 | 17,688 | 3,060 | Accepted | Accepted | 92.65 | import numpy as np
def getNearestValue(list, num):
"""
概要: リストからある値に最も近い値を返却する関数
@param list: データ配列
@param num: 対象値
@return 対象値に最も近い値
"""
# リスト要素と対象値の差分を計算し最小値のインデックスを取得
idx = np.abs(np.asarray(list) - num).argmin()
return list[idx]
num = int(eval(input()))
temperat... | N = int(eval(input()))
T, A = list(map(int, input().split(" ")))
height = list(map(int, input().split(" ")))
place_temperature = 0
diff_A =[]
for i in range(N):
place_temperature= T - height[i] * 0.006
diff_A.append(abs(A - place_temperature))
print((diff_A.index(min(diff_A)) + 1)) | 25 | 11 | 643 | 294 | import numpy as np
def getNearestValue(list, num):
"""
概要: リストからある値に最も近い値を返却する関数
@param list: データ配列
@param num: 対象値
@return 対象値に最も近い値
"""
# リスト要素と対象値の差分を計算し最小値のインデックスを取得
idx = np.abs(np.asarray(list) - num).argmin()
return list[idx]
num = int(eval(input()))
temperature = list(map... | N = int(eval(input()))
T, A = list(map(int, input().split(" ")))
height = list(map(int, input().split(" ")))
place_temperature = 0
diff_A = []
for i in range(N):
place_temperature = T - height[i] * 0.006
diff_A.append(abs(A - place_temperature))
print((diff_A.index(min(diff_A)) + 1))
| false | 56 | [
"-import numpy as np",
"-",
"-",
"-def getNearestValue(list, num):",
"- \"\"\"",
"- 概要: リストからある値に最も近い値を返却する関数",
"- @param list: データ配列",
"- @param num: 対象値",
"- @return 対象値に最も近い値",
"- \"\"\"",
"- # リスト要素と対象値の差分を計算し最小値のインデックスを取得",
"- idx = np.abs(np.asarray(list) - num).a... | false | 0.394324 | 0.037204 | 10.599083 | [
"s824526087",
"s587622132"
] |
u137693056 | p03435 | python | s832056056 | s916209831 | 52 | 17 | 3,064 | 3,064 | Accepted | Accepted | 67.31 | def calc(a1,c):
As=[a1]
Bs=[]
Bs.append(c[0][0]-As[0])
As.append(c[1][0]-Bs[0])
As.append(c[2][0]-Bs[0])
Bs.append(c[0][1]-As[0])
Bs.append(c[0][2]-As[0])
for a in range(3):
for b in range(3):
if As[a]+Bs[b]!=c[a][b]: return False
return True
c=[]
f... | def calc(a1,c):
As=[a1]
Bs=[]
Bs.append(c[0][0]-As[0])
As.append(c[1][0]-Bs[0])
As.append(c[2][0]-Bs[0])
Bs.append(c[0][1]-As[0])
Bs.append(c[0][2]-As[0])
for a in range(3):
for b in range(3):
if As[a]+Bs[b]!=c[a][b]: return False
return True
c=[]
f... | 24 | 21 | 533 | 452 | def calc(a1, c):
As = [a1]
Bs = []
Bs.append(c[0][0] - As[0])
As.append(c[1][0] - Bs[0])
As.append(c[2][0] - Bs[0])
Bs.append(c[0][1] - As[0])
Bs.append(c[0][2] - As[0])
for a in range(3):
for b in range(3):
if As[a] + Bs[b] != c[a][b]:
return False
... | def calc(a1, c):
As = [a1]
Bs = []
Bs.append(c[0][0] - As[0])
As.append(c[1][0] - Bs[0])
As.append(c[2][0] - Bs[0])
Bs.append(c[0][1] - As[0])
Bs.append(c[0][2] - As[0])
for a in range(3):
for b in range(3):
if As[a] + Bs[b] != c[a][b]:
return False
... | false | 12.5 | [
"-for i in range(-int(1e4), 100):",
"- if calc(i, c):",
"- print(\"Yes\")",
"- flag = True",
"- break",
"-if not flag:",
"+if calc(0, c):",
"+ print(\"Yes\")",
"+else:"
] | false | 0.00777 | 0.040485 | 0.19192 | [
"s832056056",
"s916209831"
] |
u074220993 | p03425 | python | s975523121 | s378921961 | 140 | 69 | 9,884 | 17,164 | Accepted | Accepted | 50.71 | N = int(eval(input()))
Name = [input()[0] for _ in range(N)]
March = {x:Name.count(x) for x in 'MARCH' if Name.count(x) > 0}
import itertools
ans = 0
for x,y,z in itertools.combinations(list(March.values()), 3):
ans += x*y*z
print(ans) | from collections import Counter
from itertools import combinations, starmap
func = lambda x, y, z: x*y*z
def main():
with open(0) as f:
N, *S = f.read().split()
S = [s[0] for s in S if s[0] in list('MARCH')]
S = Counter(S)
ans = sum(starmap(func, combinations(list(S.values()), 3)))
... | 9 | 13 | 236 | 336 | N = int(eval(input()))
Name = [input()[0] for _ in range(N)]
March = {x: Name.count(x) for x in "MARCH" if Name.count(x) > 0}
import itertools
ans = 0
for x, y, z in itertools.combinations(list(March.values()), 3):
ans += x * y * z
print(ans)
| from collections import Counter
from itertools import combinations, starmap
func = lambda x, y, z: x * y * z
def main():
with open(0) as f:
N, *S = f.read().split()
S = [s[0] for s in S if s[0] in list("MARCH")]
S = Counter(S)
ans = sum(starmap(func, combinations(list(S.values()), 3)))
pr... | false | 30.769231 | [
"-N = int(eval(input()))",
"-Name = [input()[0] for _ in range(N)]",
"-March = {x: Name.count(x) for x in \"MARCH\" if Name.count(x) > 0}",
"-import itertools",
"+from collections import Counter",
"+from itertools import combinations, starmap",
"-ans = 0",
"-for x, y, z in itertools.combinations(list(... | false | 0.034328 | 0.037067 | 0.926103 | [
"s975523121",
"s378921961"
] |
u020373088 | p03309 | python | s531016204 | s675948336 | 212 | 194 | 26,836 | 26,128 | Accepted | Accepted | 8.49 | n = int(eval(input()))
a = list(map(int, input().split()))
a = [a[i] - (i+1) for i in range(len(a))]
import statistics
b = int(statistics.median(a))
ans = sum([abs(i-b) for i in a])
print(ans) | n = int(eval(input()))
a = list(map(int, input().split()))
a = [a[i] - (i+1) for i in range(len(a))]
b = sorted(a)[int(n/2)]
print((sum([abs(i-b) for i in a]))) | 8 | 5 | 194 | 156 | n = int(eval(input()))
a = list(map(int, input().split()))
a = [a[i] - (i + 1) for i in range(len(a))]
import statistics
b = int(statistics.median(a))
ans = sum([abs(i - b) for i in a])
print(ans)
| n = int(eval(input()))
a = list(map(int, input().split()))
a = [a[i] - (i + 1) for i in range(len(a))]
b = sorted(a)[int(n / 2)]
print((sum([abs(i - b) for i in a])))
| false | 37.5 | [
"-import statistics",
"-",
"-b = int(statistics.median(a))",
"-ans = sum([abs(i - b) for i in a])",
"-print(ans)",
"+b = sorted(a)[int(n / 2)]",
"+print((sum([abs(i - b) for i in a])))"
] | false | 0.052777 | 0.062698 | 0.841765 | [
"s531016204",
"s675948336"
] |
u367130284 | p03212 | python | s981753453 | s901178910 | 90 | 76 | 2,940 | 3,060 | Accepted | Accepted | 15.56 | n=int(eval(input()))
def dfs(s):
if int(s)>n:
return 0
ret=1 if all(s.count(c)>0 for c in "753") else 0
for c in "753":
ret+=dfs(s+c)
return ret
print((dfs("0"))) | n=int(eval(input()))
def dfs(s):
if int(s)>n:
return 0
b=(all(map(s.count,"357")))
for c in "357":
b+=dfs(s+c)
return b
print((dfs("0"))) | 11 | 10 | 198 | 170 | n = int(eval(input()))
def dfs(s):
if int(s) > n:
return 0
ret = 1 if all(s.count(c) > 0 for c in "753") else 0
for c in "753":
ret += dfs(s + c)
return ret
print((dfs("0")))
| n = int(eval(input()))
def dfs(s):
if int(s) > n:
return 0
b = all(map(s.count, "357"))
for c in "357":
b += dfs(s + c)
return b
print((dfs("0")))
| false | 9.090909 | [
"- ret = 1 if all(s.count(c) > 0 for c in \"753\") else 0",
"- for c in \"753\":",
"- ret += dfs(s + c)",
"- return ret",
"+ b = all(map(s.count, \"357\"))",
"+ for c in \"357\":",
"+ b += dfs(s + c)",
"+ return b"
] | false | 0.049537 | 0.065581 | 0.755354 | [
"s981753453",
"s901178910"
] |
u367130284 | p03946 | python | s785368944 | s690335400 | 217 | 197 | 24,348 | 24,456 | Accepted | Accepted | 9.22 | from numpy import*;_,a=open(0);*a,=list(map(int,a.split()));c=array(a)-minimum.accumulate(a);print((list(c).count(max(c)))) | from numpy import*;_,a=open(0);*a,=list(map(int,a.split()));c=array(a)-minimum.accumulate(a);print((sum(c==max(c)))) | 1 | 1 | 115 | 108 | from numpy import *
_, a = open(0)
(*a,) = list(map(int, a.split()))
c = array(a) - minimum.accumulate(a)
print((list(c).count(max(c))))
| from numpy import *
_, a = open(0)
(*a,) = list(map(int, a.split()))
c = array(a) - minimum.accumulate(a)
print((sum(c == max(c))))
| false | 0 | [
"-print((list(c).count(max(c))))",
"+print((sum(c == max(c))))"
] | false | 0.186316 | 0.705702 | 0.264015 | [
"s785368944",
"s690335400"
] |
u353919145 | p03261 | python | s647868719 | s198254800 | 165 | 18 | 38,384 | 3,060 | Accepted | Accepted | 89.09 | def a():
n=int(eval(input()))
w=list()
for i in range(n):
z=eval(input())
w.append(z)
for i in range(1,n):
if w[i][0]!=w[i-1][len(w[i-1])-1]:
print("No")
return 0
w.sort()
for i in range(n-1):
if w[i]==w[i+1]:
print... | n=int(eval(input()))
x=[]
f_l_checker=True
x.append(eval(input()))
for i in range(1,n):
x.append(eval(input()))
if f_l_checker:
if x[i][0]==x[i-1][-1]:
for j in range(i):
if x[i]==x[j]:
f_l_checker=False
else:
f_l_checker=Fa... | 18 | 17 | 373 | 364 | def a():
n = int(eval(input()))
w = list()
for i in range(n):
z = eval(input())
w.append(z)
for i in range(1, n):
if w[i][0] != w[i - 1][len(w[i - 1]) - 1]:
print("No")
return 0
w.sort()
for i in range(n - 1):
if w[i] == w[i + 1]:
... | n = int(eval(input()))
x = []
f_l_checker = True
x.append(eval(input()))
for i in range(1, n):
x.append(eval(input()))
if f_l_checker:
if x[i][0] == x[i - 1][-1]:
for j in range(i):
if x[i] == x[j]:
f_l_checker = False
else:
f_l_checker... | false | 5.555556 | [
"-def a():",
"- n = int(eval(input()))",
"- w = list()",
"- for i in range(n):",
"- z = eval(input())",
"- w.append(z)",
"- for i in range(1, n):",
"- if w[i][0] != w[i - 1][len(w[i - 1]) - 1]:",
"- print(\"No\")",
"- return 0",
"- w.sort... | false | 0.040278 | 0.039445 | 1.021101 | [
"s647868719",
"s198254800"
] |
u655975843 | p03294 | python | s785536957 | s008591694 | 298 | 19 | 18,564 | 3,316 | Accepted | Accepted | 93.62 | import numpy as np
n = int(eval(input()))
a = list(map(int, input().split()))
f = 0
ans = np.cumsum(a) - n
print((ans[-1]))
| n = int(eval(input()))
a = list(map(int, input().split()))
f = 0
ans = 0
for i in range(n):
ans += a[i]
print((ans - n))
| 6 | 7 | 121 | 123 | import numpy as np
n = int(eval(input()))
a = list(map(int, input().split()))
f = 0
ans = np.cumsum(a) - n
print((ans[-1]))
| n = int(eval(input()))
a = list(map(int, input().split()))
f = 0
ans = 0
for i in range(n):
ans += a[i]
print((ans - n))
| false | 14.285714 | [
"-import numpy as np",
"-",
"-ans = np.cumsum(a) - n",
"-print((ans[-1]))",
"+ans = 0",
"+for i in range(n):",
"+ ans += a[i]",
"+print((ans - n))"
] | false | 0.388552 | 0.036259 | 10.716111 | [
"s785536957",
"s008591694"
] |
u296150111 | p02773 | python | s156421948 | s590589572 | 559 | 481 | 20,676 | 33,416 | Accepted | Accepted | 13.95 | import sys
input=sys.stdin.readline
n=int(eval(input()))
p=[]
for i in range(n):
s=input().rstrip()
p.append(s)
p.sort()
ans=0
cnt=1
for i in range(n-1):
if p[i]==p[i+1]:
cnt+=1
else:
ans=max(ans,cnt)
cnt=1
ans=max(ans,cnt)
q=[]
for i in range(n-ans+1):
if p[i]==p[i+ans-1]:
q.append(p[i... | table={}
import sys
input=sys.stdin.readline
n=int(eval(input()))
ss=[]
for i in range(n):
s=input().rstrip()
if s in table:
table[s]+=1
else:
table[s]=1
ss.append(s)
ans=[]
saidai=max(table.values())
for i in range(len(ss)):
if table[ss[i]]==saidai:
ans.append(ss[i])
ans.sort()
for x in a... | 24 | 20 | 366 | 328 | import sys
input = sys.stdin.readline
n = int(eval(input()))
p = []
for i in range(n):
s = input().rstrip()
p.append(s)
p.sort()
ans = 0
cnt = 1
for i in range(n - 1):
if p[i] == p[i + 1]:
cnt += 1
else:
ans = max(ans, cnt)
cnt = 1
ans = max(ans, cnt)
q = []
for i in range(n - a... | table = {}
import sys
input = sys.stdin.readline
n = int(eval(input()))
ss = []
for i in range(n):
s = input().rstrip()
if s in table:
table[s] += 1
else:
table[s] = 1
ss.append(s)
ans = []
saidai = max(table.values())
for i in range(len(ss)):
if table[ss[i]] == saidai:
... | false | 16.666667 | [
"+table = {}",
"-p = []",
"+ss = []",
"- p.append(s)",
"-p.sort()",
"-ans = 0",
"-cnt = 1",
"-for i in range(n - 1):",
"- if p[i] == p[i + 1]:",
"- cnt += 1",
"+ if s in table:",
"+ table[s] += 1",
"- ans = max(ans, cnt)",
"- cnt = 1",
"-ans = max(ans... | false | 0.0377 | 0.076208 | 0.4947 | [
"s156421948",
"s590589572"
] |
u057109575 | p02715 | python | s710781804 | s378317316 | 179 | 101 | 74,240 | 69,004 | Accepted | Accepted | 43.58 | N, K = list(map(int, input().split()))
def func(n):
r = n
for i in range(2, n + 1):
if i ** 2 > n:
break
if n % i == 0:
r -= r // i
while n % i == 0:
n //= i
if n > 1:
r -= r // n
return r
MOD = 10... | N, K = list(map(int, input().split()))
MOD = 10 ** 9 + 7
cnt = [0] * (K + 1)
ans = 0
for x in reversed(list(range(1, K + 1))):
cnt[x] += pow(K // x, N, MOD)
for n in range(2, K + 1):
if x * n > K:
break
cnt[x] -= cnt[x * n]
cnt[x] %= MOD
ans += x * cnt[x] % MOD
... | 23 | 15 | 420 | 327 | N, K = list(map(int, input().split()))
def func(n):
r = n
for i in range(2, n + 1):
if i**2 > n:
break
if n % i == 0:
r -= r // i
while n % i == 0:
n //= i
if n > 1:
r -= r // n
return r
MOD = 10**9 + 7
ans = 0
for i in rang... | N, K = list(map(int, input().split()))
MOD = 10**9 + 7
cnt = [0] * (K + 1)
ans = 0
for x in reversed(list(range(1, K + 1))):
cnt[x] += pow(K // x, N, MOD)
for n in range(2, K + 1):
if x * n > K:
break
cnt[x] -= cnt[x * n]
cnt[x] %= MOD
ans += x * cnt[x] % MOD
print((ans % MOD... | false | 34.782609 | [
"-",
"-",
"-def func(n):",
"- r = n",
"- for i in range(2, n + 1):",
"- if i**2 > n:",
"+MOD = 10**9 + 7",
"+cnt = [0] * (K + 1)",
"+ans = 0",
"+for x in reversed(list(range(1, K + 1))):",
"+ cnt[x] += pow(K // x, N, MOD)",
"+ for n in range(2, K + 1):",
"+ if x * n... | false | 0.386817 | 0.133676 | 2.893683 | [
"s710781804",
"s378317316"
] |
u948524308 | p03239 | python | s680048762 | s587642909 | 20 | 17 | 2,940 | 2,940 | Accepted | Accepted | 15 | N, T = list(map(int, input().split()))
ans = 1001
for i in range(N):
c,t=list(map(int,input().split()))
if t<=T and c < ans:
ans = c
if ans >1000:
print("TLE")
else:
print(ans)
| N, T = list(map(int, input().split()))
c_ok=[]
for i in range(N):
c,t=list(map(int,input().split()))
if t<=T :
c_ok.append(c)
if c_ok==[]:
print("TLE")
else:
print((min(c_ok)))
| 12 | 12 | 202 | 200 | N, T = list(map(int, input().split()))
ans = 1001
for i in range(N):
c, t = list(map(int, input().split()))
if t <= T and c < ans:
ans = c
if ans > 1000:
print("TLE")
else:
print(ans)
| N, T = list(map(int, input().split()))
c_ok = []
for i in range(N):
c, t = list(map(int, input().split()))
if t <= T:
c_ok.append(c)
if c_ok == []:
print("TLE")
else:
print((min(c_ok)))
| false | 0 | [
"-ans = 1001",
"+c_ok = []",
"- if t <= T and c < ans:",
"- ans = c",
"-if ans > 1000:",
"+ if t <= T:",
"+ c_ok.append(c)",
"+if c_ok == []:",
"- print(ans)",
"+ print((min(c_ok)))"
] | false | 0.037117 | 0.077837 | 0.476857 | [
"s680048762",
"s587642909"
] |
u906501980 | p02660 | python | s965538090 | s415895864 | 91 | 72 | 9,468 | 65,844 | Accepted | Accepted | 20.88 | from collections import Counter
def get_prime_factors(x):
out = []
if x < 1:
return out
while not x%2:
out.append(2)
x //= 2
i = 3
while i*i <= x:
if not x%i:
out.append(i)
x //= i
else:
i += 2
if x != 1... | from collections import Counter
def get_prime_factors(x):
out = []
if x < 1:
return out
while not x%2:
out.append(2)
x //= 2
i = 3
while i*i <= x:
if not x%i:
out.append(i)
x //= i
else:
i += 2
if x != 1... | 35 | 35 | 659 | 663 | from collections import Counter
def get_prime_factors(x):
out = []
if x < 1:
return out
while not x % 2:
out.append(2)
x //= 2
i = 3
while i * i <= x:
if not x % i:
out.append(i)
x //= i
else:
i += 2
if x != 1:
... | from collections import Counter
def get_prime_factors(x):
out = []
if x < 1:
return out
while not x % 2:
out.append(2)
x //= 2
i = 3
while i * i <= x:
if not x % i:
out.append(i)
x //= i
else:
i += 2
if x != 1:
... | false | 0 | [
"+ ans = 0",
"- ans = 0",
"- ans += 1",
"+ ans += 1"
] | false | 0.038201 | 0.038371 | 0.995571 | [
"s965538090",
"s415895864"
] |
u282228874 | p03212 | python | s404259165 | s831361423 | 294 | 88 | 6,240 | 18,716 | Accepted | Accepted | 70.07 | from itertools import product
n = int(eval(input()))
num = ['','3','5','7']
A = set()
for i in product(num,repeat=9):
x = "".join(i)
if len(set(x)) == 3:
if (int(x) not in A) and (int(x) <= n):
A.add(int(x))
print((len(A))) | N = int(eval(input()))
num = ['3','5','7']
for i in range(len(str(N))-1):
num2 = []
for n in num:
num2.append(n+'3')
num2.append(n+'5')
num2.append(n+'7')
num2.append(n)
num = num2
cnt = 0
num = set(num)
for n in num:
if '3' in n and '5' in n and '7' in n:
... | 10 | 17 | 253 | 370 | from itertools import product
n = int(eval(input()))
num = ["", "3", "5", "7"]
A = set()
for i in product(num, repeat=9):
x = "".join(i)
if len(set(x)) == 3:
if (int(x) not in A) and (int(x) <= n):
A.add(int(x))
print((len(A)))
| N = int(eval(input()))
num = ["3", "5", "7"]
for i in range(len(str(N)) - 1):
num2 = []
for n in num:
num2.append(n + "3")
num2.append(n + "5")
num2.append(n + "7")
num2.append(n)
num = num2
cnt = 0
num = set(num)
for n in num:
if "3" in n and "5" in n and "7" in n:
... | false | 41.176471 | [
"-from itertools import product",
"-",
"-n = int(eval(input()))",
"-num = [\"\", \"3\", \"5\", \"7\"]",
"-A = set()",
"-for i in product(num, repeat=9):",
"- x = \"\".join(i)",
"- if len(set(x)) == 3:",
"- if (int(x) not in A) and (int(x) <= n):",
"- A.add(int(x))",
"-pri... | false | 0.525449 | 0.061507 | 8.542925 | [
"s404259165",
"s831361423"
] |
u054514819 | p03045 | python | s289198279 | s201612755 | 495 | 228 | 7,856 | 81,204 | Accepted | Accepted | 53.94 | N, M = list(map(int, input().split()))
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return se... | import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
N, M = mapint()
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x]... | 49 | 59 | 1,153 | 1,465 | N, M = list(map(int, input().split()))
class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
... | import sys
def input():
return sys.stdin.readline().strip()
def mapint():
return list(map(int, input().split()))
sys.setrecursionlimit(10**9)
N, M = mapint()
class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] ... | false | 16.949153 | [
"-N, M = list(map(int, input().split()))",
"+import sys",
"+",
"+",
"+def input():",
"+ return sys.stdin.readline().strip()",
"+",
"+",
"+def mapint():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+sys.setrecursionlimit(10**9)",
"+N, M = mapint()",
"+ def all_group_m... | false | 0.038217 | 0.038143 | 1.001959 | [
"s289198279",
"s201612755"
] |
u994521204 | p02537 | python | s900236709 | s764499876 | 521 | 477 | 136,084 | 103,628 | Accepted | Accepted | 8.45 | import sys
input = sys.stdin.buffer.readline
class SegmentTree:
ele = 0
func = max
# SEG木は1-index
# Aに関しては0-index
def __init__(self, n): # Aは0-idx
self.n = n
self.num = 2 ** ((self.n - 1).bit_length())
self.SEG = [self.ele] * (2 * self.num)
def searc... | import sys
input = sys.stdin.buffer.readline
n, k = list(map(int, input().split()))
max_n = 300000
num = 2 ** ((max_n - 1).bit_length())
SEG = [0] * (2 * num)
func = max
ele = 0
def update(idx, val):
idx += num
SEG[idx] = val
while idx > 0:
idx //= 2
SEG[idx] = func(SE... | 66 | 47 | 1,715 | 923 | import sys
input = sys.stdin.buffer.readline
class SegmentTree:
ele = 0
func = max
# SEG木は1-index
# Aに関しては0-index
def __init__(self, n): # Aは0-idx
self.n = n
self.num = 2 ** ((self.n - 1).bit_length())
self.SEG = [self.ele] * (2 * self.num)
def search(self, idx):
... | import sys
input = sys.stdin.buffer.readline
n, k = list(map(int, input().split()))
max_n = 300000
num = 2 ** ((max_n - 1).bit_length())
SEG = [0] * (2 * num)
func = max
ele = 0
def update(idx, val):
idx += num
SEG[idx] = val
while idx > 0:
idx //= 2
SEG[idx] = func(SEG[2 * idx], SEG[2 * ... | false | 28.787879 | [
"+n, k = list(map(int, input().split()))",
"+max_n = 300000",
"+num = 2 ** ((max_n - 1).bit_length())",
"+SEG = [0] * (2 * num)",
"+func = max",
"+ele = 0",
"-class SegmentTree:",
"- ele = 0",
"- func = max",
"- # SEG木は1-index",
"- # Aに関しては0-index",
"- def __init__(self, n): # ... | false | 0.336151 | 0.069051 | 4.868127 | [
"s900236709",
"s764499876"
] |
u156815136 | p03105 | python | s517167909 | s666582429 | 49 | 38 | 5,660 | 10,204 | Accepted | Accepted | 22.45 | from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
# d = m - k[i] -... | #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... | 30 | 31 | 661 | 773 | from statistics import median
# import collections
# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
# d = m - k[i] - k[j... | # from statistics import median
# import collections
# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations, permutations, accumulate, product # (string,3) 3回
# from collections import deque
from collections import deque, defaul... | false | 3.225806 | [
"-from statistics import median",
"-",
"+# from statistics import median",
"-from itertools import combinations # (string,3) 3回",
"-from collections import deque",
"-from collections import defaultdict",
"-import bisect",
"+from itertools import combinations, permutations, accumulate, product # (str... | false | 0.044236 | 0.045191 | 0.978856 | [
"s517167909",
"s666582429"
] |
u996749146 | p03341 | python | s729590026 | s962921197 | 563 | 464 | 29,692 | 29,696 | Accepted | Accepted | 17.58 | # https://beta.atcoder.jp/contests/arc098/tasks/arc098_a
# C - Attention
# C_Attention.py
N = int(eval(input()))
S = eval(input())
e = [0 for i in range(N)]
w = [0 for i in range(N)]
d = [0 for i in range(N)]
# 累積和を求める
for i in range(N):
# そこからE側の人で、Wを向くべきなのにEを向いている人
if i > 0:
w[i] +... | # https://beta.atcoder.jp/contests/arc098/tasks/arc098_a
# C - Attention
# C_Attention_beta.py
N = int(eval(input()))
S = eval(input())
e = [0 for i in range(N)]
w = [0 for i in range(N)]
d = [0 for i in range(N)]
# 累積和を求める
for i in range(N):
# そこからE側の人で、Wを向くべきなのにEを向いている人
if i > 0:
w... | 33 | 38 | 661 | 683 | # https://beta.atcoder.jp/contests/arc098/tasks/arc098_a
# C - Attention
# C_Attention.py
N = int(eval(input()))
S = eval(input())
e = [0 for i in range(N)]
w = [0 for i in range(N)]
d = [0 for i in range(N)]
# 累積和を求める
for i in range(N):
# そこからE側の人で、Wを向くべきなのにEを向いている人
if i > 0:
w[i] += w[i - 1]
if i ... | # https://beta.atcoder.jp/contests/arc098/tasks/arc098_a
# C - Attention
# C_Attention_beta.py
N = int(eval(input()))
S = eval(input())
e = [0 for i in range(N)]
w = [0 for i in range(N)]
d = [0 for i in range(N)]
# 累積和を求める
for i in range(N):
# そこからE側の人で、Wを向くべきなのにEを向いている人
if i > 0:
w[i] += w[i - 1]
... | false | 13.157895 | [
"-# C_Attention.py",
"+# C_Attention_beta.py",
"- # そこからW側の人で、Eを向くべきなのにWを向いている人",
"+# そこからW側の人で、Eを向くべきなのにWを向いている人",
"+for j in range(N):",
"+ i = N - 1 - j",
"+ if i < N - 1:",
"+ e[i] += e[i + 1]",
"- e[N - 1 - i] += e[N - 1 - (i - 1)]",
"- if i < N - 1:",
"- if... | false | 0.037818 | 0.047588 | 0.794691 | [
"s729590026",
"s962921197"
] |
u347640436 | p03634 | python | s509510529 | s705440416 | 1,075 | 928 | 68,800 | 55,608 | Accepted | Accepted | 13.67 | from heapq import heappop, heappush
N = int(eval(input()))
costs = {}
for _ in range(N - 1):
a, b, c = list(map(int, input().split()))
costs.setdefault(a, {})
costs[a][b] = c
costs.setdefault(b, {})
costs[b][a] = c
Q, K = list(map(int, input().split()))
d = [float('inf')] * (N + 1)
... | from collections import deque
N = int(eval(input()))
links = [[] for _ in range(N + 1)]
for _ in range(N - 1):
a, b, c = list(map(int, input().split()))
links[a].append((b, c))
links[b].append((a, c))
Q, K = list(map(int, input().split()))
d = [float('inf')] * (N + 1)
d[K] = 0
q = deque([K])... | 31 | 26 | 698 | 591 | from heapq import heappop, heappush
N = int(eval(input()))
costs = {}
for _ in range(N - 1):
a, b, c = list(map(int, input().split()))
costs.setdefault(a, {})
costs[a][b] = c
costs.setdefault(b, {})
costs[b][a] = c
Q, K = list(map(int, input().split()))
d = [float("inf")] * (N + 1)
d[K] = 0
# prev ... | from collections import deque
N = int(eval(input()))
links = [[] for _ in range(N + 1)]
for _ in range(N - 1):
a, b, c = list(map(int, input().split()))
links[a].append((b, c))
links[b].append((a, c))
Q, K = list(map(int, input().split()))
d = [float("inf")] * (N + 1)
d[K] = 0
q = deque([K])
while q:
i... | false | 16.129032 | [
"-from heapq import heappop, heappush",
"+from collections import deque",
"-costs = {}",
"+links = [[] for _ in range(N + 1)]",
"- costs.setdefault(a, {})",
"- costs[a][b] = c",
"- costs.setdefault(b, {})",
"- costs[b][a] = c",
"+ links[a].append((b, c))",
"+ links[b].append((a, ... | false | 0.074187 | 0.076477 | 0.970056 | [
"s509510529",
"s705440416"
] |
u992910889 | p03607 | python | s361359947 | s115368282 | 523 | 103 | 61,400 | 16,628 | Accepted | Accepted | 80.31 | 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 xor
import... | from collections import Counter, deque # https://note.nkmk.me/python-scipy-connected-components/
# 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... | 25 | 31 | 599 | 896 | 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 xor
import sys
s... | from collections import (
Counter,
deque,
) # https://note.nkmk.me/python-scipy-connected-components/
# from copy import copy, deepcopy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# i... | false | 19.354839 | [
"-from collections import Counter, deque",
"+from collections import (",
"+ Counter,",
"+ deque,",
"+) # https://note.nkmk.me/python-scipy-connected-components/",
"-# import numpy as np",
"+# import numpy as np # Pythonのみ!",
"+# import re",
"+# from scipy.sparse.csgraph import connected_comp... | false | 0.034336 | 0.036058 | 0.952243 | [
"s361359947",
"s115368282"
] |
u764215612 | p02690 | python | s485414197 | s269841280 | 34 | 31 | 9,312 | 9,432 | Accepted | Accepted | 8.82 | import math
def main():
x = int(eval(input()))
for i in range(-120,120):
for j in range(-120,120):
if math.pow(i, 5) - math.pow(j, 5) == x:
print((str(i) + ' ' + str(j)))
return
main() | import math
def main():
x = int(eval(input()))
for i in range(-118,120):
for j in range(-119,129):
if math.pow(i, 5) - math.pow(j, 5) == x:
print((str(i) + ' ' + str(j)))
return
main() | 9 | 9 | 214 | 214 | import math
def main():
x = int(eval(input()))
for i in range(-120, 120):
for j in range(-120, 120):
if math.pow(i, 5) - math.pow(j, 5) == x:
print((str(i) + " " + str(j)))
return
main()
| import math
def main():
x = int(eval(input()))
for i in range(-118, 120):
for j in range(-119, 129):
if math.pow(i, 5) - math.pow(j, 5) == x:
print((str(i) + " " + str(j)))
return
main()
| false | 0 | [
"- for i in range(-120, 120):",
"- for j in range(-120, 120):",
"+ for i in range(-118, 120):",
"+ for j in range(-119, 129):"
] | false | 0.049708 | 0.062981 | 0.789264 | [
"s485414197",
"s269841280"
] |
u597455618 | p02572 | python | s679227055 | s059911106 | 149 | 136 | 29,124 | 29,120 | Accepted | Accepted | 8.72 | import sys
from itertools import accumulate
n = int(sys.stdin.buffer.readline())
a = list(map(int, sys.stdin.buffer.readline().split()))
aa = list(accumulate(a))
MOD = 10**9+7
ans = 0
for i in range(n):
ans += a[i]*(aa[n-1] - aa[i]) % MOD
print((ans%MOD))
| import sys
from itertools import accumulate
n = int(sys.stdin.buffer.readline())
a = list(map(int, sys.stdin.buffer.readline().split()))
aa = list(accumulate(a))
MOD = 10**9+7
ans = 0
for i in range(n):
ans += a[i]*(aa[n-1] - aa[i])
print((ans%MOD))
| 10 | 10 | 267 | 261 | import sys
from itertools import accumulate
n = int(sys.stdin.buffer.readline())
a = list(map(int, sys.stdin.buffer.readline().split()))
aa = list(accumulate(a))
MOD = 10**9 + 7
ans = 0
for i in range(n):
ans += a[i] * (aa[n - 1] - aa[i]) % MOD
print((ans % MOD))
| import sys
from itertools import accumulate
n = int(sys.stdin.buffer.readline())
a = list(map(int, sys.stdin.buffer.readline().split()))
aa = list(accumulate(a))
MOD = 10**9 + 7
ans = 0
for i in range(n):
ans += a[i] * (aa[n - 1] - aa[i])
print((ans % MOD))
| false | 0 | [
"- ans += a[i] * (aa[n - 1] - aa[i]) % MOD",
"+ ans += a[i] * (aa[n - 1] - aa[i])"
] | false | 0.036135 | 0.10293 | 0.351064 | [
"s679227055",
"s059911106"
] |
u780475861 | p03647 | python | s057655392 | s248350398 | 290 | 154 | 19,168 | 41,936 | Accepted | Accepted | 46.9 | import sys
def main():
n, m = list(map(int, sys.stdin.readline().split()))
set1, setn = set(), set()
for _ in range(m):
i, j = list(map(int, sys.stdin.readline().split()))
if i == 1:
set1.add(j)
if j == n:
setn.add(i)
if set1 & setn:
print('POSSIBLE')
else:
pri... | import sys
def main():
n, m = list(map(int, sys.stdin.readline().split()))
lst = list(map(int, sys.stdin.read().split()))
set1, setn = set(), set()
for i, j in zip(lst, lst):
if i == 1:
set1.add(j)
if j == n:
setn.add(i)
if set1 & setn:
print('POSSIBLE')
else:
pr... | 20 | 20 | 366 | 367 | import sys
def main():
n, m = list(map(int, sys.stdin.readline().split()))
set1, setn = set(), set()
for _ in range(m):
i, j = list(map(int, sys.stdin.readline().split()))
if i == 1:
set1.add(j)
if j == n:
setn.add(i)
if set1 & setn:
print("POSSI... | import sys
def main():
n, m = list(map(int, sys.stdin.readline().split()))
lst = list(map(int, sys.stdin.read().split()))
set1, setn = set(), set()
for i, j in zip(lst, lst):
if i == 1:
set1.add(j)
if j == n:
setn.add(i)
if set1 & setn:
print("POSSIB... | false | 0 | [
"+ lst = list(map(int, sys.stdin.read().split()))",
"- for _ in range(m):",
"- i, j = list(map(int, sys.stdin.readline().split()))",
"+ for i, j in zip(lst, lst):"
] | false | 0.040779 | 0.032709 | 1.246726 | [
"s057655392",
"s248350398"
] |
u279460955 | p03806 | python | s031878184 | s288537434 | 727 | 613 | 73,468 | 73,816 | Accepted | Accepted | 15.68 | n, ma, mb = (int(x) for x in input().split())
ABC = [tuple(int(x) for x in input().split()) for _ in range(n)]
m = n // 2
D = dict()
E = dict()
for bit in range(1, 1<<m):
sum_a = 0
sum_b = 0
sum_c = 0
for i in range(m):
if bit & 1<<i:
a, b, c = ABC[i]
sum_a +=... | n, ma, mb = (int(x) for x in input().split())
ABC = [tuple(int(x) for x in input().split()) for _ in range(n)]
D1 = dict()
D2 = dict()
for (m, D, j) in ((n // 2, D1, 0), (n - n // 2, D2, n // 2)):
for bit in range(1, 1<<m):
sum_a = 0
sum_b = 0
sum_c = 0
for i in range(m):
... | 50 | 32 | 1,069 | 826 | n, ma, mb = (int(x) for x in input().split())
ABC = [tuple(int(x) for x in input().split()) for _ in range(n)]
m = n // 2
D = dict()
E = dict()
for bit in range(1, 1 << m):
sum_a = 0
sum_b = 0
sum_c = 0
for i in range(m):
if bit & 1 << i:
a, b, c = ABC[i]
sum_a += a
... | n, ma, mb = (int(x) for x in input().split())
ABC = [tuple(int(x) for x in input().split()) for _ in range(n)]
D1 = dict()
D2 = dict()
for (m, D, j) in ((n // 2, D1, 0), (n - n // 2, D2, n // 2)):
for bit in range(1, 1 << m):
sum_a = 0
sum_b = 0
sum_c = 0
for i in range(m):
... | false | 36 | [
"-m = n // 2",
"-D = dict()",
"-E = dict()",
"-for bit in range(1, 1 << m):",
"- sum_a = 0",
"- sum_b = 0",
"- sum_c = 0",
"- for i in range(m):",
"- if bit & 1 << i:",
"- a, b, c = ABC[i]",
"- sum_a += a",
"- sum_b += b",
"- sum... | false | 0.034824 | 0.039461 | 0.882494 | [
"s031878184",
"s288537434"
] |
u995004106 | p02659 | python | s068367071 | s335338496 | 133 | 104 | 72,616 | 72,692 | Accepted | Accepted | 21.8 | import math
import pprint
import fractions
import collections
import itertools
from decimal import *
A,B=list(map(str,input().split()))
#print(A*B)
getcontext().prec=40
A=int(A)
#print(Decimal(A)*Decimal(B))
A=str(A)
A=list(map(int,A))
b=list(str(B))
B=[0]*3
#print(A,b)
N=len(A) #Aの桁数
... | import math
import pprint
import fractions
import collections
import itertools
from decimal import *
A,B=list(map(str,input().split()))
A=int(A)
B=str(B)
num=int(B[0])*100+int(B[2])*10+int(B[3])
#print(A,num)
print(((A*num)//100))
| 52 | 12 | 1,022 | 234 | import math
import pprint
import fractions
import collections
import itertools
from decimal import *
A, B = list(map(str, input().split()))
# print(A*B)
getcontext().prec = 40
A = int(A)
# print(Decimal(A)*Decimal(B))
A = str(A)
A = list(map(int, A))
b = list(str(B))
B = [0] * 3
# print(A,b)
N = len(A) # Aの桁数
table =... | import math
import pprint
import fractions
import collections
import itertools
from decimal import *
A, B = list(map(str, input().split()))
A = int(A)
B = str(B)
num = int(B[0]) * 100 + int(B[2]) * 10 + int(B[3])
# print(A,num)
print(((A * num) // 100))
| false | 76.923077 | [
"-# print(A*B)",
"-getcontext().prec = 40",
"-# print(Decimal(A)*Decimal(B))",
"-A = str(A)",
"-A = list(map(int, A))",
"-b = list(str(B))",
"-B = [0] * 3",
"-# print(A,b)",
"-N = len(A) # Aの桁数",
"-table = [[0 for _ in range(len(A) + 1)] for _ in range(10)]",
"-for i in range(1, 10):",
"- ... | false | 0.039452 | 0.035872 | 1.099794 | [
"s068367071",
"s335338496"
] |
u561083515 | p02861 | python | s670209569 | s181065958 | 498 | 406 | 8,180 | 7,972 | Accepted | Accepted | 18.47 | N = int(eval(input()))
xy = [[int(i) for i in input().split()] for _ in range(N)]
from itertools import permutations
states = list(permutations(list(range(N))))
ans = 0
for state in states:
dist = 0
for i,n in enumerate(state):
if i == 0:
prev = xy[n]
continue
... | N = int(eval(input()))
xy = [[int(i) for i in input().split()] for _ in range(N)]
from itertools import permutations
from math import sqrt
states = list(permutations(list(range(N))))
ans = 0
for state in states:
dist = 0
for i,n in enumerate(state):
if i == 0:
prev = xy[n]
... | 21 | 22 | 472 | 493 | N = int(eval(input()))
xy = [[int(i) for i in input().split()] for _ in range(N)]
from itertools import permutations
states = list(permutations(list(range(N))))
ans = 0
for state in states:
dist = 0
for i, n in enumerate(state):
if i == 0:
prev = xy[n]
continue
now = xy[... | N = int(eval(input()))
xy = [[int(i) for i in input().split()] for _ in range(N)]
from itertools import permutations
from math import sqrt
states = list(permutations(list(range(N))))
ans = 0
for state in states:
dist = 0
for i, n in enumerate(state):
if i == 0:
prev = xy[n]
cont... | false | 4.545455 | [
"+from math import sqrt",
"- dist += pow(pow(prev[0] - now[0], 2) + pow(prev[1] - now[1], 2), 0.5)",
"+ dist += sqrt((prev[0] - now[0]) ** 2 + (prev[1] - now[1]) ** 2)"
] | false | 0.044348 | 0.044621 | 0.993883 | [
"s670209569",
"s181065958"
] |
u644907318 | p03476 | python | s393145645 | s517104110 | 1,084 | 424 | 55,108 | 86,412 | Accepted | Accepted | 60.89 | INFTY = 10**5+1
P = [1 for _ in range(INFTY)]
P[0]=P[1]=0
for i in range(2,int(INFTY**0.5)+1):
for j in range(i*i,INFTY,i):
P[j] = 0
R = [0 for _ in range(INFTY)]
for i in range(INFTY):
if i%2==1:
if P[i]==1 and P[(i+1)//2]==1:
R[i] = 1
A = [0 for _ in range(INFTY+1)]
for... | P = [1 for _ in range(10**5)]
P[0]=0
P[1]=0
for i in range(2,int((10**5)**0.5)+1):
for j in range(i*i,10**5,i):
P[j]=0
Q = []
for i in range(3,10**5,2):
if P[i]==1 and P[(i+1)//2]==1:
Q.append(i)
A = [0 for _ in range(10**5+1)]
for q in Q:
A[q] = 1
for i in range(1,10**5+1):
... | 18 | 19 | 461 | 434 | INFTY = 10**5 + 1
P = [1 for _ in range(INFTY)]
P[0] = P[1] = 0
for i in range(2, int(INFTY**0.5) + 1):
for j in range(i * i, INFTY, i):
P[j] = 0
R = [0 for _ in range(INFTY)]
for i in range(INFTY):
if i % 2 == 1:
if P[i] == 1 and P[(i + 1) // 2] == 1:
R[i] = 1
A = [0 for _ in range(... | P = [1 for _ in range(10**5)]
P[0] = 0
P[1] = 0
for i in range(2, int((10**5) ** 0.5) + 1):
for j in range(i * i, 10**5, i):
P[j] = 0
Q = []
for i in range(3, 10**5, 2):
if P[i] == 1 and P[(i + 1) // 2] == 1:
Q.append(i)
A = [0 for _ in range(10**5 + 1)]
for q in Q:
A[q] = 1
for i in range(1... | false | 5.263158 | [
"-INFTY = 10**5 + 1",
"-P = [1 for _ in range(INFTY)]",
"-P[0] = P[1] = 0",
"-for i in range(2, int(INFTY**0.5) + 1):",
"- for j in range(i * i, INFTY, i):",
"+P = [1 for _ in range(10**5)]",
"+P[0] = 0",
"+P[1] = 0",
"+for i in range(2, int((10**5) ** 0.5) + 1):",
"+ for j in range(i * i, 1... | false | 0.226159 | 0.28054 | 0.806155 | [
"s393145645",
"s517104110"
] |
u532966492 | p02868 | python | s330849926 | s603100357 | 1,616 | 1,002 | 93,272 | 79,072 | Accepted | Accepted | 38 | def main():
class segtree():
def __init__(self,base,monoid,ini):#self,モノイド,元の配列
#ini:上限(下限),base:元の配列,monoid:モノイド,tree:セグ木,depth:treeの深さ,
#basesize:baseの要素数,treesize:treeの要素数,num:treesize-basesize
# 初期値(上限とか下限)を決定
self.ini=ini
... | def main():
from sys import stdin
input = stdin.readline
import numpy as np
n, m = list(map(int, input().split()))
abc = [list(map(int, input().split())) for _ in [0]*m]
g = [[] for _ in [0]*n]
[g[u-1].append([v-1, c]) for u, v, c in abc]
[g[i+1].append([i, 0]) for i in range(n... | 119 | 29 | 4,269 | 690 | def main():
class segtree:
def __init__(self, base, monoid, ini): # self,モノイド,元の配列
# ini:上限(下限),base:元の配列,monoid:モノイド,tree:セグ木,depth:treeの深さ,
# basesize:baseの要素数,treesize:treeの要素数,num:treesize-basesize
# 初期値(上限とか下限)を決定
self.ini = ini
# セグ木の要素数(num... | def main():
from sys import stdin
input = stdin.readline
import numpy as np
n, m = list(map(int, input().split()))
abc = [list(map(int, input().split())) for _ in [0] * m]
g = [[] for _ in [0] * n]
[g[u - 1].append([v - 1, c]) for u, v, c in abc]
[g[i + 1].append([i, 0]) for i in range... | false | 75.630252 | [
"- class segtree:",
"- def __init__(self, base, monoid, ini): # self,モノイド,元の配列",
"- # ini:上限(下限),base:元の配列,monoid:モノイド,tree:セグ木,depth:treeの深さ,",
"- # basesize:baseの要素数,treesize:treeの要素数,num:treesize-basesize",
"- # 初期値(上限とか下限)を決定",
"- self.ini = ini",... | false | 0.039354 | 0.177309 | 0.221953 | [
"s330849926",
"s603100357"
] |
u367701763 | p02702 | python | s631340416 | s969408143 | 161 | 86 | 83,608 | 82,820 | Accepted | Accepted | 46.58 | # https://atcoder.jp/contests/abc164/tasks/abc164_d
from operator import mul
from functools import reduce
from collections import defaultdict
def combination(n, r):
if not 0 <= r <= n: return 0
r = min(r, n - r)
numer = reduce(mul, list(range(n, n - r, -1)), 1)
denom = reduce(mul, list(range... | # https://atcoder.jp/contests/abc164/tasks/abc164_d
import sys
input = sys.stdin.readline
S = input().rstrip()
res = 0
T = [0]
x = 0
p = 1
L = len(S)
MOD = 2019
for i, s in zip(list(range(L)),reversed(S)):
""" 累積和 """
x = (int(s)*p + x)%MOD
p = p*10%MOD
T.append(x)
reminder = ... | 33 | 29 | 662 | 432 | # https://atcoder.jp/contests/abc164/tasks/abc164_d
from operator import mul
from functools import reduce
from collections import defaultdict
def combination(n, r):
if not 0 <= r <= n:
return 0
r = min(r, n - r)
numer = reduce(mul, list(range(n, n - r, -1)), 1)
denom = reduce(mul, list(range(1... | # https://atcoder.jp/contests/abc164/tasks/abc164_d
import sys
input = sys.stdin.readline
S = input().rstrip()
res = 0
T = [0]
x = 0
p = 1
L = len(S)
MOD = 2019
for i, s in zip(list(range(L)), reversed(S)):
"""累積和"""
x = (int(s) * p + x) % MOD
p = p * 10 % MOD
T.append(x)
reminder = [0] * 2019
for i in... | false | 12.121212 | [
"-from operator import mul",
"-from functools import reduce",
"-from collections import defaultdict",
"+import sys",
"-",
"-def combination(n, r):",
"- if not 0 <= r <= n:",
"- return 0",
"- r = min(r, n - r)",
"- numer = reduce(mul, list(range(n, n - r, -1)), 1)",
"- denom = ... | false | 0.034018 | 0.063813 | 0.533085 | [
"s631340416",
"s969408143"
] |
u788703383 | p03628 | python | s260706529 | s391315031 | 182 | 167 | 38,408 | 38,384 | Accepted | Accepted | 8.24 | MOD = 10**9+7
n = int(eval(input()))
s = eval(input())
p = eval(input())
ans = 0
f = 0
i = 0
while i < n:
if i > n:break
if s[i] == p[i]:
if i == 0:
ans = 3
else:
if f == 1:
ans *= 1
else:
ans *= 2
f = 0... | MOD = 10**9+7
n = int(eval(input()))
s = eval(input())
p = eval(input())
ans = 0
f = 0
i = 0
two = False
while i < n:
if i == 0:
if s[i] == p[i]:
ans = 3
else:
ans = 6
i += 1
two = True
i += 1
continue
if i >= n:br... | 31 | 35 | 540 | 584 | MOD = 10**9 + 7
n = int(eval(input()))
s = eval(input())
p = eval(input())
ans = 0
f = 0
i = 0
while i < n:
if i > n:
break
if s[i] == p[i]:
if i == 0:
ans = 3
else:
if f == 1:
ans *= 1
else:
ans *= 2
f = 0
e... | MOD = 10**9 + 7
n = int(eval(input()))
s = eval(input())
p = eval(input())
ans = 0
f = 0
i = 0
two = False
while i < n:
if i == 0:
if s[i] == p[i]:
ans = 3
else:
ans = 6
i += 1
two = True
i += 1
continue
if i >= n:
break
... | false | 11.428571 | [
"+two = False",
"- if i > n:",
"+ if i == 0:",
"+ if s[i] == p[i]:",
"+ ans = 3",
"+ else:",
"+ ans = 6",
"+ i += 1",
"+ two = True",
"+ i += 1",
"+ continue",
"+ if i >= n:",
"- if i == 0:",
"- ... | false | 0.037792 | 0.067794 | 0.557448 | [
"s260706529",
"s391315031"
] |
u124498235 | p03680 | python | s139764103 | s683686713 | 210 | 185 | 7,884 | 7,084 | Accepted | Accepted | 11.9 | n = int(eval(input()))
a = [int(eval(input())) for i in range(n)]
chk = [False for i in range(n)]
c = 0
d = 0
while True:
if chk[c]:
print((-1))
exit()
else:
chk[c] = True
if c == 1:
print (d)
exit()
c = a[c]-1
d += 1 | n = int(eval(input()))
a = [int(eval(input())) for i in range(n)]
c = a[0]
for i in range(n):
if c == 2:
print((i+1))
exit()
c = a[c-1]
print((-1)) | 17 | 10 | 239 | 149 | n = int(eval(input()))
a = [int(eval(input())) for i in range(n)]
chk = [False for i in range(n)]
c = 0
d = 0
while True:
if chk[c]:
print((-1))
exit()
else:
chk[c] = True
if c == 1:
print(d)
exit()
c = a[c] - 1
d += 1
| n = int(eval(input()))
a = [int(eval(input())) for i in range(n)]
c = a[0]
for i in range(n):
if c == 2:
print((i + 1))
exit()
c = a[c - 1]
print((-1))
| false | 41.176471 | [
"-chk = [False for i in range(n)]",
"-c = 0",
"-d = 0",
"-while True:",
"- if chk[c]:",
"- print((-1))",
"+c = a[0]",
"+for i in range(n):",
"+ if c == 2:",
"+ print((i + 1))",
"- else:",
"- chk[c] = True",
"- if c == 1:",
"- print(d)",
"- ... | false | 0.048161 | 0.04402 | 1.094061 | [
"s139764103",
"s683686713"
] |
u576917603 | p02813 | python | s288267979 | s337055716 | 57 | 33 | 15,092 | 8,052 | Accepted | Accepted | 42.11 | n=int(eval(input()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
aa=()
import itertools
c=list(itertools.permutations(list(range(1,n+1))))
cc=[]
for i in c:
cc.append(list(i))
for x,i in enumerate(cc):
if a==i:
aa=x
if b==i:
bb=x
print((abs(aa-bb))) | n=int(eval(input()))
a=tuple([int(x)-1 for x in input().split()])
b=tuple([int(x)-1 for x in input().split()])
import itertools as it
pe=list(it.permutations(list(range(n)),n))
x,y=0,0
for ind,i in enumerate(pe):
if i==a:
x=ind
if i==b:
y=ind
print((abs(x-y))) | 15 | 14 | 299 | 291 | n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
aa = ()
import itertools
c = list(itertools.permutations(list(range(1, n + 1))))
cc = []
for i in c:
cc.append(list(i))
for x, i in enumerate(cc):
if a == i:
aa = x
if b == i:
bb = x
print((abs(aa... | n = int(eval(input()))
a = tuple([int(x) - 1 for x in input().split()])
b = tuple([int(x) - 1 for x in input().split()])
import itertools as it
pe = list(it.permutations(list(range(n)), n))
x, y = 0, 0
for ind, i in enumerate(pe):
if i == a:
x = ind
if i == b:
y = ind
print((abs(x - y)))
| false | 6.666667 | [
"-a = list(map(int, input().split()))",
"-b = list(map(int, input().split()))",
"-aa = ()",
"-import itertools",
"+a = tuple([int(x) - 1 for x in input().split()])",
"+b = tuple([int(x) - 1 for x in input().split()])",
"+import itertools as it",
"-c = list(itertools.permutations(list(range(1, n + 1)))... | false | 0.043869 | 0.034287 | 1.279456 | [
"s288267979",
"s337055716"
] |
u239917977 | p03160 | python | s498289036 | s373276350 | 246 | 156 | 52,028 | 13,868 | Accepted | Accepted | 36.59 | def main():
import sys
input = sys.stdin.readline
N = int(eval(input()))
H = list(map(int, input().split()))
inf = float("inf")
dp = [inf]*N
dp[0] = 0
step1, step2 = inf, inf
for i in range(1, N):
step1 = abs(H[i-1]-H[i]) + dp[i-1]
if i >= 2:
... | def main():
import sys
input = sys.stdin.readline
N = int(eval(input()))
H = list(map(int, input().split()))
inf = float("inf")
dp = [inf]*N
dp[0] = 0
for i in range(N-1):
dp[i+1] = min(dp[i+1], dp[i] + abs(H[i+1]-H[i]))
if i != N-2:
dp[i+2]... | 25 | 21 | 489 | 419 | def main():
import sys
input = sys.stdin.readline
N = int(eval(input()))
H = list(map(int, input().split()))
inf = float("inf")
dp = [inf] * N
dp[0] = 0
step1, step2 = inf, inf
for i in range(1, N):
step1 = abs(H[i - 1] - H[i]) + dp[i - 1]
if i >= 2:
step... | def main():
import sys
input = sys.stdin.readline
N = int(eval(input()))
H = list(map(int, input().split()))
inf = float("inf")
dp = [inf] * N
dp[0] = 0
for i in range(N - 1):
dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i + 1] - H[i]))
if i != N - 2:
dp[i + 2] =... | false | 16 | [
"- step1, step2 = inf, inf",
"- for i in range(1, N):",
"- step1 = abs(H[i - 1] - H[i]) + dp[i - 1]",
"- if i >= 2:",
"- step2 = abs(H[i - 2] - H[i]) + dp[i - 2]",
"- step = min(step1, step2)",
"- dp[i] = min(dp[i], step)",
"+ for i in range(N - 1):",
... | false | 0.03599 | 0.041972 | 0.857465 | [
"s498289036",
"s373276350"
] |
u952656646 | p03031 | python | s326160391 | s222399413 | 156 | 37 | 12,396 | 9,140 | Accepted | Accepted | 76.28 | import numpy as np
N, M = list(map(int, input().split()))
D = [0]*M
for i in range(M):
temp = list(map(int, input().split()))
for j in temp[1:]:
D[i] += 2**(j-1)
p = list(map(int, input().split()))
ans = 0
for s in range(2**N):
temp = True
for i,d in enumerate(D):
temp &= bi... | N, M = list(map(int, input().split()))
S = [0]*M
for i in range(M):
s = list(map(int, input().split()))
for j in s[1:]:
S[i] += 2**(j-1)
p = list(map(int, input().split()))
ans = 0
for b in range(2**N):
tmp = True
for i, s in enumerate(S):
tmp &= bin(b&s).count('1')%2==p[i]
... | 16 | 15 | 383 | 354 | import numpy as np
N, M = list(map(int, input().split()))
D = [0] * M
for i in range(M):
temp = list(map(int, input().split()))
for j in temp[1:]:
D[i] += 2 ** (j - 1)
p = list(map(int, input().split()))
ans = 0
for s in range(2**N):
temp = True
for i, d in enumerate(D):
temp &= bin(s &... | N, M = list(map(int, input().split()))
S = [0] * M
for i in range(M):
s = list(map(int, input().split()))
for j in s[1:]:
S[i] += 2 ** (j - 1)
p = list(map(int, input().split()))
ans = 0
for b in range(2**N):
tmp = True
for i, s in enumerate(S):
tmp &= bin(b & s).count("1") % 2 == p[i]
... | false | 6.25 | [
"-import numpy as np",
"-",
"-D = [0] * M",
"+S = [0] * M",
"- temp = list(map(int, input().split()))",
"- for j in temp[1:]:",
"- D[i] += 2 ** (j - 1)",
"+ s = list(map(int, input().split()))",
"+ for j in s[1:]:",
"+ S[i] += 2 ** (j - 1)",
"-for s in range(2**N):",
... | false | 0.047107 | 0.006732 | 6.997255 | [
"s326160391",
"s222399413"
] |
u357751375 | p03835 | python | s711399508 | s723106907 | 1,315 | 1,192 | 9,116 | 9,052 | Accepted | Accepted | 9.35 | k,s = list(map(int,input().split()))
t = 0
for i in range(k+1):
for j in range(k+1):
if k >= s - i - j and 0 <= s - i - j:
t += 1
print(t) | k,s = list(map(int,input().split()))
ans = 0
for x in range(k+1):
for y in range(k+1):
z = s - (x + y)
if 0 <= z <= k:
ans += 1
print(ans) | 9 | 8 | 166 | 171 | k, s = list(map(int, input().split()))
t = 0
for i in range(k + 1):
for j in range(k + 1):
if k >= s - i - j and 0 <= s - i - j:
t += 1
print(t)
| k, s = list(map(int, input().split()))
ans = 0
for x in range(k + 1):
for y in range(k + 1):
z = s - (x + y)
if 0 <= z <= k:
ans += 1
print(ans)
| false | 11.111111 | [
"-t = 0",
"-for i in range(k + 1):",
"- for j in range(k + 1):",
"- if k >= s - i - j and 0 <= s - i - j:",
"- t += 1",
"-print(t)",
"+ans = 0",
"+for x in range(k + 1):",
"+ for y in range(k + 1):",
"+ z = s - (x + y)",
"+ if 0 <= z <= k:",
"+ ... | false | 0.113196 | 0.040837 | 2.771885 | [
"s711399508",
"s723106907"
] |
u554784585 | p02959 | python | s882749976 | s051147378 | 315 | 214 | 24,832 | 24,252 | Accepted | Accepted | 32.06 | N=int(eval(input()))
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=0
for i in range(N):
if i%2==0:
if A[int(i/2)]>=B[int(i/2)]:
A[int(i/2)]-=B[int(i/2)]
ans+=B[int(i/2)]
B[int(i/2)]=0
else:
B[int(i/2)]-=A[int(i/2)]
... | N=int(eval(input()))
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=0
for i in range(N):
if i%2==0:
if A[i//2]>=B[i//2]:
A[i//2]-=B[i//2]
ans+=B[i//2]
B[i//2]=0
else:
B[i//2]-=A[i//2]
ans+=A[i//2]
... | 42 | 42 | 1,205 | 1,045 | N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
if i % 2 == 0:
if A[int(i / 2)] >= B[int(i / 2)]:
A[int(i / 2)] -= B[int(i / 2)]
ans += B[int(i / 2)]
B[int(i / 2)] = 0
else:
B[in... | N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
if i % 2 == 0:
if A[i // 2] >= B[i // 2]:
A[i // 2] -= B[i // 2]
ans += B[i // 2]
B[i // 2] = 0
else:
B[i // 2] -= A[i // 2]
... | false | 0 | [
"- if A[int(i / 2)] >= B[int(i / 2)]:",
"- A[int(i / 2)] -= B[int(i / 2)]",
"- ans += B[int(i / 2)]",
"- B[int(i / 2)] = 0",
"+ if A[i // 2] >= B[i // 2]:",
"+ A[i // 2] -= B[i // 2]",
"+ ans += B[i // 2]",
"+ B[i // 2] = ... | false | 0.036939 | 0.079295 | 0.465844 | [
"s882749976",
"s051147378"
] |
u588341295 | p03854 | python | s129159168 | s335794214 | 132 | 59 | 3,956 | 4,084 | Accepted | Accepted | 55.3 | # -*- coding: utf-8 -*-
""" 逆順使わないでDPでやる版 """
S = eval(input())
dp = [False] * (len(S)+1)
# 0文字地点は遡る用にTrueにしておく
dp[0] = True
for i in range(1, len(dp)):
if i-5 >= 0:
if S[i-5:i] == "dream" or S[i-5:i] == "erase":
# 条件に当てはまったら、文字数分遡って有効な文字列が続いているか確認
if dp[i-5]:
... | # -*- coding: utf-8 -*-
import sys
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in ... | 29 | 40 | 613 | 1,096 | # -*- coding: utf-8 -*-
""" 逆順使わないでDPでやる版 """
S = eval(input())
dp = [False] * (len(S) + 1)
# 0文字地点は遡る用にTrueにしておく
dp[0] = True
for i in range(1, len(dp)):
if i - 5 >= 0:
if S[i - 5 : i] == "dream" or S[i - 5 : i] == "erase":
# 条件に当てはまったら、文字数分遡って有効な文字列が続いているか確認
if dp[i - 5]:
... | # -*- coding: utf-8 -*-
import sys
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [[c] * b for i in range(a)]
def list3d(a, b, c, d):
return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e):
return [[[[e] * d for j in range(c)] for j in rang... | false | 27.5 | [
"-\"\"\" 逆順使わないでDPでやる版 \"\"\"",
"+import sys",
"+",
"+",
"+def input():",
"+ return sys.stdin.readline().strip()",
"+",
"+",
"+def list2d(a, b, c):",
"+ return [[c] * b for i in range(a)]",
"+",
"+",
"+def list3d(a, b, c, d):",
"+ return [[[d] * c for j in range(b)] for i in range... | false | 0.046916 | 0.046021 | 1.019445 | [
"s129159168",
"s335794214"
] |
u586759271 | p02573 | python | s680056814 | s528955737 | 531 | 427 | 120,776 | 82,800 | Accepted | Accepted | 19.59 | N,M = list(map(int,input().split()))
AB = [None]*M
for i in range(M):
a,b = list(map(int,input().split()))
if a>b:
a,b=b,a
AB[i] = (a-1,b-1)
AB=set(AB)
tree=[[] for _ in range(N)]
for a,b in AB:
tree[a].append(b)
tree[b].append(a) #aがbの親、とかが保証されてれば不要。
from coll... | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
... | 38 | 55 | 856 | 1,399 | N, M = list(map(int, input().split()))
AB = [None] * M
for i in range(M):
a, b = list(map(int, input().split()))
if a > b:
a, b = b, a
AB[i] = (a - 1, b - 1)
AB = set(AB)
tree = [[] for _ in range(N)]
for a, b in AB:
tree[a].append(b)
tree[b].append(a) # aがbの親、とかが保証されてれば不要。
from collections... | class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = se... | false | 30.909091 | [
"+class UnionFind:",
"+ def __init__(self, n):",
"+ self.n = n",
"+ self.parents = [-1] * n",
"+",
"+ def find(self, x):",
"+ if self.parents[x] < 0:",
"+ return x",
"+ else:",
"+ self.parents[x] = self.find(self.parents[x])",
"+ ... | false | 0.079439 | 0.084124 | 0.944302 | [
"s680056814",
"s528955737"
] |
u535803878 | p02925 | python | s772166029 | s618529734 | 1,584 | 745 | 287,492 | 180,108 | Accepted | Accepted | 52.97 | import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")
n = int(eval(input()))
a = [list([int(x)-1 for x in input().split()]) for _ in range(n)]
N = n*(n-1)//2
index = {}
ind = 0
from collections import defaultdict
ns = d... | import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")
n = int(eval(input()))
a = [list([int(x)-1 for x in input().split()]) for _ in range(n)]
N = n*(n-1)//2
index = [[0]*(n) for i in range(n)]
ind = 0
from collections i... | 62 | 64 | 1,449 | 1,544 | import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x + "\n")
n = int(eval(input()))
a = [list([int(x) - 1 for x in input().split()]) for _ in range(n)]
N = n * (n - 1) // 2
index = {}
ind = 0
from collections import defaultdict
ns = defa... | import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x + "\n")
n = int(eval(input()))
a = [list([int(x) - 1 for x in input().split()]) for _ in range(n)]
N = n * (n - 1) // 2
index = [[0] * (n) for i in range(n)]
ind = 0
from collections im... | false | 3.125 | [
"-index = {}",
"+index = [[0] * (n) for i in range(n)]",
"- index[i, j] = ind",
"- index[j, i] = ind",
"+ index[i][j] = ind",
"+ index[j][i] = ind",
"- u = index[i, a[i][j]]",
"- v = index[i, a[i][j + 1]]",
"+ u = index[i][a[i][j]]",
"+ v = i... | false | 0.056277 | 0.06892 | 0.816561 | [
"s772166029",
"s618529734"
] |
u185896732 | p02720 | python | s419323224 | s916523266 | 387 | 164 | 13,248 | 17,004 | Accepted | Accepted | 57.62 | import sys
from collections import deque
input=sys.stdin.readline
sys.setrecursionlimit(10**6)
lunlun=deque()
def dfs(now):
if len(now)>10:return
lunlun.append(int(now))
l=now[-1]
if l!="0":
dfs(now+str(int(l)-1))
if l!="9":
dfs(now+str(int(l)+1))
dfs(now+l... | import sys
from collections import deque
input=sys.stdin.readline
sys.setrecursionlimit(10**6)
def main():
k=int(input().rstrip())
lunlun=deque([str(i) for i in range(1,10)])
for _ in range(k-1):
now=lunlun.popleft()
last=now[-1]
if last!="0":
lunlun.append(n... | 24 | 21 | 420 | 517 | import sys
from collections import deque
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
lunlun = deque()
def dfs(now):
if len(now) > 10:
return
lunlun.append(int(now))
l = now[-1]
if l != "0":
dfs(now + str(int(l) - 1))
if l != "9":
dfs(now + str(int(l) + 1))
... | import sys
from collections import deque
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
def main():
k = int(input().rstrip())
lunlun = deque([str(i) for i in range(1, 10)])
for _ in range(k - 1):
now = lunlun.popleft()
last = now[-1]
if last != "0":
lunlun.app... | false | 12.5 | [
"-lunlun = deque()",
"-def dfs(now):",
"- if len(now) > 10:",
"- return",
"- lunlun.append(int(now))",
"- l = now[-1]",
"- if l != \"0\":",
"- dfs(now + str(int(l) - 1))",
"- if l != \"9\":",
"- dfs(now + str(int(l) + 1))",
"- dfs(now + l)",
"+def main():... | false | 1.210903 | 0.07044 | 17.190604 | [
"s419323224",
"s916523266"
] |
u072717685 | p02580 | python | s920156138 | s918033118 | 604 | 310 | 280,916 | 181,800 | Accepted | Accepted | 48.68 | import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import defaultdict
def main():
h, w, m = list(map(int, input().split()))
rows = defaultdict(int)
cols = defaultdict(int)
d1 = lambda :defaultdict(int)
d2 = defaultdict(d1)
m = list(map(int, read().split()... | import sys
read = sys.stdin.read
#readlines = sys.stdin.readlines
def main():
h, w, m = list(map(int, input().split()))
b_row = [0] * h
b_col = [0] * w
b_coor = set()
m = list(map(int, read().split()))
for a, b in zip(m, m):
a -= 1
b -= 1
b_row[a] += 1
... | 32 | 30 | 809 | 758 | import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import defaultdict
def main():
h, w, m = list(map(int, input().split()))
rows = defaultdict(int)
cols = defaultdict(int)
d1 = lambda: defaultdict(int)
d2 = defaultdict(d1)
m = list(map(int, read().split()))
... | import sys
read = sys.stdin.read
# readlines = sys.stdin.readlines
def main():
h, w, m = list(map(int, input().split()))
b_row = [0] * h
b_col = [0] * w
b_coor = set()
m = list(map(int, read().split()))
for a, b in zip(m, m):
a -= 1
b -= 1
b_row[a] += 1
b_col[b] ... | false | 6.25 | [
"-readlines = sys.stdin.readlines",
"-from collections import defaultdict",
"-",
"-",
"+# readlines = sys.stdin.readlines",
"- rows = defaultdict(int)",
"- cols = defaultdict(int)",
"- d1 = lambda: defaultdict(int)",
"- d2 = defaultdict(d1)",
"+ b_row = [0] * h",
"+ b_col = [0]... | false | 0.038552 | 0.037239 | 1.035276 | [
"s920156138",
"s918033118"
] |
u652907854 | p03852 | python | s956519090 | s315770789 | 72 | 65 | 61,784 | 61,484 | Accepted | Accepted | 9.72 | # li = sorted(list(map(int, input().split())))
# n, m = map(int, input().split())
c = input()
print("vowel") if c in "aeiou" else print("consonant")
| print("vowel") if input() in "aeiou" else print("consonant")
| 4 | 1 | 151 | 60 | # li = sorted(list(map(int, input().split())))
# n, m = map(int, input().split())
c = input()
print("vowel") if c in "aeiou" else print("consonant")
| print("vowel") if input() in "aeiou" else print("consonant")
| false | 75 | [
"-# li = sorted(list(map(int, input().split())))",
"-# n, m = map(int, input().split())",
"-c = input()",
"-print(\"vowel\") if c in \"aeiou\" else print(\"consonant\")",
"+print(\"vowel\") if input() in \"aeiou\" else print(\"consonant\")"
] | false | 0.095741 | 0.03795 | 2.522832 | [
"s956519090",
"s315770789"
] |
u046158516 | p04015 | python | s504080879 | s852360284 | 194 | 65 | 42,716 | 68,732 | Accepted | Accepted | 66.49 | n,a=list(map(int,input().split()))
x=list(map(int,input().split()))
for i in range(n):
x[i]-=a
dp=[]
for i in range(n+1):
dp.append([])
for i in range(6000):
dp[-1].append(0)
dp[0][3000]=1
for i in range(n):
for j in range(6000):
if j+x[i]<6000 and j+x[i]>=0:
dp[i+1][j+x[i]]+=dp[i][j]... | n,a=list(map(int,input().split()))
x=list(map(int,input().split()))
dic={}
dic2=dic.copy()
for i in range(n):
for j in dic:
if j+x[i]-a in dic2:
dic2[j+x[i]-a]+=dic[j]
else:
dic2[j+x[i]-a]=dic[j]
if x[i]-a in dic2:
dic2[x[i]-a]+=1
else:
dic2[x[i]-a]=1
dic=dic2.copy()
i... | 16 | 19 | 365 | 361 | n, a = list(map(int, input().split()))
x = list(map(int, input().split()))
for i in range(n):
x[i] -= a
dp = []
for i in range(n + 1):
dp.append([])
for i in range(6000):
dp[-1].append(0)
dp[0][3000] = 1
for i in range(n):
for j in range(6000):
if j + x[i] < 6000 and j + x[i] >= 0:
... | n, a = list(map(int, input().split()))
x = list(map(int, input().split()))
dic = {}
dic2 = dic.copy()
for i in range(n):
for j in dic:
if j + x[i] - a in dic2:
dic2[j + x[i] - a] += dic[j]
else:
dic2[j + x[i] - a] = dic[j]
if x[i] - a in dic2:
dic2[x[i] - a] += 1
... | false | 15.789474 | [
"+dic = {}",
"+dic2 = dic.copy()",
"- x[i] -= a",
"-dp = []",
"-for i in range(n + 1):",
"- dp.append([])",
"- for i in range(6000):",
"- dp[-1].append(0)",
"-dp[0][3000] = 1",
"-for i in range(n):",
"- for j in range(6000):",
"- if j + x[i] < 6000 and j + x[i] >= 0:"... | false | 0.441714 | 0.101314 | 4.359864 | [
"s504080879",
"s852360284"
] |
u965602776 | p03112 | python | s091775032 | s043633301 | 1,478 | 1,167 | 80,856 | 18,000 | Accepted | Accepted | 21.04 | import bisect
from itertools import product
I = lambda n: [int(eval(input())) for _ in range(n)]
def f(S, x):
p = bisect.bisect_left(S, x)
return [S[p-1], S[p]]
g = lambda x, s, t: abs(x-s)+abs(s-t)
INF = 10**11
a, b, q = list(map(int, input().split()))
S, T, X = [-INF]+I(a)+[INF], [-INF]+I(b)+[INF], I... | from bisect import bisect_left
from itertools import product
I = lambda n: [int(eval(input())) for _ in range(n)]
def f(S, x):
p = bisect_left(S, x)
return [S[p-1], S[p]]
g = lambda x, s, t: abs(x-s)+abs(s-t)
INF = 10**11
a, b, q = list(map(int, input().split()))
S, T, X = [-INF]+I(a)+[INF], [-INF]+I(b... | 15 | 15 | 451 | 461 | import bisect
from itertools import product
I = lambda n: [int(eval(input())) for _ in range(n)]
def f(S, x):
p = bisect.bisect_left(S, x)
return [S[p - 1], S[p]]
g = lambda x, s, t: abs(x - s) + abs(s - t)
INF = 10**11
a, b, q = list(map(int, input().split()))
S, T, X = [-INF] + I(a) + [INF], [-INF] + I(b... | from bisect import bisect_left
from itertools import product
I = lambda n: [int(eval(input())) for _ in range(n)]
def f(S, x):
p = bisect_left(S, x)
return [S[p - 1], S[p]]
g = lambda x, s, t: abs(x - s) + abs(s - t)
INF = 10**11
a, b, q = list(map(int, input().split()))
S, T, X = [-INF] + I(a) + [INF], [-... | false | 0 | [
"-import bisect",
"+from bisect import bisect_left",
"- p = bisect.bisect_left(S, x)",
"+ p = bisect_left(S, x)"
] | false | 0.047455 | 0.048737 | 0.973701 | [
"s091775032",
"s043633301"
] |
u350997995 | p03672 | python | s314768356 | s033000234 | 26 | 18 | 3,060 | 3,060 | Accepted | Accepted | 30.77 | s = eval(input())
mmax = 0
n = len(s)
while(n>1):
s = s[0:n-1]
n = len(s)
if n<2:
break
if s[0:int(n/2)]==s[int(n/2):n]:
mmax = max(mmax, n)
print(mmax) | S = eval(input())
n = len(S)
for i in range(1,n):
if (n-i)%2 == 1:
continue
if S[0:int((n-i)/2)]==S[int((n-i)/2):n-i]:
print((len(S[0:n-i])))
exit() | 11 | 8 | 172 | 179 | s = eval(input())
mmax = 0
n = len(s)
while n > 1:
s = s[0 : n - 1]
n = len(s)
if n < 2:
break
if s[0 : int(n / 2)] == s[int(n / 2) : n]:
mmax = max(mmax, n)
print(mmax)
| S = eval(input())
n = len(S)
for i in range(1, n):
if (n - i) % 2 == 1:
continue
if S[0 : int((n - i) / 2)] == S[int((n - i) / 2) : n - i]:
print((len(S[0 : n - i])))
exit()
| false | 27.272727 | [
"-s = eval(input())",
"-mmax = 0",
"-n = len(s)",
"-while n > 1:",
"- s = s[0 : n - 1]",
"- n = len(s)",
"- if n < 2:",
"- break",
"- if s[0 : int(n / 2)] == s[int(n / 2) : n]:",
"- mmax = max(mmax, n)",
"-print(mmax)",
"+S = eval(input())",
"+n = len(S)",
"+for i... | false | 0.036984 | 0.109887 | 0.336561 | [
"s314768356",
"s033000234"
] |
u567281053 | p02275 | python | s786219606 | s788102649 | 1,970 | 1,500 | 266,268 | 265,860 | Accepted | Accepted | 23.86 | import sys
def countingSort(A, B, k):
C = [0] * (k + 1)
for j in range(0, len(A)):
C[A[j]] += 1
for i in range(1, k + 1):
C[i] += C[i - 1]
B = [0] * (max(C) + 1)
for j in range(len(A) - 1, -1, -1):
B[C[A[j]]] = A[j]
C[A[j]] -= 1
del B[0]
... | import sys
'''
def countingSort(A, B, k):
C = [0] * (k + 1)
for j in range(len(A)):
C[A[j]] += 1
for i in range(1, k + 1):
C[i] += C[i - 1]
B = [0] * (max(C) + 1)
for j in range(len(A) - 1, -1, -1):
B[C[A[j]]] = A[j]
C[A[j]] -= 1
del B[0]
... | 24 | 35 | 500 | 740 | import sys
def countingSort(A, B, k):
C = [0] * (k + 1)
for j in range(0, len(A)):
C[A[j]] += 1
for i in range(1, k + 1):
C[i] += C[i - 1]
B = [0] * (max(C) + 1)
for j in range(len(A) - 1, -1, -1):
B[C[A[j]]] = A[j]
C[A[j]] -= 1
del B[0]
print(" ".join([str(... | import sys
"""
def countingSort(A, B, k):
C = [0] * (k + 1)
for j in range(len(A)):
C[A[j]] += 1
for i in range(1, k + 1):
C[i] += C[i - 1]
B = [0] * (max(C) + 1)
for j in range(len(A) - 1, -1, -1):
B[C[A[j]]] = A[j]
C[A[j]] -= 1
del B[0]
print " ".join([str(... | false | 31.428571 | [
"-",
"+\"\"\"",
"- for j in range(0, len(A)):",
"+ for j in range(len(A)):",
"+ print \" \".join([str(b) for b in B])",
"+ \"\"\"",
"+",
"+",
"+def countingSort(A, B, k):",
"+ C = [0] * (k + 1)",
"+ for i in range(len(A)):",
"+ C[A[i]] += 1",
"+ for i in range(len... | false | 0.083434 | 0.211845 | 0.393845 | [
"s786219606",
"s788102649"
] |
u408260374 | p02346 | python | s708353680 | s188202622 | 1,500 | 1,040 | 9,168 | 8,192 | Accepted | Accepted | 30.67 | import math
class FenwickTree:
"""
FenwickTree(Binary Indexed Tree)
total number: n
queries:
1. add(i, val): add val to i-th value
2. sum(n): sum(bit[0] + ... + bit[n-1])
complexity: O(log n)
Self-balancing binary search tree or Segment Tree can do the same, it takes longer t... | class FenwickTree:
"""FenwickTree (Binary Indexed Tree, 0-index)
Queries:
1. add(i, val): add val to i-th value
2. sum(n): sum(bit[0] + ... + bit[n-1])
complexity: O(log n)
See: http://hos.ac/slides/20140319_bit.pdf
"""
def __init__(self, a_list):
self.N ... | 43 | 65 | 1,241 | 1,689 | import math
class FenwickTree:
"""
FenwickTree(Binary Indexed Tree)
total number: n
queries:
1. add(i, val): add val to i-th value
2. sum(n): sum(bit[0] + ... + bit[n-1])
complexity: O(log n)
Self-balancing binary search tree or Segment Tree can do the same, it takes longer to program ... | class FenwickTree:
"""FenwickTree (Binary Indexed Tree, 0-index)
Queries:
1. add(i, val): add val to i-th value
2. sum(n): sum(bit[0] + ... + bit[n-1])
complexity: O(log n)
See: http://hos.ac/slides/20140319_bit.pdf
"""
def __init__(self, a_list):
self.N = len(a_list)
... | false | 33.846154 | [
"-import math",
"-",
"-",
"- \"\"\"",
"- FenwickTree(Binary Indexed Tree)",
"- total number: n",
"- queries:",
"- 1. add(i, val): add val to i-th value",
"- 2. sum(n): sum(bit[0] + ... + bit[n-1])",
"+ \"\"\"FenwickTree (Binary Indexed Tree, 0-index)",
"+ Queries:",
"+ ... | false | 0.034372 | 0.044808 | 0.767096 | [
"s708353680",
"s188202622"
] |
u716530146 | p02793 | python | s627153208 | s445753631 | 1,017 | 573 | 131,884 | 131,596 | Accepted | Accepted | 43.66 | #!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
n=int(eval(input()))
A=list(map(int,input().split()))
def gcd(a, b):
while(b != 0):
... | #!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
class InverseTable:
__slots__ = ['In', 'fac', 'Ifac']
def __init__(self, mod, maxnum):... | 50 | 51 | 1,258 | 1,408 | #!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8")
inf = float("inf")
mod = 10**9 + 7
mans = inf
ans = 0
count = 0
pro = 1
n = int(eval(input()))
A = list(map(int, input().split()))
def gcd(a, b):
while b != 0:
a, b... | #!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8")
inf = float("inf")
mod = 10**9 + 7
mans = inf
ans = 0
count = 0
pro = 1
class InverseTable:
__slots__ = ["In", "fac", "Ifac"]
def __init__(self, mod, maxnum):
... | false | 1.960784 | [
"-n = int(eval(input()))",
"-A = list(map(int, input().split()))",
"-",
"-",
"-def gcd(a, b):",
"- while b != 0:",
"- a, b = b, a % b",
"- return a",
"-",
"-",
"-def lcm(m, n):",
"- return (m * n) // gcd(m, n)",
"-it = InverseTable(mod, 10**6)",
"+invt = InverseTable(mod, 1... | false | 2.050101 | 2.766143 | 0.741141 | [
"s627153208",
"s445753631"
] |
u664907598 | p03161 | python | s208101262 | s372759030 | 1,831 | 454 | 23,116 | 52,448 | Accepted | Accepted | 75.2 | import numpy as np
N, K = (int(i) for i in input().split())
h = np.array([int(i) for i in input().split()])
dp = np.empty(N, dtype='int')
for i in range(N):
if i == 0:
dp[i] = 0
elif i - K < 0:
dp[i] = np.min(np.abs(h[i] - h[:i]) + dp[:i])
else:
dp[i] = np.min(np.abs(h[i] - h[i-K:i])... |
n,k = list(map(int,input().split()))
h = list(map(int, input().split()))
dp = [0]*n
dp[0] = 0
dp[1] = abs(h[0]-h[1])
for i in range(2,n):
j = max(0,i-k)
dp[i] = min([dp[l]+abs(h[i]-h[l]) for l in range(j,i)])
print((int(dp[n-1])))
| 15 | 13 | 352 | 249 | import numpy as np
N, K = (int(i) for i in input().split())
h = np.array([int(i) for i in input().split()])
dp = np.empty(N, dtype="int")
for i in range(N):
if i == 0:
dp[i] = 0
elif i - K < 0:
dp[i] = np.min(np.abs(h[i] - h[:i]) + dp[:i])
else:
dp[i] = np.min(np.abs(h[i] - h[i - K ... | n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
dp = [0] * n
dp[0] = 0
dp[1] = abs(h[0] - h[1])
for i in range(2, n):
j = max(0, i - k)
dp[i] = min([dp[l] + abs(h[i] - h[l]) for l in range(j, i)])
print((int(dp[n - 1])))
| false | 13.333333 | [
"-import numpy as np",
"-",
"-N, K = (int(i) for i in input().split())",
"-h = np.array([int(i) for i in input().split()])",
"-dp = np.empty(N, dtype=\"int\")",
"-for i in range(N):",
"- if i == 0:",
"- dp[i] = 0",
"- elif i - K < 0:",
"- dp[i] = np.min(np.abs(h[i] - h[:i]) + d... | false | 0.231082 | 0.042527 | 5.43381 | [
"s208101262",
"s372759030"
] |
u698919163 | p02678 | python | s683770675 | s819186716 | 517 | 447 | 123,168 | 123,016 | Accepted | Accepted | 13.54 | N,M = list(map(int,input().split()))
AB = [list(map(int,input().split())) for i in range(M)]
ans = [-1] * (N+1)
graph = [[] for _ in range(N+1)]
for a,b in AB:
graph[a].append(b)
graph[b].append(a)
from collections import deque
import sys
ans = [-1] * (N+1)
todo = deque([(1,0)])
while todo... | N,M = list(map(int,input().split()))
AB = [list(map(int,input().split())) for i in range(M)]
ans = [-1] * (N+1)
graph = [[] for _ in range(N+1)]
for a,b in AB:
graph[a].append(b)
graph[b].append(a)
from collections import deque
import sys
ans = [-1] * (N+1)
todo = deque([(1,0)])
while todo... | 34 | 32 | 707 | 665 | N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(M)]
ans = [-1] * (N + 1)
graph = [[] for _ in range(N + 1)]
for a, b in AB:
graph[a].append(b)
graph[b].append(a)
from collections import deque
import sys
ans = [-1] * (N + 1)
todo = deque([(1, 0)])
while todo:
x, p... | N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(M)]
ans = [-1] * (N + 1)
graph = [[] for _ in range(N + 1)]
for a, b in AB:
graph[a].append(b)
graph[b].append(a)
from collections import deque
import sys
ans = [-1] * (N + 1)
todo = deque([(1, 0)])
while todo:
x, p... | false | 5.882353 | [
"-for i in range(2, N + 1):",
"- if ans[i] == -1:",
"- print(\"No\")",
"- sys.exit()",
"-print(\"Yes\")",
"-for i in range(2, N + 1):",
"- print((ans[i]))",
"+if -1 in ans[2:]:",
"+ print(\"No\")",
"+else:",
"+ print(\"Yes\")",
"+ for i in range(2, N + 1):",
"+ ... | false | 0.042992 | 0.083442 | 0.515225 | [
"s683770675",
"s819186716"
] |
u169138653 | p02821 | python | s596717423 | s110548345 | 1,174 | 766 | 17,752 | 16,944 | Accepted | Accepted | 34.75 | from itertools import accumulate
n,m=list(map(int,input().split()))
a=list(map(int,input().split()))
a.sort(reverse=True)
b=[0]*(2*a[0]+1)
for i in range(n):
b[a[i]]+=1
b=list(accumulate(b[::-1]))[::-1]
s=list(accumulate([0]+a))
ok=0
ng=2*a[0]+1
while ng-ok>1:
mid=(ng+ok)//2
cnt=0
for i in range(n... | N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort(reverse=True)
LB = A[-1] * 2 # 一回の握手で上がる幸福度の下限は、左手も右手もパワーが一番低い人を握った場合
UB = A[0] * 2 # 一回の握手で上がる幸福度の上限は、左手も右手もパワーが一番高い人を握った場合
# cgs[i] は パワーがi以上のゲストの数
cgs = [0] * (UB + 1)
for a in A:
cgs[a] += 1
for i in range(UB, 0, -... | 28 | 45 | 519 | 861 | from itertools import accumulate
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort(reverse=True)
b = [0] * (2 * a[0] + 1)
for i in range(n):
b[a[i]] += 1
b = list(accumulate(b[::-1]))[::-1]
s = list(accumulate([0] + a))
ok = 0
ng = 2 * a[0] + 1
while ng - ok > 1:
mid = (ng + ok)... | N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort(reverse=True)
LB = A[-1] * 2 # 一回の握手で上がる幸福度の下限は、左手も右手もパワーが一番低い人を握った場合
UB = A[0] * 2 # 一回の握手で上がる幸福度の上限は、左手も右手もパワーが一番高い人を握った場合
# cgs[i] は パワーがi以上のゲストの数
cgs = [0] * (UB + 1)
for a in A:
cgs[a] += 1
for i in range(UB, 0, -1):
cgs[i ... | false | 37.777778 | [
"-from itertools import accumulate",
"+N, M = list(map(int, input().split()))",
"+A = list(map(int, input().split()))",
"+A.sort(reverse=True)",
"+LB = A[-1] * 2 # 一回の握手で上がる幸福度の下限は、左手も右手もパワーが一番低い人を握った場合",
"+UB = A[0] * 2 # 一回の握手で上がる幸福度の上限は、左手も右手もパワーが一番高い人を握った場合",
"+# cgs[i] は パワーがi以上のゲストの数",
"+cgs =... | false | 0.08682 | 0.105244 | 0.824943 | [
"s596717423",
"s110548345"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.