Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
if len(sed(list(input())))<=2:
  print('Yes')
else:
  print('No')

Fixed submission:
s=input()
if len(set(s[1:]))==1 or len(set(s[:-1]))==1:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):

n=int(input())
rec=[2,1]
if n>=2:
    for i in range(2,n):
        rec.append(rec[i-2]+rec[i-1])
print(rec[n])


Fixed submission:
n=int(input())
rec=[2,1]
if n>=2:
    for i in range(2,n+1):
        rec.append(rec[i-2]+rec[i-1])
print(rec[n])

Buggy python submission (verdict: Runtime Error):
n=int(input())
rec=[2,1]
for i in range(2,n):
  rec.append(rec[i-2]+rec[i-1])
print(rec[n])

Fixed submission:
n=int(input())
rec=[2,1]
if n>=2:
    for i in range(2,n+1):
        rec.append(rec[i-2]+rec[i-1])
print(rec[n])
Buggy python submission (verdict: Runtime Error):

Beta
  paiza.IO
新規コード
一覧
ウェブ開発  
New!
日本語  サインアップ ログイン
Python3 Split Button!	
Enter a title here
Main.py 
Success  

  
1
2
3
4
5
6
7
8
9
10
11
12
13
def chunked(iterable, n):
    return [iterable[x:x + n] for x in range(0, len(iterable), n)]
s=input()
for i in range(1,len(s)):
    a=s[:(-1*i)]
    if len(a)>1:
        li=chunked(a,(len(a)+1)//2)
        
        if li[0]==li[1]:
            print(len(a))
            quit()
    
  実行 (Ctrl-Enter) Split Button!             
出力
入力
コメント 0
(0.04 sec)
 
2

Fixed submission:
def chunked(iterable, n):
    return [iterable[x:x + n] for x in range(0, len(iterable), n)]

s=input()
for i in range(1,len(s)):
    a=s[:(-1*i)]
    if len(a)>1:
        li=chunked(a,(len(a)+1)//2)
        
        if li[0]==li[1]:
            print(len(a))
            quit()
Buggy python submission (verdict: Runtime Error):
n = int(input())
alp = "abcdefghijklmnopqrstuvwxyz"
d = {i+1:s for i, s in enumerate(alp)}
s = ""
while True:
    q, mod = divmod(n, 26)
    s = d[mod] + s
    if q == 0:
        break
    n = q
print(s)

Fixed submission:
n = int(input())
alp = "abcdefghijklmnopqrstuvwxyz"
d = {i+1:s for i, s in enumerate(alp)}
s = ""
while True:
    q, mod = divmod(n, 26)
    if mod == 0:
        s = "z" + s
        n = q-1
    else:
        s = d[mod] + s
        n = q
    if n == 0:
        break
print(s)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
n = int(input())
a = np.array(list(map(int, input().split())))
ci = defaultdict(int)
cj = defaultdict(int)
for i in range(n):
    ci[a[i]+i] += 1
    cj[i-a[i]] += 1
cnt = 0
for k in ci.keys():
    cnt += ci[k] * cj[k]
print(cnt)

Fixed submission:
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
ci = defaultdict(int)
cj = defaultdict(int)
for i in range(n):
    ci[a[i]+i] += 1
    cj[i-a[i]] += 1
cnt = 0
for k in ci.keys():
    cnt += ci[k] * cj[k]
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
# 愚直な方法: O(n^2)
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))
cnt = 0
for i in range(1, n+1):
    for j in range(i+1, n+1):
        if abs(i-j) == (a[i-1]+a[j-1]):
            cnt += 1
print(cnt)

Fixed submission:
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
ci = defaultdict(int)
cj = defaultdict(int)
for i in range(n):
    ci[a[i]+i] += 1
    cj[i-a[i]] += 1
cnt = 0
for k in ci.keys():
    cnt += ci[k] * cj[k]
print(cnt)

Buggy python submission (verdict: Runtime Error):
# 愚直な方法: O(n^2)
n = int(input())
a = np.array(list(map(int, input().split())))
cnt = 0
for i in range(1, n+1):
    for j in range(i+1, n+1):
        if abs(i-j) == (a[i-1]+a[j-1]):
            cnt += 1
print(cnt)

Fixed submission:
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
ci = defaultdict(int)
cj = defaultdict(int)
for i in range(n):
    ci[a[i]+i] += 1
    cj[i-a[i]] += 1
cnt = 0
for k in ci.keys():
    cnt += ci[k] * cj[k]
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
# 各要素に身長同士の和を保持する行列を利用する方法
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))
s = np.array([])
for i in a:
    s = np.append(s, i+a)
s = s.reshape(len(a), -1)
for i in range(len(a)):
    s[i, i] = -1
