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

Fixed submission:
x1, y1, x2, y2 = map(int, input().split())

a, b = abs(x2 - x1), abs(y1 - y2)

if (x1 <= x2)and(y1 <= y2):
    x3, y3 = x2 - b, y2 + a
    x4, y4 = x3 - a, y3 - b
elif (x1 >= x2)and(y1 <= y2):
    x3, y3 = x2 - b, y2 - a
    x4, y4 = x3 + a, y3 - b
elif (x1 >= x2)and(y1 >= y2):
    x3, y3 = x2 + b, y2 - a
    x4, y4 = x3 + a, y3 + b
elif (x1 <= x2)and(y1 >= y2):
    x3, y3 = x2 + b, y2 + a
    x4, y4 = x3 - a, y3 + b

print(x3, y3, x4, y4)

Buggy submission (verdict: Runtime Error):
x1, y1, x2, y2 = map(int, input().split())

a, b = abs(x2 - x1), abs(y1 - y2)

if (x1 <= x2)and(y1 <= y2):
    x3, y3 = x2 - b, y2 + a
    x4, y4 = x3 - a, y3 - b
elif (x1 > x2)and(y1 < y2):
    x3, y3 = x2 - b, y2 - a
    x4, y4 = x3 + a, y3 - b
elif (x1 > x2)and(y1 > y2):
    x3, y3 = x2 + b, y2 - a
    x4, y4 = x3 + a, y3 + b
elif (x1 < x2)and(y1 > y2):
    x3, y3 = x2 + b, y2 + a
    x4, y4 = x3 - a, y3 + b


print(x3, y3, x4, y4)

Buggy submission (verdict: Runtime Error):
x1, y1, x2, y2 = map(int, input().split())

a, b = abs(x2 - x1), abs(y1 - y2)

if (x1 <= x2)and(y1 <= y2):
    x3, y3 = x2 - b, y2 + a
    x4, y4 = x3 - a, y3 - b
elif (x1 > x2)and(y1 < y2):
    x3, y3 = x2 - b, y2 - a
    x4, y4 = x3 + a, y3 - b
elif (x1 > x2)and(y1 > y2):
    x3, y3 = x2 + b, y2 - a
    x4, y4 = x3 + a, y3 + b
elif (x1 < x2)and(y1 > y2):
    x3, y3 = x2 + b, y2 + a
    x4, y4 = x3 - a, y3 + b


print("{} {} {} {}".format(x3, y3, x4, y4))

Buggy submission (verdict: Runtime Error):
x1, y1, x2, y2 = map(int, input().split())

a, b = abs(x2 - x1), abs(y1 - y2)

print(a, b)

if (x1 <= x2)and(y1 <= y2):
    x3, y3 = x2 - b, y2 + a
    x4, y4 = x3 - a, y3 - b
elif (x1 > x2)and(y1 < y2):
    x3, y3 = x2 - b, y2 - a
    x4, y4 = x3 + a, y3 - b
elif (x1 > x2)and(y1 > y2):
    x3, y3 = x2 + b, y2 - a
    x4, y4 = x3 + a, y3 + b
elif (x1 < x2)and(y1 > y2):
    x3, y3 = x2 + b, y2 + a
    x4, y4 = x3 - a, y3 + b


print("{} {} {} {}".format(x3, y3, x4, y4))
Problem p02831 (python)

Fixed submission:
from fractions import gcd
a,b=map(int,input().split())
print(int(a*b/gcd(a,b)))

Buggy submission (verdict: Runtime Error):
from math import gcd
a,b=map(int,input().split())
print(int(a*b/gcd(a,b)))
Problem p02935 (python)

Fixed submission:
n=int(input())
vs=list(map(int,input().split()))
while not len(vs)==1:
    vs.sort()
    a=vs.pop(0)
    b=vs.pop(0)
    t=(a+b)/2
    vs.append(t)
print(vs[0])

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())
tree = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

xs = [0] * n
for _ in range(q):
    p, x = map(int, input().split())
    xs[p-1] += x

ans = [0] * n

def dfs(u, parent=None):
    ans[u] = ans[parent] + xs[u]
    for v in tree[u]:
        if not v == parent:
            dfs(v, u)

dfs(0, 0)
print(' '.join([str(i) for i in ans]))
Problem p02762 (python)

