alexjercan/bugnet huggingface dataset:
Problem p03283 (Python) — buggy submission, verdict: Time Limit Exceeded

import sys

import numba as nb
import numpy as np

input = sys.stdin.readline


@nb.njit("i8[:](i8,i8,i8,i8[:,:],i8[:,:])", cache=True)
def solve(N, M, Q, LR, pq):
    S = np.zeros(shape=(N + 1, N + 1), dtype=np.int64)
    for i in range(M):
        L, R = LR[i]
        S[L][R] += 1
    for i in range(N + 1):
        S[i] = np.cumsum(S[i])

    ans = np.zeros(shape=Q, dtype=np.int64)
    for i in range(Q):
        p, q = pq[i]
        for j in range(p, q + 1):
            ans[i] += S[j][q] - S[j][p - 1]

    return ans


def main():
    N, M, Q = map(int, input().split())
    LR = np.zeros(shape=(M, 2), dtype=np.int64)
    for i in range(M):
        LR[i] = input().split()
    pq = np.zeros(shape=(Q, 2), dtype=np.int64)
    for i in range(Q):
        pq[i] = input().split()

    ans = solve(N, M, Q, LR, pq)

    print("\\n".join(map(str, ans)))


if __name__ == "__main__":
    main()


Error: TLE

Fixed submission:

import sys
from itertools import accumulate

input = sys.stdin.readline


def main():
    N, M, Q = map(int, input().split())
    LR = [None] * M
    for i in range(M):
        LR[i] = tuple(map(int, input().split()))
    pq = [None] * Q
    for i in range(Q):
        pq[i] = tuple(map(int, input().split()))

    S = [[0] * (N + 1) for _ in range(N + 1)]
    for L, R in LR:
        S[L][R] += 1
    for i in range(N + 1):
        S[i] = list(accumulate(S[i]))

    ans = [0] * Q
    for i, (p, q) in enumerate(pq):
        for j in range(p, q + 1):
            ans[i] += S[j][q] - S[j][p - 1]

    print("\\n".join(map(str, ans)))


if __name__ == "__main__":
    main()
Problem p03283 (Python) — buggy submission, verdict: Time Limit Exceeded

N, M, Q = map(int, input().split())

x = [[0 for i in range(N + 1)] for j in range(N + 1)]

for i in range(M):
    l, r = map(int, input().split())
    x[l][r] += 1

for i in range(1, N + 1):
    for j in range(1, N + 1):
        x[i][j] += x[i - 1][j] + x[i][j - 1] - x[i - 1][j - 1]

for i in range(Q):
    p, q = map(int, input().split())

    ans = x[N][q] - x[p - 1][q]
    print(ans)


Error: TLE

Fixed submission:

N, M, Q = map(int, input().split())

LR = [[0 for i in range(2)] for j in range(M)]
pq = [[0 for i in range(2)] for j in range(Q)]

for i in range(M):
    LR[i] = list(map(int, input().split()))

for i in range(Q):
    pq[i] = list(map(int, input().split()))

x = [[0 for i in range(N)] for j in range(N)]

# print(LR[0][0])

for i in range(M):
    # x[LR[i][1] - 1][LR[i][0] - 1] = x[LR[i][1] - 1][LR[i][0] - 1] + 1
    x[LR[i][1] - 1][LR[i][0] - 1] += 1

xacu = [[0 for i in range(N)] for j in range(N)]

for i in range(N):
    for j in range(N):
        if j == 0:
            xacu[i][j] = x[i][j]
        else:
            xacu[i][j] = xacu[i][j - 1] + x[i][j]

# print(xacu)

for i in range(Q):
    count = 0
    p = pq[i][0]
    for j in range(pq[i][1]):
        if p == 1:
            count = count + xacu[j][N - 1]
        else:
            count = count + xacu[j][N - 1] - xacu[j][p - 2]

    print(count)
Problem p03283 (Python) — buggy submission, verdict: Time Limit Exceeded

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import bisect
import array


def solve():
    n, m, q = map(int, input().split())
    nl = [[0 for i in range(n + 1)] for j in range(n + 1)]
    for e in [input().split() for _ in range(m)]:
        l, r = int(e[0]), int(e[1])
        nl[l][r] += 1
    table = [array.array("i", [0] * (n + 2)) for j in range(n + 2)]
    ran = array.array("i", range(n + 1))
    for i in ran:
        for j in ran:
            table[i][j + 1] = table[i][j] + nl[i][j]

    for i, e in enumerate([input().split() for _ in range(q)]):
        l, r = int(e[0]), int(e[1])
        ans = 0
        for j in range(l, r + 1):
            ans += table[j][r + 1] - table[j][l]
        print(ans)