b = np.arange(1, n+1)
t = np.array([])
for i in b:
    t = np.append(t, abs(b-i))
t = t.reshape(len(b), -1)
print(int(np.count_nonzero(s == t)/2))

Fixed submission:
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
ci = defaultdict(int)
cj = defaultdict(int)
for i in range(n):
    ci[a[i]+i] += 1
    cj[i-a[i]] += 1
cnt = 0
for k in ci.keys():
    cnt += ci[k] * cj[k]
print(cnt)
Buggy python submission (verdict: Runtime Error):
x = int(input())
m = 100
i = 0.01
y = 0
flag = True
while flag:
    m = math.floor(m*(1+i))
    y += 1
    if m >= x:
        break
print(y)

Fixed submission:
import math

x = int(input())
m = 100
i = 0.01
y = 0
flag = True
while flag:
    m = math.floor(m*(1+i))
    y += 1
    if m >= x:
        break
print(y)
Buggy python submission (verdict: Runtime Error):
r = int(input())
print(2 * math.pi * r)

Fixed submission:
import math
r = int(input())
print(2 * math.pi * r)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
for i in range(1, n+1):
    print(a[i-1:].count(i))

Fixed submission:
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)
for i in a:
    d[i] += 1
for j in range(1, n+1):
    print(d.get(j, 0))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
for i in range(1, n+1):
    print(a.count(i))

Fixed submission:
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)
for i in a:
    d[i] += 1
for j in range(1, n+1):
    print(d.get(j, 0))
Buggy python submission (verdict: Runtime Error):
N = int(input())
s = [int(input()) for _ in range(N)]
cond = True
for i in s:
  if i%2 == 0:
    if i%3 == 0 or i%5 == 0:
      continue
    else:
      cond = False
      break
if cond is True:
  print("APPROVED")
else:
  print("DENIED")

Fixed submission:
N = int(input())
s = list(map(int, input().split()))
cond = True
for i in s:
  if i%2 == 0:
    if i%3 == 0 or i%5 == 0:
      continue
    else:
      cond = False
      break
if cond is True:
  print("APPROVED")
else:
  print("DENIED")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a = list(map(int, input().split())) #
ans=1
for i in range(n):
    ans=ans*a[i]

if ans>10**18:
    print(-1)
else:
    print(ans)

Fixed submission:
n=int(input())
a = list(map(int, input().split())) #
ans=1
for i in range(n):
    if a[i]==0:
        print(0)
        exit()