Fixed submission:
from collections import defaultdict
from collections import Counter

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

fn = defaultdict(lambda: 1)
CD = [0]*K

par = list(range(N))

def root(x):
    S = set()
    S.add(x)
    y = x
    while True:
        if par[y] == y:
            for s in S:
                par[s] = y
            return y
        S.add(y)
        y = par[y]

def unite(x,y):
    rx = root(x)
    ry = root(y)
    par[rx] = ry

for _ in range(M):
    A,B = map(int,input().split())
    A -= 1
    B -= 1
    fn[A] += 1
    fn[B] += 1
    unite(A,B)
    
for _ in range(K):
    C,D = map(int,input().split())
    C -= 1
    D -= 1
    CD[_] = (C,D)

par = [root(x) for x in range(N)]
c = Counter(par)

RESULT = [(c[par[x]] - fn[x]) for x in range(N)]

for C,D in CD:
    if par[C] == par[D]:
        RESULT[C] -= 1
        RESULT[D] -= 1

print(*RESULT,sep=" ")

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
from collections import Counter

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

fn = defaultdict(lambda: 1)
CD = [0]*K

par = list(range(N))

def root(x):
    if par[x] == x:
        return x
    y = root(par[x])
    par[x] = y
    return y

def unite(x,y):
    rx = root(x)
    ry = root(y)
    par[rx] = ry

def same(x,y):
    return root(x) == root(y)

for _ in range(M):
    A,B = map(int,input().split())
    A -= 1
    B -= 1
    fn[A] += 1
    fn[B] += 1
    unite(A,B)
    
for _ in range(K):
    C,D = map(int,input().split())
    C -= 1
    D -= 1
    CD[_] = (C,D)

par = [root(x) for x in range(N)]
c = Counter(par)

RESULT = [(c[par[x]] - fn[x]) for x in range(N)]

for C,D in CD:
    if par[C] == par[D]:
        RESULT[C] -= 1
        RESULT[D] -= 1

print(*RESULT,sep=" ")
Problem p02829 (python)

Fixed submission:
A = int(input())
B = int(input())
print(6-A-B)

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split())
print(6-A-B)
Problem p02912 (python)

Fixed submission:
import heapq

N , M = map(int,input().split())
A = list(map(lambda x:-int(x),input().split()))