if __name__ == "__main__":
    solve()


Error: TLE

Fixed submission:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import bisect
import array


def solve():
    n, m, q = map(int, input().split())
    nl = [[] for j in range(n + 1)]
    for e in (input().split() for _ in [0] * m):
        l, r = int(e[0]), int(e[1])
        bisect.insort_left(nl[l], r)
    table = [array.array("i", [0] * (n + 1)) for j in range(n + 1)]
    ran = array.array("i", range(n + 1))
    for i in ran:
        table[i] = [bisect.bisect_right(nl[i], j) for j in ran]

    a = [0] * q
    s = array.array("i", a)
    for i, e in enumerate(input().split() for _ in a):
        l, r = int(e[0]), int(e[1])
        s[i] = sum(table[j][r] - table[j][l - 1] for j in range(l, r + 1))
    print("\\n".join(str(e) for e in s))


if __name__ == "__main__":
    solve()
Problem p03284 (Python) — buggy submission, verdict: Runtime Error

N, K = map(int, input().split())

if N % K == 0:
    print(0)

else:
    print(1)


Error: ValueError: invalid literal for int() with base 10: '7 3'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03284/Python/s894069046.py", line 3, in <module>
    N = int(input())
ValueError: invalid literal for int() with base 10: '7 3'


Fixed submission:

import bisect

N = int(input())
root = [4, 7]

if bisect.bisect_right(root, N):
    print("Yes")
else:
    print("No")
Problem p03284 (Python) — buggy submission, verdict: Runtime Error

N, K = map(int, (input().split()))
if N % K == 0:
    print("0")
else:
    print("1")


Error: TypeError: int() argument must be a string, a bytes-like object or a real number, not 'list'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03284/Python/s928688987.py", line 1, in <module>
    N, K = map(int(input().split()))
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'list'


Fixed submission:

N, K = map(int(input().split()))
if N % K == 0:
    print("0")
else:
    print("1")
Problem p03284 (Python) — buggy submission, verdict: Runtime Error

N, K = map(int, input().split())
print([0, 1][0 < N % K])


Error: 0

Fixed submission:

N, K = map(int, input().split())
print([0, 1][N % K])
Problem p03284 (Python) — buggy submission, verdict: Runtime Error

numSenbei, numPeople = [int(i) for i in str(input()).split()]

if numSenbei % numPeople == 0:
    print(0)
else:
    print(1)


Error: TypeError: not all arguments converted during string formatting
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03284/Python/s122237530.py", line 3, in <module>
    if numSenbei % numPeople == 0:
TypeError: not all arguments converted during string formatting


Fixed submission:

(numSenbei, numPeople) = input().split()

if numSenbei % numPeople == 0:
    print(1)
else:
    print(0)
Problem p03286 (Python) — buggy submission, verdict: Runtime Error

# -2進数を求める
N = int(input())

if N == 0:
    print(0)
else:
    ans = ""
    while N != 0:
        if N % 2 != 0:
            N -= 1
            ans = "1" + ans
        else:
            ans = "0" + ans
        N = N // (-2)
    print(ans)


Error: 0

Fixed submission:

# -2進数を求める
N = int(input())

if N == 0:
    print(0)
else:
    ans = ""
    while N != 0:
        if N % 2 != 0:
            N -= 1
            ans = "1" + ans
        else:
            ans = "0" + ans
        N = N // (-2)
print(ans)
Problem p03287 (Python) — buggy submission, verdict: Time Limit Exceeded

from collections import Counter
import numpy as np


N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))

A = np.cumsum(A) % M
C = Counter(A)

res = 0
for c in C.items():
    if c[1] > 1:
        res += (c[1] * (c[1] - 1)) // 2
    if c[0] == 0:
        res += c[1]

print(res)


Error: TLE

Fixed submission:

# -*- coding: utf-8 -*-
from collections import defaultdict

N, M = map(int, input().split())
A_list = list(map(int, input().split()))

x = defaultdict(int)
y = defaultdict(int)

