Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03290 (python)

Fixed submission:
def main():
    from math import ceil
    d, g, *pc = map(int, open(0).read().split())
    p, c = pc[::2], pc[1::2]

    ans = sum(p)

    for i in range(2 ** d - 1):
        tmp = g
        count = 0
        # i は集合の表現 ex 1001101
        for j in range(d):
            # iのj桁目が1はどうか
            if i >> j & 1:
                # process
                tmp -= (c[j] + 100 * (j + 1) * p[j])
                count += p[j]

        j = d - 1
        while i >> j & 1:
            j -= 1

        if tmp <= 0:
            ans = min(ans, count)
            continue
        else:
            k = ceil(tmp / ((j + 1) * 100))
            if k >= p[j]:
                continue
            else:
                count += k
                ans = min(count, ans)

    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    from itertools import combinations_with_replacement
    from fractions import ceil
    d, g, *pc = map(int, open(0).read().split())
    p, c = pc[::2], pc[1::2]
    ans = 0
    l = range(d)
    for x in combinations_with_replacement(l, d):
        y = list(set(x))
        tmp = g
        count = 0
        for i in y:
            tmp -= (i + 1) * 100 * p[i] + c[i]
            count += p[i]
        if tmp >= g:
            ans = min(ans, count)
        else:
            j = max(y)
            if j == d - 1:
                j -= 1
            else:
                j += 1
            k = ceil(tmp / (100 * (j + 1)))
            if k < p[j]:
                count += k
                ans = min(ans, count)

    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    from itertools import combinations_with_replacement
    from math import ceil
    d, g, *pc = map(int, open(0).read().split())
    p, c = pc[::2], pc[1::2]
    ans = 0
    l = range(d)
    for x in combinations_with_replacement(l, d):
        y = list(set(x))
        tmp = g
        count = 0
        for i in y:
            tmp -= (i + 1) * 100 * p[i] + c[i]
            count += p[i]
        if tmp >= g:
            ans = min(ans, count)
        else:
            j = max(y)
            if j == d - 1:
                j -= 1
            else:
                j += 1
            k = ceil(tmp / (100 * (j + 1)))
            if k < p[j]:
                count += k
                ans = min(ans, count)

    print(ans)


if __name__ == '__main__':
    main()
Problem p03303 (python)

Fixed submission:
s,w=str(input()),int(input())
y="".join([s[i] for i in range(0,len(s),w)])
print(y)

Buggy submission (verdict: Runtime Error):
s=str(input())
y="".join([s[i] for i in range(0,len(s),w)])
print(y)
Problem p03328 (python)