heapq.heapify(A)
for _ in range(M):
    largest = heapq.heappop(A)
    largest = -((-largest)//2)
    heapq.heappush(A, largest)

print(-sum(A))

Buggy submission (verdict: Runtime Error):
import heapq

N , M = map(int,input().split())
A = list(map(lambda x:-int(x),input().split()))

heapq.heapify(A)
for _ in range(M):
    largest = heapq.heappop(A)
    largest = -((-largest)//2)
    if largest != 0:
        heapq.heappush(A, largest)

print(-sum(A))
Problem p02762 (python)

Fixed submission:
#create date: 2020-07-03 14:00

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    def find(x):
        if par[x] < 0:
            return x
        else:
            par[x] = find(par[x])
            return par[x]

    def unite(x, y):
        x = find(x); y = find(y)
        if x == y:
            return False
        else:
            if par[x] > par[y]:
                x, y = y, x
            par[x] += par[y]
            par[y] = x
            return True
    def same(x, y):
        return find(x) == find(y)
    def size(x):
        return -par[find(x)]


    n, m, k = na()
    par = [-1] * n
    friend = [0] * n
    block = [list() for i in range(n)]
    for i in range(m):
        a, b = na()
        a -= 1; b -= 1
        unite(a, b)
        friend[a] += 1
        friend[b] += 1
    for i in range(k):
        c, d = na()
        c -= 1; d -= 1
        block[c].append(d)
        block[d].append(c)
    #print(par, fb)
    for i in range(n):
        ans = size(i) - friend[i] - 1
        for b in block[i]:
            if same(i, b):
                ans -= 1
        print(ans, end=" ")
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#create date: 2020-07-03 14:00

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    def find(x):
        if par[x] < 0:
            return x
        else:
            par[x] = find(par[x])
            return par[x]

    def unite(x, y):
        x = find(x); y = find(y)
        if x == y:
            return False
        else:
            if par[x] > par[y]:
                x, y = y, x
            par[x] += par[y]
            par[y] = x
            return True
    def same(x, y):
        return find(x) == find(y)
    
    n, m, k = na()
    par = [-1] * n
    fb = [[0] * n for i in range(n)]
    for i in range(m):
        a, b = na()
        a -= 1; b -= 1
        unite(a, b)
        fb[a][b] = 1
        fb[b][a] = 1
    for i in range(k):
        c, d = na()
        c -= 1; d -= 1
        fb[c][d] = 1
        fb[d][c] = 1
    #print(par, fb)
    for i in range(n):
        ans = 0
        for j in range(n):
            if same(i, j) and fb[i][j]==0 and i != j:
                ans += 1
        print(ans, end=" ")
if __name__ == "__main__":
    main()
Problem p02793 (python)

Fixed submission:
import sys
import math
import functools
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(a, b):
    return a * b // gcd (a, b)
def lcm_n(nums):
    return functools.reduce(lcm, nums)

n = ni()
a = na()
a_lcm = lcm_n(a)
ans = 0
for ai in a:
    ans += a_lcm // ai
ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import math
import functools
import numpy as np
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(a, b):
    return a * b // gcd (a, b)
def lcm_n(nums):
    return functools.reduce(lcm, nums)

n = ni()
a = na()
a_lcm = lcm_n(a)
a = np.array(a)
# ans = 0
# for ai in a:
#     ans += a_lcm // ai
#     ans %= mod
# print(ans)
ans = np.sum(a_lcm // a) % mod
print(ans)
Problem p02951 (python)

Fixed submission:
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement, groupby
from math import floor, ceil, sqrt, factorial, log
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
from itertools import product
import sys
stdin = sys.stdin
mod = 10**9 + 7


def ns(): return stdin.readline().rstrip()


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


a, b, c = na()
print(max(b + c - a, 0))

Buggy submission (verdict: Runtime Error):
import sys
stdin = sys.stdin
from itertools import accumulate

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n = ni()
h = na()
f = h[0]
b = False
for hi in h[1:]:
    if hi > f:
        f = hi
        b = False
    elif hi == f - 1 and not b:
        f = hi
        b = True
    elif hi == f:
        b = True
    else:
        print("No")
        quit()
print("Yes")
Problem p03127 (python)

Fixed submission:
import sys
import math
import itertools
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]
#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


n = ni()
a = na()

ans = a[0]

for ai in a[1:]:
    ans = gcd(ans, ai)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import math
import itertools
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n = ni()
a = na()

ans = a[0]

for ai in a[1:]:
    ans = math.gcd(ans, ai)
print(ans)
Problem p03272 (python)

Fixed submission:
import sys
stdin = sys.stdin

na = lambda: list(map(int, stdin.readline().split()))
n, i = na()

print(n - i + 1)

Buggy submission (verdict: Runtime Error):
na = lambda: list(map(int, stdin.readline().split()))
n, i = na()

print(n - i + 1)
Problem p02550 (python)

Fixed submission:
N,x,MOD = map(int, input().split())
s = x
flag = False
sflag = False
if N == 1:
  flag = True
  sflag = True
  print(s)
for i in range(1,MOD):
  x = (x*x) % MOD
  s += x
  if N == (i+1):
    flag = True
    break
if flag == True:
  if sflag == False:
    print(s)
else:
  t_s = 0
  cnt = 0
  init = x
  for i in range(MOD):
    x = (x*x) % MOD
    t_s += x
    cnt += 1
    if x == init:
      break
  bi = (N-MOD)//cnt
  res = (N-MOD)%cnt
  s += t_s * bi
  for i in range(res):
    x = (x*x) % MOD
    s += x
  print(s)

Buggy submission (verdict: Runtime Error):
N,x,MOD = map(int, input().split())
s = x
t_s = 0
for i in range(2,MOD + 1):
  if N == 1:
    break
  x = (x*x)%MOD
  s += x
  if i == N:
    break
res = N - i
init = x
t_s = x
cnt = 1
for i in range(MOD):
  if N == 1:
    break
  x = (x*x)%MOD
  if x == init:
    break
  cnt += 1
  t_s += x
if not N == 1:
  bai = res // cnt
  res = res %  cnt
  s += t_s * bai
if res > 0:
  for i in range(res):
    x = (x*x)%MOD
    s += x
print(s)

Buggy submission (verdict: Runtime Error):
N,x,MOD = map(int, input().split())
s = x
t_s = 0
for i in range(2,MOD + 1):
  x = (x*x)%MOD
  s += x
  if i == N:
    break
res = N - i
init = x
t_s = x
cnt = 1
for i in range(MOD):
  x = (x*x)%MOD
  if x == init:
    break
  cnt += 1
  t_s += x
bai = res // cnt
res = res %  cnt
s += t_s * bai
if res > 0:
  for i in range(res):
    x = (x*x)%MOD
    s += x
print(s)

Buggy submission (verdict: Runtime Error):
N,x,MOD = map(int, input().split())
s = x
t_s = 0
for i in range(2,MOD + 1):
  x = (x*x)%MOD
  s += x
  if i == N:
    break
res = N - i
init = x
t_s = x
cnt = 1
for i in range(0,MOD):
  x = (x*x)%MOD
  if x == init:
    break
  cnt += 1
  t_s += x
bai = res // cnt
res = res %  cnt
s += t_s * bai
if res > 0:
  for i in range(res):
    x = (x*x)%MOD
    s += x
else:
  pass
print(s)
Problem p02771 (python)

Fixed submission:
line = input().split(' ')
k = set(line)
if len(k) == 2:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
mydict = {}
for i in range(N):
  t = input()
  if t in mydict:
    mydict[t]+=1
  else:
    mydict[t] = 1
max_k_list = [kv[0] for kv in mydict.items() if kv[1] == max(mydict.values())]
max_k_list.sort()
for i in max_k_list:
  print(i)
Problem p03315 (python)

Fixed submission:
j = {
    "-":-1,
    "+":1
    }
l =input()
s = 0
for i in range(len(l)):
  s += j[l[i]]
print(s)

Buggy submission (verdict: Runtime Error):
j = {
    "-":-1,
    "+":1
    }
l =input()
n = input()
s = 0
for i in range(len(l)):
  s += j[l[i]]
print(s)

Buggy submission (verdict: Runtime Error):
j = {
    "-":-1,
    "+":1
    }
l =input().split(" ")
s = 0
for i in range(len(l)):
  s += j[l[i]]
print(s)
Problem p03745 (python)

Fixed submission:
N = int(input())
line = [int(x) for x in input().split(' ')]
count = 1
prev = line[0]
i = 0
while i < len(line):
  if prev == line[i]:
    i += 1
    continue
  elif prev < line[i]:
    for j in range(i,len(line)):
      if line[j] < prev:
        count+=1
        break
      prev = line[j]
    i = j
  elif prev > line[i]:
    for j in range(i,len(line)):
      if line[j] > prev:
        count += 1
        break
      prev = line[j]
    i = j
  prev = line[i]
  i+=1
print(count)

Buggy submission (verdict: Runtime Error):
def solve(ary):
  prev = ary[0]
  mem = "equal"
  for i in ary:
    if prev > i:
      mem = "minus"
      break
    elif prev < i:
      mem = "plus"
      break
  if mem == "minus":
    return M(ary)
  elif mem == "plus":
    return P(ary)
  else:
    return 1

def M(ary):
  prev = ary[0]
  for i in range(len(ary)):
    if ary[i] > prev:
      return solve(ary[i:])+1
    prev = ary[i]
  return 1
    
def P(ary):
  prev = ary[0]
  for i in range(len(ary)):
    if ary[i] < prev:
      return solve(ary[i:])+1
    prev = ary[i]
  return 1

N = int(input())
line = [int(x) for x in input().split(' ')]
print(solve(line))
Problem p03834 (python)

Fixed submission:
line = input().split(',')
print(line[0],line[1],line[2])

Buggy submission (verdict: Runtime Error):
line = input().split(' ')
print(line[0],line[1],line[2])
Problem p02571 (python)

Fixed submission:
s = input()
t = input()

anses = []
for i in range(len(s) - len(t)+1):
  cnt = 0
  for c, d in zip(s[i:i + len(t)], t):
    if c != d:
      cnt += 1
  anses.append(cnt)

print(min(anses))

Buggy submission (verdict: Runtime Error):
s = input()
t = input()

anses = []
for i in range(len(s) - len(t)):
  cnt = 0
  for c, d in zip(s[i:i + len(t)], t):
    if c != d:
      cnt += 1
  anses.append(cnt)

print(min(anses))
Problem p02695 (python)

Fixed submission:
n, m, q = list(map(int, input().split()))
abcd = [list(map(int, input().split())) for _ in range(q)]

import itertools
anses = []
# for A in itertools.product(sum(([i]*n for i in range(1,m+1)),[]), repeat=n):
# for A in itertools.product(range(1, m + 1), repeat=n):

def f(A):
  for ai in range(A[-1], m + 1):
    if len(A) < n:
      f(A + [ai])
    else:
      p = 0
      for a, b, c, d in abcd:
        a -= 1
        b -= 1
        if A[b] - A[a] == c:
          p += d
      anses.append(p)

f([1])
print(max(anses))

Buggy submission (verdict: Runtime Error):
n, m, q = list(map(int, input().split()))
abcd = [list(map(int, input().split())) for _ in range(q)]

import itertools
anses = []
# for A in itertools.product(sum(([i]*n for i in range(1,m+1)),[]), repeat=n):

# for A in itertools.product(range(1, m + 1), repeat=n):


def f(i, A):
  for ai in range(A[-1], m + 1):
    if len(A) < m:
      f(ai, A + [ai])
    else:
      p = 0
      for a, b, c, d in abcd:
        a -= 1
        b -= 1
        if A[b] - A[a] == c:
          p += d
      anses.append(p)


f(0, [1])
print(max(anses))
Problem p02859 (python)

Fixed submission:
r=int(input())

print(r**2)

Buggy submission (verdict: Runtime Error):
n=int(input())

print(r**2)
Problem p02879 (python)

Fixed submission:
a,b=list(map(int,input().split()))

if a<=9 and b<=9:
  print(a*b)
else:
  print('-1')

Buggy submission (verdict: Runtime Error):
n=int(input())

print(n**2)
Problem p03127 (python)

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

import fractions
g = 0
for x in a:
  g = fractions.gcd(g,x)
print(g)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

import math
g = 0
for x in a:
  g = math.gcd(g, x)
print(g)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

import math
g=0
for x in a:
  g=math.gcd(g,x)
print(g)
Problem p02623 (python)

Fixed submission:
from bisect import bisect_right
n, m, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))