for i in range(N):
    temp = x.copy()
    x.clear()
    r = A_list[i] % M
    for t in temp.items():
        y[t[0]] = y[t[0]] + t[1]
        x[int(t[0] + r) % M] = t[1]
    x[r] += 1

print(int(x[0] + y[0]))
Problem p03287 (Python) — buggy submission, verdict: Time Limit Exceeded

from sys import stdin
from collections import Counter
import numpy as np

N, M = [int(x) for x in stdin.readline().split()]
A = np.array([int(a) for a in stdin.readline().split()], dtype=np.int64)

cum_remainders = (np.hstack([0, A]) % M).cumsum() % M

remainder_counts = Counter(cum_remainders)
combinations = 0
for count in remainder_counts.values():
    combinations += count * (count - 1) // 2
print(combinations)


Error: TLE

Fixed submission:

from sys import stdin
import numpy as np

N, M = [int(x) for x in stdin.readline().split()]
A = np.array([int(a) for a in stdin.readline().split()], dtype=np.int64)

cumsum_remainders = (np.hstack([0, A]) % M).cumsum() % M

total = 0
for remainder in np.unique(cumsum_remainders):
    count = (cumsum_remainders == remainder).sum()
    total += count * (count - 1) // 2
print(total)
Problem p03287 (Python) — buggy submission, verdict: Time Limit Exceeded

# -*- coding: utf-8 -*-

"""
参考：https://img.atcoder.jp/abc105/editorial.pdf
　　　http://drken1215.hatenablog.com/entry/2018/08/13/125300
　　　https://www.hamayanhamayan.com/entry/2018/08/12/010816
・左端固定で右端動かすループの累積和だけ取れば、
　(右端の累積和)-(左端-1の累積和)で、どこでも分かるようになる。
・B-AがMの倍数 → BとAのmod Mが等しい(やってみれば分かる)
・各ループ内で、それまでに集計した累積和mod Mから左端として使える場所を数える。
"""

from collections import defaultdict

N, M = map(int, input().split())
aN = list(map(int, input().split()))

# 累積和を一時的に格納する変数
sm = 0
ans = 0
# 累積和のmod Mを格納するdict
d = defaultdict(int)
# 何もない累積和0の分を足しておく
d[0] = 1
for i in range(N):
    sm += +aN[i]
    # 今回のsm%Mを右端として、mod Mが同値になる左端候補の数を答えに加算
    ans += d[sm % M]
    # 今回のsm%Mはこの後左端候補として使うので+1
    d[sm % M] += 1
print(ans)


Error: TLE

Fixed submission:

# -*- coding: utf-8 -*-

N, M = map(int, input().split())
aN = list(map(int, input().split()))

cnt = 0
for i in range(N):
    ans = 0
    for j in range(i, N):
        ans += aN[j]
        if ans % M == 0:
            cnt += 1
print(cnt)
Problem p03287 (Python) — buggy submission, verdict: Runtime Error

# -*- coding: utf-8 -*-
from itertools import accumulate
from collections import defaultdict

n, m = map(int, input().split())
ary = [int(_) for _ in input().split()]

sum_ary = list(accumulate(ary, lambda x, y: x + y))
mod_ary = [s % m for s in sum_ary]
mod_table = defaultdict(int)
for mod in mod_ary:
    mod_table[mod] += 1
mod_table[0] += 1