Fixed submission:
a,b=map(int,input().split())
print((b-a)*(b-a+1)//2-b)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
print((b-a-1)(b-a-2)/2)
Problem p03331 (python)

Fixed submission:
n=int(input())
m=100000
for x in range(1,n//2+1):
  y=n-x
  x,y=list(str(x)),list(str(y))
  z=sum(list(map(int,x)))+sum(list(map(int,y)))
  m=min(m,z)
print(m)

Buggy submission (verdict: Runtime Error):
n=int(input())
m=0
for x in range(n//2):
  y=n-x
  x,y=list(x),list(y)
  z=sum(list(map(int,x)))+sum(list(map(int,y)))
  m=max(m,z)
print(m)
Problem p03338 (python)

Fixed submission:
n,s,c=int(input()),list(input()),0
for i in range(n):
  h=len(set(s[:i])&set(s[i:]))
  c=max(c,h)
print(c)

Buggy submission (verdict: Runtime Error):
n,s=int(input()),list(input())
c=0
for i in range(len(s)):
  h=len(set(s[:i])&(s[i:]))
  c=max(c,h)
print(c)
Problem p03360 (python)

Fixed submission:
a,b,c=map(int,input().split())
k=int(input())
print((a+b+c-max(a,b,c))+max(a,b,c)*2**k)

Buggy submission (verdict: Runtime Error):
a,b,c,k=map(int,input().split()),int(input())
print((a+b+c-max(a,b,c))+max(a,b,c)*2**k)
Problem p03361 (python)

Fixed submission:
def main():
    h, w = map(int, input().split())

    m = []
    wall = ['.' for _ in range(w + 2)]
    m.append(wall)
    for _ in range(h):
        r = ["."] + list(input()) + ["."]
        m.append(r)
    m.append(wall)

    for i in range(1, h + 1):
        for j in range(1, w + 1):
            if m[i][j] == '#':
                f = any([m[i + x][j + y] == "#" for (x, y) in ((1, 0), (-1, 0), (0, 1), (0, -1))])
                if not f:
                    print("No")
                    exit()
    else:
        print("Yes")


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    h, w = map(int, input().split())

    m = []
    wall = ['.' for _ in range(w + 2)]
    m.append(wall)
    for _ in range(w):
        r = ["."] + list(input()) + ["."]
        m.append(r)
    m.append(wall)

    for i in range(1, h + 1):
        for j in range(1, w + 1):
            if m[i][j] == '#':
                f = any([m[i + x][j + y] == "#" for (x, y) in ((1, 0), (-1, 0), (0, 1), (0, -1))])
                if not f:
                    print("No")
                    exit()
    else:
        print("Yes")


if __name__ == '__main__':
    main()
Problem p03378 (python)

Fixed submission:
n,m,x=map(int,input().split())
s=sum(int(i)<x for i in input().split())
print(min(s,m-s))

Buggy submission (verdict: Runtime Error):
n,m,x = map(int,input().split())
a = [int(input()) for _ in range(m)]
c = sum(0+a[i] for i in range(len(a)) if x<i)
print(c)
Problem p03400 (python)

Fixed submission:
n=int(input())
d,x=map(int,input().split())
ans=x+n
for _ in range(n):
  ans+=(d-1)//int(input())
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
d,x=map(int,input().split())
print(sum(d//(int(input()+1) for _ in range(n))))
Problem p03424 (python)

Fixed submission:
n=input()
print("Four" if len(set(map(str,input().split())))==4 else "Three")

Buggy submission (verdict: Runtime Error):
n=input()
print("Four" if len(set(map(int,input().split())))==4 else "Three")
Problem p03427 (python)

Fixed submission:
def main():
    n = int(input())
    l = len(str(n))
    v = int(str(n)[0]) + 9 * (l - 1)
    if str(n)[1:] == '9' * (l - 1):
        print(v)
    else:
        print(v-1)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    l = len(str(n))
    v = int(str(n)[0]) + 9 * (l - 1)
    if str(n)[1:] == '9' * (l - 1):
        print(ans)
    else:
        print(v-1)

if __name__ == '__main__':
    main()
Problem p03474 (python)

Fixed submission:
a,b=map(int,input().split())
s=str(input())
f= s[a]=="-" and len(s)==a+b+1 and s.count("-")==1
print("Yes" if f is True else "No")

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
s=str(input())
f= s[a]=="-" and len(s)==a+b+1
print("Yes" if f is True else "No')
Problem p03494 (python)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
ans=1000
for i in l:
  t=0
  while(i%2==0):
    i=i//2
    t+=1
  ans=min(ans,t)
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
ans=0
for i in l:
  t=0
  while(i%2=0):
    i=i//2
    t+=1
  ans=min(ans,t)
print(ans)
Problem p03502 (python)

Fixed submission:
x=int(input())
print("Yes" if x%sum(map(int,str(x)))==0 else "No")

Buggy submission (verdict: Runtime Error):
x=int(input())
print("Yes" if x%sum(list(str(x)))==0 else "No")
Problem p03504 (python)

Fixed submission:
def main():
    from itertools import accumulate
    n, c, *stc = map(int, open(0).read().split())
    table = [0] * 2 * (10 ** 5 + 1)
    m = list(zip(stc[::3], stc[1::3], stc[2::3]))
    m.sort(key=lambda a: (a[2], a[0], a[1]))

    ch_ = 0
    t_ = 0
    for s, t, ch in m:
        if ch != ch_:
            ch_ = ch
            t_ = 0
        if t_ == 2 * s:
            table[t_ + 1] += 1
        else:
            table[2 * s - 1] += 1

        table[2 * t + 1] -= 1
        t_ = 2 * t

    *x, = accumulate(table)
    ans = max(x)

    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    from itertools import accumulate
    n, c, *stc = map(int, open(0).read().split())
    table = [0] * (10 ** 5 + 2)
    m = list(zip(stc[::3], stc[1::3], stc[2::3]))
    m = sorted(key=lambda a: (a[2], a[0], a[1]))

    ch_ = 0
    t_ = 0
    for s, t, ch in m:
        if ch != ch_:
            ch_ = ch
            t_ = 0
        if t_ == s:
            table[t_ + 1] += 1
        else:
            table[s] += 1

        table[t + 1] -= 1
        t_ = t

    *x, = accumulate(table)
    ans = max(x)

    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    from itertools import accumulate
    n, c, *stc = map(int, open(0).read().split())
    table = [0] * (10 ** 5 + 1)
    m = list(zip(stc[::3], stc[1::3], stc[2::3]))
    m.sort(key=lambda a: (a[2], a[0], a[1]))

    ch_ = 0
    t_ = 0
    for s, t, ch in m:
        if ch != ch_:
            ch_ = ch
            t_ = 0
        if t_ == s:
            table[t_ + 1] += 1
        else:
            table[s] += 1

        table[t + 1] -= 1
        t_ = t

    *x, = accumulate(table)
    ans = max(x)

    print(ans)


if __name__ == '__main__':
    main()
Problem p03523 (python)

Fixed submission:
def main():
    import re

    f = re.match('A?KIHA?BA?RA?$',input())
    print('YES'if f else 'NO')


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    s = str(input())
    t = 'AKIHABARA'
    i = 0

    for u in t:
        if s[i] == u:
            i += 1
        if i == len(t):
            print('YES')
            break
    else:
        print('NO')


if __name__ == '__main__':
    main()
Problem p03568 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
e=sum(x%2==0 for x in a)
print(3**n-2**e)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
x,y=sum(x%2==0 for x in l),n-x
print(3**n-2**x)
Problem p03575 (python)

Fixed submission:
import copy


def main():
    # n: 頂点数
    # w: 辺の数
    n, w = map(int, input().split())
    # v -> v ; cost: 0
    d = [[False] * n for i in range(n)]

    # d[u][v] : 辺u-vのコスト(if not: inf)
    e = []
    for i in range(w):
        # edge: u -> v ; cost : z
        u, v = map(lambda x: int(x) - 1, input().split())
        e.append([u, v])
        # 無向グラフを想定
        d[u][v] = True
        d[v][u] = True

    def dfs(graph, visited, x):
        if visited[x]:
            return
        visited[x] = True
        for i in range(n):
            if graph[x][i]:
                dfs(graph, visited, i)

    ans = 0
    for (u, v) in e:
        graph = copy.deepcopy(d)
        graph[u][v] = False
        graph[v][u] = False
        for i in range(n):
            visited = [False for _ in range(n)]
            dfs(graph, visited, i)
            if not all(visited):
                ans += 1
                break
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n, m, *ab = map(int, open(0).read().split())
    e = [set() for _ in range(n)]
    for u, v in zip(*[iter(ab)] * 2):
        e[u - 1].add(v - 1)
        e[v - 1].add(u - 1)

    ans = 0
    for _ in range(m):
        count = 0
        for i, x in enumerate(e):
            if len(x) == 1:
                e[i] = []
                e[x[0]] -= {i}
                count += 1
        if count:
            ans += count
        else:
            print(ans)
            exit()


if __name__ == "__main__":
    main()
Problem p03578 (python)

Fixed submission:
import collections
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
dd,tt=collections.Counter(d),collections.Counter(t)
for k,v in tt.items():
  if dd.get(k)==None:
    print("NO")
    exit()
  elif dd.get(k)<v:
    print("NO")
    exit()
print("YES")

Buggy submission (verdict: Runtime Error):
import collections
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
dd,tt=collections.Counter(d),collections.Counter(t)
for k,v in tt.items():
  h=dd.get(k)>=v
  if h==False or h==None:
    print("NO")
    exit()
print("YES")

Buggy submission (verdict: Runtime Error):
import collections
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
dd,tt=collections.Counter(d),collections.Counter(t)
for k,v in tt.items():
  h=dd.get(k)>=v
  if h==False:
    print("NO")
    exit()
print("YES")
Problem p03592 (python)

Fixed submission:
n,m,k=map(int,input().split())
for i in range(n+1):
  for j in range(m+1):
    s=m*i+n*j-2*i*j
    if s==k:
      print("Yes")
      exit()
print("No")

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
if n%k==0 or m%k==0:
  print("Yes")
  exit()
for i in range(n):
  for j in range(m):
    s=(n*i+m*j-i*j)-i*j
    if s==k:
      print("Yes")
      exit()
print("No")
Problem p03599 (python)

Fixed submission:
def main():
    from itertools import combinations
    a, b, c, d, e, f = map(int, input().split())
    a *= 100
    b *= 100

    water = [a * i + b * j for i in range(f // a + 1) for j in range(f // b + 1)]
    sugar = [c * i + d * j for i in range(f // c + 1) for j in range(f // d + 1)]
    water.sort()
    sugar.sort(reverse=True)

    tmp = 0
    x, y = 0, 0
    for w in water:
        if w == 0:
            continue
        for s in sugar:
            if s + w > f:
                continue
            if s * 100 <= e * w and tmp <= s / (s + w):
                tmp = s / (s + w)
                x = s + w
                y = s
    print(x,y)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    from itertools import product
    a, b, c, d, e, f = map(int, input().split())
    a, b = max(a, b), min(17 19 22 26 55 2802a, b)
    c, d = max(c, d), min(c, d)
    aa, bb, cc, dd = f // (100 * a), f // (100 * b), f // c, f // d
    aaa, bbb, ccc, ddd = range(aa + 1), range(bb + 1), range(cc, -1, -1), range(dd, -1, -1)
    n = 0
    ans = (0, 0)
    for (k, l, j, i) in product(ddd, ccc, bbb, aaa):
        w = 100 * (a * i + b * j)
        s = c * k + d * l

        if w == 0:
            continue

        m = 100 * s / w

        ok = (s + w <= f) and (100 * s <= e * w)
        if ok:
            n = m
            ans = (s + w, s)
            break

    print(ans)


if __name__ == '__main__':
    main()
Problem p03606 (python)

Fixed submission:
n = int(input())
c = 0 
for _ in range(n):
  n,m = map(int,input().split())
  c += m-n+1
print(c)

Buggy submission (verdict: Runtime Error):
n = int(input())
c = 0 
for _ in range(n):
  n,m = map(int,input().split())
  c += m-n+1
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
c = 0 
for _ in range(n):
  n,m = map(int,input().split())
  count += m-n+1
print(count)

Buggy submission (verdict: Runtime Error):
n = input()
c = 0 
for _ in range(n):
  n,m = map(int,input().split())
  count += m-n+1
print(count)
Problem p03608 (python)

Fixed submission:
import sys
read = sys.stdin.read
from itertools import permutations
def main():
    def warshall_floyd(d):
        for k in range(n):
            for i in range(n):
                for j in range(n):
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j])
        return d
 
    n, m, r = map(int, input().split())
    rs = tuple(map(int, input().split()))
    d = [[10**9] * n for _ in range(n)]
    m = map(int, read().split())
    mmm = zip(m, m, m)
    for s, t, dis in mmm:
        s -= 1
        t -= 1
        d[t][s] = d[s][t] = dis
    for j1 in range(n):
        d[j1][j1] = 0
    res = warshall_floyd(d)
    rsp = tuple(permutations(rs))
    result = float('inf')
    for rspe in rsp:
        res_t = 0
        for i1 in range(r - 1):
            res_t += res[rspe[i1]-1][rspe[i1+1]-1]
        result = min(result, res_t)
    print(result)
 
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
from itertools import permutations
def main():
    def warshall_floyd(d):
        for k in range(n):
            for i in range(n):
                for j in range(n):
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j])
        return d
 
    n, m, r = map(int, input().split())
    rs = tuple(map(int, input().split()))
    d = [[10**9] * n for _ in range(n)]
    m = map(int, read().split())
    mmm = zip(m, m, m)
    for s, t, dis in mmm:
        s -= 1
        t -= 1
        d[t][s] = d[s][t] = dis
    for j1 in range(n):
        d[j1][j1] = 0
    res = warshall_floyd(d)
    rsp = tuple(permutations(rs))
    result = float('inf')
    for rspe in rsp:
        res_t = 0
        for i1 in range(r - 1):
            res_t += res[rspe[i1]-1][rspe[i1+1]-1]
        result = min(result, res_t)
    print(result)
 
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    from itertools import permutations

    n, m, r, *x = map(int, open(0).read().split())
    to = x[:r]

    dis = [[float("Inf")] * (n + 1) for _ in range(n + 1)]
    for i in range(1, n + 1):
        dis[i][i] = 0

    for a, b, c in zip(*[iter(x[r:])] * 3):
        dis[a][b] = c
        dis[b][a] = c

    for k in range(1, n + 1):
        for i in range(1, n + 1):
            for j in range(1, n + 1):
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j])

    ans = float("Inf")
    done = set()
    for p in permutations(to, r):
        tmp = 0
        if list(p) in done:
            continue
        q = list(p)
        done.add(sorted(q))
        for i, j in zip(p, p[1:]):
            tmp += dis[i][j]
        ans = min(ans, tmp)

    print(ans)


if __name__ == '__main__':
    main()
Problem p03611 (python)

Fixed submission:
def main():
    from collections import Counter
    n, *a = map(int, open(0).read().split())
    b = Counter(a)
    c = [(k, v) for k, v in b.items()]
    c.sort(key=lambda x: x[0])
    ans = 0
    c = [c[0]] + c + [c[-1]]
    for x, y, z in zip(c, c[1:], c[2:]):
        v = y[0]
        tmp = y[1]
        if v - x[0] == 1:
            tmp += x[1]
        if v - z[0] == -1:
            tmp += z[1]
        ans = max(ans, tmp)

    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    from collections import Counter
    n, *a = map(int, open(0).read().split())
    b = Counter(a)
    c = [[k, v] for k, v in b.items()]
    c.sort(key=lambda x: x[1], reverse=True)
    x = c[0][0]
    al, ar = c[0][1], c[0][1]
    if b.get(x - 1) is not None:
        al += b.get(xl - 1)
    if b.get(x - 2) is not None:
        al += b.get(xl - 2)
    if b.get(x + 1) is not None:
        al += b.get(x + 1)
    if b.get(x + 2) is not None:
        al += b.get(x + 2)

    print(max(al, ar))


if __name__ == '__main__':
    main()
Problem p03633 (python)

Fixed submission:
def main():
    from fractions import gcd
    from functools import reduce

    def cal(a, b):
        t = a * b // gcd(a, b)
        return t

    n, *t = map(int, open(0).read().split())
    ans = reduce(cal, t)
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    from math import gcd
    from functools import reduce
    from operator import mul
    n, *t = map(int, open(0).read().split())
    g = reduce(gcd, t)
    ans = reduce(mul, t) // g
    print(ans)


if __name__ == '__main__':
    main()
Problem p03637 (python)

Fixed submission:
def main():
    n, *a = map(int, open(0).read().split())

    o = sum([i % 2 == 1 for i in a])
    p = sum([i % 4 == 0 for i in a])
    q = sum([i % 2 == 0 for i in a]) - p

    if p + 1 >= o and not q:
        print("Yes")
    elif p >= o and q:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n, *a = map(int, open(0).read().split())

    o = sum([i % 2 == 1 for i in a])
    p = sum([i % 4 == 0 for i in a])
    q = sum([i % q == 0 for i in a]) - p
    
    if p + 1 >= o and not q:
        print("Yes")
    elif p >= 0 and q:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()
Problem p03657 (python)

Fixed submission:
a,b=map(int,input().split())
f=a%3==0 or b%3==0 or (a+b)%3==0
print("Possible" if f==True else "Impossible")

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
b,i,c=10**9,1,True
while(i<n and c):
  p=sum(l[:i])
  q=sum(l[i:])
  if min(b,abs(p-q))!=abs(p-q):
    break
  else:
    b=min(b,abs(p-q))
    i+=1
print(b)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
b,i,c=10**9,1,True
while(i<n and c):
  p=sum(l[:i])
  q=sum(l[i:])
  c=min(b,abs(p-q))==abs(p-q)
  b=min(b,abs(p-q))
  i+=1
print(b)
Problem p03659 (python)

Fixed submission:
n=int(input())
x=list(map(int,input().split()))
a,b=x[0],sum(x)-x[0]
c=abs(a-b)
for i in range(1,n-1):
  a+=x[i]
  b-=x[i]
  c=min(c,abs(a-b))
print(c)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
b,i=l10**9,1
while(i<n):
  p=sum(l[:i])
  q=sum(l[i:])
  b=min(b,abs(p-q))
  i+=1
print(b)
Problem p03673 (python)

Fixed submission:
n,p=int(input()),list(map(int,input().split()))
k= n//2 if n%2==0 else n//2+1
a,b=list(range(0,k)),list(range(k-1,n))[::-1]
c=[]
for x,y in zip(a,b):
  c.append(x)
  c.append(y)
c= c if n%2==0 else c[:-1]
c=c[::-1]
l=list([])
for x,y in zip(c,list(range(n))):
  l.append([x,y])
l=sorted(l)
for i in range(n):
  print(p[l[i][1]],end=" ")

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
print(*A[::-2],*A[N%2::2])
Problem p03696 (python)

Fixed submission:
def main():
    n = int(input())
    s = input()

    l, r = 0, 0

    for i in s:
        if i == ")":
            if l:
                l -= 1
            else:
                r += 1
        else:
            l += 1

    print(r * "(" + s + ")" * l)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    s = input()
    t = s.split(')(')
    if len(t) == 1:
        u = t[0].split('()')
        print(u)
        v = max(len(u[0]), len(u[1])) + 1
        ans = v * '(' + v * ')'
        print(ans)
        exit()

    ans = ''
    for x in t:
        l = len(x) + 1
        ans += l * '(' + l * ')'

    print(ans)


if __name__ == '__main__':
    main()
Problem p03730 (python)

Fixed submission:
a,b,c=map(int,input().split())
x = any((a*i)%b==c for i in range(1,b+1))
print("YES" if x else "NO")

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
x = a%b
print("Yes" if c%x==0 else "No")
Problem p03738 (python)

Fixed submission:
a,b=int(input()),int(input())
if a>b:
  print("GREATER")
elif a<b:
  print("LESS")
else:
  print("EQUAL")

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a>b:
  print("GREATER")
elif a<b:
  print("LESS")
else:
  print("EQUAL")
Problem p03739 (python)

Fixed submission:
n=input()
a=[int(i) for i in input().split()]
def chk(a,t):
    ans=0
    x=0
    for i in a:
        x+=i
        if t==True and x<1:
            ans+=1-x
            x=1
        elif t==False and x>-1:
            ans+=x+1
            x=-1
        t=not t
    return ans
print(min(chk(a,True),chk(a,False)))

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
c,f=0,l[0]/abs(l[0])
s=l[0]
for i in range(1,n):
  t=s+l[i]
  if s*t>=0:
    s=-1*f
    c+=abs(t)+1
  else:
    f=-1*f
    s=s+l[i]
print(int(c))

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
c,f=0,l[0]/abs(l[0])
s=l[0]
for i in range(1,n,1):
  t=s+l[i]
  if s*t>0:
    s=-1*f
    c+=abs(t-s+1)
  else:
    f=-1*f
    s=s+l[i]
print(int(c))