for i in range(m):
    b[i+1] += b[i]


def f(time, r):
    ret = bisect_right(r, time) - 1
    return ret


def fa(time):
    return f(time, a)


def fb(time):
    return f(time, b)

ans = 0

for i, ai in enumerate(a):
    k -= ai
    if k < 0:
        break
    ans = max(ans, i + fb(k))

print(ans)

Buggy submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a = list(map(int, input().split())) + [10 ** 10]
b = list(map(int, input().split())) + [10 ** 10]


def dfs(ai, bi, time, finished=False):
    if finished:
        return ai + bi
    
    if ai == n-1 and bi == n-1:
        return ai + bi
    
    if time >= a[ai]:
        ret1 = dfs(ai + 1, bi, time - a[ai])
    else:
        ret1 = dfs(ai, bi, time, finished=True)

    if time >= b[bi]:
        ret2 = dfs(ai, bi + 1, time - b[bi])
    else:
        ret2 = dfs(ai, bi, time, finished=True)

    return max(ret1, ret2)


print(dfs(0, 0, k))

Buggy submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))+[10**10]
b = list(map(int, input().split()))+[10**10]



def dfs(ai, bi, time, finished=False):
    if finished:
        return ai+bi

    if time >= a[ai]:
        ret1 = dfs(ai+1, bi, time-a[ai])
    else:
        ret1 = dfs(ai, bi, time, finished=True)

    
    if time >= b[bi]:
        ret2 = dfs(ai, bi+1, time-b[bi])
    else:
        ret2 = dfs(ai, bi, time, finished=True)

    return max(ret1, ret2)