print(sum([mod * (mod - 1) // 2 for mod in mod_table.values()]))


Error: 0

Fixed submission:

# -*- coding: utf-8 -*-
from itertools import accumulate, combinations
from collections import defaultdict

n, m = map(int, input().split())
ary = [int(_) for _ in input().split()]

sum_ary = accumulate(ary, lambda x, y: x + y)
mod_table = defaultdict(int)
for mod in [s % m for s in (ary[0], *sum_ary)]:
    mod_table[mod] += 1

print(sum([len(list(combinations(range(v), 2))) for v in mod_table.values()]))
Problem p03287 (Python) — buggy submission, verdict: Runtime Error

N, M = map(int, input().split())
A = list(map(int, input().split()))

t = {}
c = 0
for a in A:
    c += a
    c %= M
    if c in t:
        t[c] += 1
    else:
        t[c] = 1

result = 0
if 0 in t:
    result += t[0]
c = 0
for a in A:
    c += a
    c %= M
    t[c] -= 1
    result += t[c]
print(result)


Error: 0

Fixed submission:

N, M = map(int, input().split())
A = list(map(int, input().split()))

t = {}
c = 0
for a in A:
    c += a
    c %= M
    if c in t:
        t[c] += 1
    else:
        t[c] = 1

result = t[0]
c = 0
for a in A:
    c += a
    c %= M
    t[c] -= 1
    result += t[c]
print(result)
Problem p03287 (Python) — buggy submission, verdict: Runtime Error

#!/usr/bin/env python3

import numpy as np
from scipy.special import comb

n, m = list(map(int, input().split()))
a = list(map(int, input().split()))

a_sum = np.cumsum(a)


re_list = {}
re_list[0] = 1
for i in a_sum:
    re = i % m
    if re in re_list:
        re_list[re] += 1
    else:
        re_list[re] = 1

# print(re_list)
ans = 0
for value in re_list.values():
    ans += comb(value, 2, exact=True)

print(ans)


Error: TLE

Fixed submission:

#!/usr/bin/env python3

import numpy as np
from scipy.special import comb

n, m = list(map(int, input().split()))
a = list(map(int, input().split()))

a_sum = np.cumsum(a)


re_list = {}
for i in a_sum:
    re = i % m
    if re in re_list:
        re_list[re] += 1
    else:
        re_list[re] = 1
re_list[0] += 1
# print(re_list)
ans = 0
for value in re_list.values():
    ans += comb(value, 2, exact=True)

print(ans)
Problem p03287 (Python) — buggy submission, verdict: Runtime Error

n, m = map(int, input().split())
a = list(map(int, input().split()))

sumList = [0] * n
sumList[0] = a[0] % m
number = {}
number[sumList[0]] = 0

for i in range(1, n):
    sumList[i] = (sumList[i - 1] + a[i]) % m
    number[sumList[i]] = 0

for i in range(n):
    number[sumList[i]] += 1

ans = 0

for key, value in number.items():
    ans += value * (value - 1) // 2
    if key == 0:
        ans += value

print(ans)


Error: 0

Fixed submission:

n, m = map(int, input().split())
a = list(map(int, input().split()))

sumList = [0] * n
sumList[0] = a[0] % m
number = {}

for i in range(1, n):
    sumList[i] = (sumList[i - 1] + a[i]) % m
    number[sumList[i]] = 0

for i in range(n):
    number[sumList[i]] += 1

ans = 0

for key, value in number.items():
    ans += value * (value - 1) // 2
    if key == 0:
        ans += value

print(ans)
Problem p03288 (Python) — buggy submission, verdict: Runtime Error

r = int(input())

if r < 1200:
    print("ABC")
elif r < 2800:
    print("ARC")
else:
    print("AGC")


Error: TypeError: '<' not supported between instances of 'str' and 'int'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03288/Python/s301962316.py", line 3, in <module>
    if r < 1200:
TypeError: '<' not supported between instances of 'str' and 'int'


Fixed submission:

r = input()

if r < 1200:
    print("ABC")
elif r < 2800:
    print("ARC")
else:
    print("AGC")
Problem p03289 (Python) — buggy submission, verdict: Runtime Error

S = input()
flag = True
cflag = False
for i, c in enumerate(S):
    if i == 0:
        if c == "A":
            continue
        else:
            flag = False
            break

    if c == "C" and 2 <= i < len(S) - 1:
        if cflag:
            flag = False
        cflag = True

    elif not (97 <= ord(c) <= 122):
        flag = False


if flag and cflag:
    print("AC")
else:
    print("WA")


Error: 0

Fixed submission:

S = input()
flag = True
Cflag = False
for i, c in enumerate(S):
    if i == 0:
        if c == "A":
            continue
        else:
            flag = False
            break

    if c == "C" and i >= 2:
        if Cflag:
            flag = False
        cflag = True
    elif not (97 <= ord(c) <= 122):
        flag = False

if flag and cflag:
    print("AC")
else:
    print("WA")
Problem p03289 (Python) — buggy submission, verdict: Runtime Error

import sys

s = input()

if s[0] != "A":
    print("WA")
    sys.exit(0)

if s[1] < "a" or s[1] > "z":
    print("WA")
    sys.exit(0)


sub = s[2:-1]
has = False
for c in sub:
    if not has and c == "C":
        has = True

    elif "a" <= c <= "z":
        continue

    else:
        has = False
        break

if not has:
    print("WA")
    sys.exit(0)

if "a" <= s[-1] <= "z":
    print("AC")
else:
    print("WA")


Error: 0

Fixed submission:

import sys

s = input()

if s[0] != "A":
    print("WA")
    sys.exit(0)

if s[1] < "a" or s[1] > "z":
    print("WA")
    sys.exit(1)


sub = s[2:-1]
has = False
for c in sub:
    if not has and c == "C":
        has = True

    elif "a" <= c <= "z":
        continue

    else:
        has = False
        break

if not has:
    print("wA")
    sys.exit(0)

if "a" <= s[len(s) - 1] <= "z":
    print("AC")
else:
    print("WA")
Problem p03289 (Python) — buggy submission, verdict: Runtime Error

import string

s = list(input())
flag = True
if s[0] != "A":
    flag = False
count = 0
for i in range(1, len(s)):
    if s[i] in string.ascii_uppercase:
        if i == 1 or i == len(s) - 1 or s[i] != "C":
            flag = False
        count += 1

if flag and count == 1:
    print("AC")
else:
    print("WA")


Error: WA

Fixed submission:

import string

s = list(input())
flag = True
if s[0] != "A":
    flag = False
s.pop(0)
if s.count("C") > 1:
    flag = False
s_index = s.index("C")
if 2 >= s_index or s_index <= (len(s) - 3):
    flag = False
s.pop(s_index)
for i in s:
    if i not in string.ascii_lowercase:
        flag = False

if flag:
    print("AC")
else:
    print("WA")
Problem p03290 (Python) — buggy submission, verdict: Runtime Error

import itertools
import math

D, G = map(int, input().split())

p = {}
c = {}
s = {}
for i in range(1, D + 1):
    pi, ci = map(int, input().split())
    score = 100 * i * pi + ci
    s[i] = score
    p[i] = pi
    c[i] = ci


def complete(pset):
    score = 0
    solved = 0
    comped = set()
    for i, b in zip(range(1, D + 1), pset):
        if b:
            score += s[i]
            solved += p[i]
            comped.add(i)
    leftset = set(list(range(1, D + 1))) - comped
    return score, solved, leftset


def left(norm, leftset):
    if norm <= 0 or len(leftset) == 0:
        return 0
    i = max(leftset)
    res = int(math.ceil(norm / (100 * i)))
    if res < p[i]:
        return res
    return float("inf")


ans = float("inf")
for pset in itertools.product((True, False), repeat=D):
    score, solved, leftset = complete(pset)
    solved += left(G - score, leftset)
    ans = min(ans, solved)

print(ans)


Error: ZeroDivisionError: division by zero
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03290/Python/s095921582.py", line 43, in <module>
    solved += left(G - score, comped_max)
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03290/Python/s095921582.py", line 34, in left
    res = int(math.floor(norm / (100 * i)))
ZeroDivisionError: division by zero


Fixed submission:

# 解法は正しいはずだがコーナーケースに引っかかるらしくWAが1個出る

import itertools
import math

D, G = map(int, input().split())

p = {}
c = {}
s = {}
for i in range(1, D + 1):
    pi, ci = map(int, input().split())
    score = 100 * i * pi + ci
    s[i] = score
    p[i] = pi
    c[i] = ci


def complete(pset):
    score = 0
    solved = 0
    comped_max = 0
    for b in pset:
        if b:
            score += s[i]
            solved += p[i]
            comped_max = max(comped_max, i)
    return score, solved, comped_max


def left(norm, i):
    if norm <= 0:
        return 0
    res = int(math.floor(norm / (100 * i)))
    if res < p[i]:
        return res
    return float("inf")


ans = float("inf")
for pset in itertools.product((True, False), repeat=D):
    score, solved, comped_max = complete(pset)
    solved += left(G - score, comped_max)
    ans = min(ans, solved)

print(ans)
Problem p03291 (Python) — buggy submission, verdict: Time Limit Exceeded

mod = 1000000007

S = input()
n = 1
a = 0
ab = 0
abc = 0
for s in S:
    if s in "A":
        a += n
    if s in "B":
        ab += a
    if s == "C":
        abc += ab
    if s in "?":
        n, a, ab, abc = 3 * n, 3 * a + n, 3 * ab + a, 3 * abc + ab
    n %= mod
    a %= mod
    ab %= mod
    abc %= mod

print(abc % mod)


Error: TLE

Fixed submission:

mod = 1000000007

S = input()
n = 1
a = 0
ab = 0
abc = 0
for s in S:
    if s in "A":
        a += n
    if s in "B":
        ab += a
    if s == "C":
        abc += ab
    if s in "?":
        n, a, ab, abc = 3 * n, 3 * a + n, 3 * ab + a, 3 * abc + ab

print(abc % mod)
Problem p03292 (Python) — buggy submission, verdict: Runtime Error

A = [int(x) for x in input().split()]

print(max(A) - min(A))


Error: TypeError: unsupported operand type(s) for -: 'map' and 'map'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03292/Python/s076740739.py", line 3, in <module>
    print(max(A) - min(A))
TypeError: unsupported operand type(s) for -: 'map' and 'map'


Fixed submission:

A = [map(int, input().split())]

print(max(A) - min(A))
Problem p03292 (Python) — buggy submission, verdict: Runtime Error

(*a,) = map(int, input().split())
print(max(a) - min(a))


Error: SyntaxError: starred assignment target must be in a list or tuple
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03292/Python/s292492907.py", line 1
    *a = map(int, input().split())
    ^^
SyntaxError: starred assignment target must be in a list or tuple


Fixed submission:

*a = map(int, input().split())
print(max(a) - min(a))
Problem p03292 (Python) — buggy submission, verdict: Runtime Error

a = list(map(int, input().split()))
print(max(a) - min(a))


Error: ValueError: min() arg is an empty sequence
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03292/Python/s403760215.py", line 2, in <module>
    print(max(a) - min(a))
ValueError: min() arg is an empty sequence


Fixed submission:

a = map(int, input().split())
print(max(a) - min(a))
Problem p03292 (Python) — buggy submission, verdict: Runtime Error

A = map(int, input().split())
A = sorted(A)
ans = 0
for i in range(1, 3):
    ans += abs(A[i - 1] - A[i])
print(ans)


Error: ValueError: invalid literal for int() with base 10: ' '
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03292/Python/s889909183.py", line 2, in <module>
    A = sorted(A)
ValueError: invalid literal for int() with base 10: ' '


Fixed submission:

A = map(int, input())
A = sorted(A)
ans = 0
for i in range(1, 3):
    ans += abs(A[i - 1] - A[i])
print(ans)
Problem p03292 (Python) — buggy submission, verdict: Runtime Error

import numpy as np

A = np.array(sorted(map(int, input().split())))
print((A[1:] - A[:-1]).sum())


Error: EOFError: EOF when reading a line
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03292/Python/s772178766.py", line 2, in <module>
    print("Yes" if input() in tuple(s1[i:] + s1[:i] for i in range(len(s1))) else "No")
EOFError: EOF when reading a line


Fixed submission:

s1 = input()
print("Yes" if input() in tuple(s1[i:] + s1[:i] for i in range(len(s1))) else "No")
Problem p03294 (Python) — buggy submission, verdict: Runtime Error

# Modulo Summation
input()
a = list(map(int, input().split()))
x = 1
for i in a:
    x *= i
print(sum(list(map(lambda j: (x - 1) % j, a))))


Error: 0

Fixed submission:

# Modulo Summation
import math
from functools import reduce


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


n = int(input())
a = list(map(int, input().split()))
m = reduce(lcm, a, 1) - 1
print(sum(map(lambda x: m % x, a)))
Problem p03294 (Python) — buggy submission, verdict: Runtime Error

from functools import reduce

n = int(input())
a = list(map(int, input().split()))


def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)


a_lcm = reduce(lambda x, y: (x * y) // gcd(x, y), a)
m = a_lcm - 1
a_mod = [m % ax for ax in a]

print(sum(a_mod))


Error: 0

Fixed submission:

import math
from functools import reduce

n = int(input())
a = list(map(int, input().split()))

a_lcm = reduce(lambda x, y: (x * y) // math.gcd(x, y), a)
m = a_lcm - 1
a_mod = [m % ax for ax in a]

print(sum(a_mod))
Problem p03294 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
a = list(map(int, input().split()))

f = sum(a) - N
print(f)


Error: TLE

Fixed submission:

from functools import reduce


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm_base(x, y):
    return (x * y) // gcd(x, y)


def lcm(numbers):
    return reduce(lcm_base, numbers, 1)


N = int(input())
a = list(map(int, input().split()))

mod = []
for m in range(lcm(a)):
    k = [m % a[i] for i in range(N)]
    mod.append(sum(k))
print(max(mod))