for i in range(n):
    if a[i]*ans>10**18:
        print(-1)
        exit()
    else:
        ans=ans*a[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n=int,input()
a=list(map(int,input().split()))
for i in range(n):
    a.append(a[i]-1)
    a.append(a[i]+1)
c=Counter(a).most_common()
print(c[0][1])

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    a.append(a[i]-1)
    a.append(a[i]+1)
c=Counter(a).most_common()
print(c[0][1])

Buggy python submission (verdict: Runtime Error):
n=int,input()
a=list(map(int,input().split()))
m=max(a)
n=min(a)
for i in range(n,m+1):
    pre=0
    for j in range(len(a)):
        if i-1<=a[j]<=i+1:
            pre+=1
    ans=max(ans,pre)
    
print(ans)

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    a.append(a[i]-1)
    a.append(a[i]+1)
c=Counter(a).most_common()
print(c[0][1])

Buggy python submission (verdict: Time Limit Exceeded):
n=int,input()
a=list(map(int,input().split()))
m=max(a)
ans=0
for i in range(m+2):
    pre=0
    for j in range(len(a)):
        if i-1<=a[j]<=i+1:
            pre+=1
    ans=max(ans,pre)
    
print(ans)
    

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    a.append(a[i]-1)
    a.append(a[i]+1)
c=Counter(a).most_common()
print(c[0][1])

Buggy python submission (verdict: Time Limit Exceeded):
n=int,input()
a=list(map(int,input().split()))
m=max(a)
ans=0
for i in range(m+2):
    pre=0
    for j in range(len(a)):
        if (a[j]-1<=i) and (i<=a[j]+1):
            pre+=1
        else:
            pre=pre
    ans=max(ans,pre)
    
print(ans)
    

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    a.append(a[i]-1)
    a.append(a[i]+1)
c=Counter(a).most_common()
print(c[0][1])
Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
t=[int(input()) for _ in range(n)]

ans=t[0]

def lcm(x,y):
    return (x*y)//math.gcd(x,y)

for i in range(1,n):
    ans=lcm(ans,t[i])
print(ans)
    

Fixed submission:
import fractions
n=int(input())
t=[int(input()) for _ in range(n)]

ans=t[0]

def lcm(x,y):
    return (x*y)//fractions.gcd(x,y)

for i in range(1,n):
    ans=lcm(ans,t[i])
print(ans)

Buggy python submission (verdict: Runtime Error):
import math as mt
n=int(input())
t=[int(input()) for _ in range(n)]

ans=t[0]
def lcm(x,y):
    return (x*y)//mt.gcd(x,y)
for i in range(1,n):
    ans=lcm(ans,t[i])
print(ans)

Fixed submission:
import fractions
n=int(input())
t=[int(input()) for _ in range(n)]

ans=t[0]

def lcm(x,y):
    return (x*y)//fractions.gcd(x,y)

for i in range(1,n):
    ans=lcm(ans,t[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    A, V = map(int, input().split())
    B, W = map(int, input().split())
    T = int(input())

    if A == B:
        print('YES')
    elif W > V:
        print('NO')
    elif (A - B) % (W - V) == 0 and (A - B) // (W - V) <= T:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()


Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    A, V = map(int, input().split())
    B, W = map(int, input().split())
    T = int(input())

    if W >= V:
        print('NO')
    elif abs((A - B) / (W - V)) <= T:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from itertools import accumulate
def input(): return sys.stdin.readline().rstrip()

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    for _ in range(K):
        new_A = [0] * (N)
        for i, a in enumerate(A):
            s = i - a
            if s < 0:
                s = 0
            f = i + a + 1
            new_A[s] += 1
            if f < N:
                new_A[f] -= 1
        A = list(accumulate(new_A))
    print(*A)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
from itertools import accumulate
def input(): return sys.stdin.readline().rstrip()

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    for _ in range(K):
        new_A = [0] * (N)
        for i, a in enumerate(A):
            s = i - a
            if s < 0:
                s = 0
            f = i + a + 1
            new_A[s] += 1
            if f < N:
                new_A[f] -= 1
        A = list(accumulate(new_A))
        if min(A) == N:
            break
    print(*A)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    MAX_V = 10 ** 18

    if 0 in A:
        print(0)
        exit()

    ans = 1
    for a in A:
        ans *= a
        if ans > MAX_V:
            ans = -1
    print(ans)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    A = sorted(map(int, input().split()), reverse=True)
    MAX_V = 10 ** 18

    if A[-1] == 0:
        print(0)
        exit()

    ans = 1
    for a in A:
        ans *= a
        if ans > MAX_V:
            ans = -1
            break
    print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    MAX_V = 10 ** 18

    ans = 1
    for a in A:
        ans *= a
    if ans > MAX_V:
        ans = -1
    print(ans)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    A = sorted(map(int, input().split()), reverse=True)
    MAX_V = 10 ** 18

    if A[-1] == 0:
        print(0)
        exit()

    ans = 1
    for a in A:
        ans *= a
        if ans > MAX_V:
            ans = -1
            break
    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
from collections import deque
def input(): return sys.stdin.readline().rstrip()

def main():
    N, M = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(M)]

    root = [[] for _ in range(M + 1)]
    for a, b in AB:
        root[a].append(b)
        root[b].append(a)

    que = deque()
    que.append(1)
    front = [-1] * (N + 1)
    front[1] = 1
    while que:
        point = que.popleft()
        for i in root[point]:
            if front[i] > 0:
                continue
            front[i] = point
            que.append(i)

    if min(front[2:]) < 0:
        print('No')
    else:
        print('Yes')
        for i in range(2, N + 1):
            print(front[i])

if __name__ == '__main__':
    main()


Fixed submission:
import sys
from collections import deque
def input(): return sys.stdin.readline().rstrip()

def main():
    N, M = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(M)]

    root = [[] for _ in range(N + 1)]
    for a, b in AB:
        root[a].append(b)
        root[b].append(a)

    que = deque()
    que.append(1)
    front = [-1] * (N + 1)
    front[1] = 1
    while que:
        point = que.popleft()
        for i in root[point]:
            if front[i] > 0:
                continue
            front[i] = point
            que.append(i)

    if min(front[1:]) < 0:
        print('No')
    else:
        print('Yes')
        for i in range(2, N + 1):
            print(front[i])

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()

def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False

def main():
    X = int(input())
    ROOT = 1/5
    for a in range(10000000):
        a5 = a ** 5
        b = a5 - X
        b_root = abs(b)**ROOT
        if not is_integer_num(b_root):
            continue
        if b < 0:
            if a5 + b_root ** 5 == X:
                print(a, -int(b_root))
                exit()
        else:
            if a5 - b_root ** 5 == X:
                print(a, int(b_root))
                exit()

if __name__ == '__main__':
    main()


Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    X = int(input())
    for a in range(-120, 120):
        a5 = a ** 5
        for b in range(-120, 120):
            if a5 - b ** 5 == X:
                print(a, b)
                exit()

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()

def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False

def main():
    X = int(input())
    ROOT = 1/5
    for a in range(-10000000, 10000000):
        a5 = a ** 5
        b = a5 - X
        b_root = abs(b)**ROOT
        if not is_integer_num(b_root):
            continue
        if b < 0:
            if a5 + b_root ** 5 == X:
                print(a, -int(b_root))
                exit()
        else:
            if a5 - b_root ** 5 == X:
                print(a, int(b_root))
                exit()

if __name__ == '__main__':
    main()


Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    X = int(input())
    for a in range(-120, 120):
        a5 = a ** 5
        for b in range(-120, 120):
            if a5 - b ** 5 == X:
                print(a, b)
                exit()

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    S = input()
    slen = len(S)
    visited = set()
    ans = 0
    for i in range(0, slen):
        if i in visited:
            continue
        start = i
        end = i + 4
        point = 1
        while end <= slen:
            if (int(S[start:end])) % 2019 == 0:
                visited.add(start)
                start = end + 1
                end = start + 4
                ans += point
                point += 1
            else:
                end += 1
    print(ans)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    S = input()
    s_list = list(map(int, list(S)))[::-1]
    MOD = 2019

    sum_v = 0
    cnt = [0] * MOD
    cnt[0] = 1
    for i, s in enumerate(s_list):
        sum_v += s * pow(10, i, MOD)
        sum_v %= MOD
        cnt[sum_v] += 1
    print(sum([c * (c - 1) // 2 for c in cnt if c > 1]))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    S = input()
    slen = len(S)
    visited = set()
    ans = 0
    for i in range(0, slen):
        if i in visited:
            continue
        start = i
        end = i + 4
        point = 1
        while end <= slen:
            if (int(S[start:end])) % 2019 == 0:
                visited.add(start)
                start = end + 1
                end = start + 4
                ans += point
                point += 1
            else:
                end += 1
    print(ans)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    S = input()
    s_list = list(map(int, list(S)))[::-1]
    MOD = 2019

    sum_v = 0
    cnt = [0] * MOD
    cnt[0] = 1
    for i, s in enumerate(s_list):
        sum_v += s * pow(10, i, MOD)
        sum_v %= MOD
        cnt[sum_v] += 1
    print(sum([c * (c - 1) // 2 for c in cnt if c > 1]))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    S = input()
    slen = len(S)
    ans = 0
    for i in range(0, slen):
        start = i
        end = i + 4
        while end <= slen:
            if (int(S[start:end])) % 2019 == 0:
                start = end + 1
                end = start + 4
                ans += 1
            else:
                end += 1
    print(ans)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    S = input()
    s_list = list(map(int, list(S)))[::-1]
    MOD = 2019

    sum_v = 0
    cnt = [0] * MOD
    cnt[0] = 1
    for i, s in enumerate(s_list):
        sum_v += s * pow(10, i, MOD)
        sum_v %= MOD
        cnt[sum_v] += 1
    print(sum([c * (c - 1) // 2 for c in cnt if c > 1]))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N, K = map(int, input().split())
    MOD = 10 ** 9 + 7

    ans = 0
    memo = [0] * (K+1)
    def getLarge(x):
        if x == 1:
            return sum(memo)
        else:
            return sum(memo[x::x])

    for i in range(K, 0, -1):
        Ki = K // i
        c = Ki ** N - getLarge(i) % MOD
        memo[i] = c
        ans += i * c
        ans %= MOD
    print(ans % MOD)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N, K = map(int, input().split())
    MOD = 10 ** 9 + 7

    ans = 0
    memo = [0] * (K+1)
    def getLarge(x):
        if x == 1:
            return sum(memo)
        else:
            return sum(memo[x::x])

    for i in range(K, 0, -1):
        Ki = K // i
        c = pow(Ki, N, MOD) - getLarge(i) % MOD
        memo[i] = c
        ans += i * c
        ans %= MOD
    print(ans % MOD)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N, K = map(int, input().split())
    MOD = 10 ** 9 + 7

    ans = 0
    memo = [0] * (K+1)
    def getLarge(x):
        if x == 1:
            return sum(memo)
        else:
            return sum(memo[x::x])

    for i in range(K, 0, -1):
        Ki = K // i
        c = Ki ** N - getLarge(i)
        memo[i] = c
        ans += i * c % MOD
    print(ans % MOD)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N, K = map(int, input().split())
    MOD = 10 ** 9 + 7

    ans = 0
    memo = [0] * (K+1)
    def getLarge(x):
        if x == 1:
            return sum(memo)
        else:
            return sum(memo[x::x])

    for i in range(K, 0, -1):
        Ki = K // i
        c = pow(Ki, N, MOD) - getLarge(i) % MOD
        memo[i] = c
        ans += i * c
        ans %= MOD
    print(ans % MOD)

if __name__ == '__main__':
    main()