print(dfs(0, 0, k))
Problem p02629 (python)

Fixed submission:
def base_k(n, k=26):
    ret = []
    ny = n
    while ny:

        ret.append(ny % k)
        ny //= k
    return ret[::-1]


def letter(i):
    return chr(i+97)


def solve(n):
    check = 26
    cnt = 1
    k = n
    while True:
        if n <= check:
            break
        check *= 26
        check += 26
        cnt += 1
    k -= check//26 - 1
    t = base_k(k-1)
    ans = ""
    if not t:
        ans = "a" * cnt
    else:
        for _ in range(cnt):
            if not t:
                ans += "a"
                continue
            ans += letter(t.pop())

    return ans[::-1]


n = int(input())
print(solve(n))

Buggy submission (verdict: Runtime Error):
def base_k(n, k=26):
    ret = []
    ny = n
    while ny:

        ret.append(ny % k)
        ny //= k
    return ret[::-1]


def letter(i):
    return chr(i+97)


n = int(input())

check = 26
add = 26**2
cnt = 1
k = n
while True:
    if n <= check:
        break
    check += add
    cnt += 1
    add *= 26
k -= check//26 - 1

t = base_k(k-1)

ans = ""
if not t:
    ans = "a" * cnt
else:
    for i in range(len(t)-cnt, len(t)):
        ans += letter(t[i])

print(ans)
Problem p02699 (python)

Fixed submission:
s, w = map(int, input().split())

if w >= s:
    print("unsafe")
else:
    print("safe")

Buggy submission (verdict: Runtime Error):
s = int(input())
w = int(input())

if w >= s:
    print("unsafe")
else:
    print("safe")
Problem p02766 (python)

Fixed submission:
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)


n, k = map(int, input().split())
print(len(Base_10_to_n(n, k)))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())


def log(r, d):
    return np.log(d)/np.log(r)


def ceil(x):
    if x.is_integer():
        return int(x)
    return int(np.ceil(x))


print(ceil(log(k, n)))
Problem p02793 (python)

Fixed submission:
from collections import defaultdict
from functools import lru_cache
import math


def trial_division(n):
    factor = defaultdict(int)
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            factor[num] += 1
    factor[n] += 1
    return factor


@lru_cache(maxsize=None)
def powmod(x, y, mod):
    if y == 0:
        return 1
    return (((powmod(x, y >> 1, mod) ** 2) % mod) * x ** (y & 1)) % mod


n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
numbers = defaultdict(int)
for a_i in a:
    for i, v in trial_division(a_i).items():
        numbers[i] = max(v, numbers[i])

l = 1
for i, v in numbers.items():
    l *= powmod(i, v, mod)
    l %= mod


ans = 0
for i in a:
    r = powmod(i, mod-2, mod)
    ans += l * r
    ans %= mod
print(int(ans))

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
import numpy as np


def trial_division(n):
    factor = defaultdict(int)
    tmp = int(np.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            factor[num] += 1
    factor[n] += 1
    return factor


def powmod(x, y, mod):
    if y == 0:
        return 1
    return (((powmod(x, y >> 1, mod) ** 2) % mod) * x ** (y & 1)) % mod


n = int(input())
a = np.array(list(map(int, input().split())))
mod = 10**9 + 7
numbers = defaultdict(int)
for a_i in a:
    for i, v in trial_division(a_i).items():
        numbers[i] = max(v, numbers[i])

l = 1
for i, v in numbers.items():
    l *= i ** v
    l %= mod

r = powmod(a, mod-2, mod)
ans = 0
for i in r:
    ans += l * r
    ans %= mod
print(int(ans))
Problem p02859 (python)

Fixed submission:
r = int(input())
print(r**2)

Buggy submission (verdict: Runtime Error):
import sys
x, y = map(int, input().split())


def power_func(a, b, p):
    if b == 0:
        return 1
    if b % 2 == 0:
        d = power_func(a, b//2, p)
        return d*d % p
    if b % 2 == 1:
        return (a*power_func(a, b-1, p)) % p


def comb(n, k, p):
    from math import factorial
    if n < 0 or k < 0 or n < k:
        return 0
    if n == 0 or k == 0:
        return 1
    a = factorial(n) % p
    b = factorial(k) % p
    c = factorial(n-k) % p
    return (a*power_func(b, p-2, p)*power_func(c, p-2, p)) % p


w = (x + y) / 3
b = (- x + 2*y) // 3

if w.is_integer():
    w = int(w)
else:
    print(0)
    sys.exit()

a = min(b, w-b)
ans = comb(w, a, 10**9+7)
print(ans)