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

Fixed submission:
# https://kmjp.hatenablog.jp/entry/2020/05/10/0900
# 数学的な問題


mod = 998244353

class COM:
    def __init__(self, n, MOD):
        self.n = n
        self.MOD = MOD
        self.fac = [0] * (n+1)
        self.finv = [0] * (n+1)
        self.inv = [0] * (n+1)
        self.fac[0] = self.fac[1] = 1
        self.finv[0] = self.finv[1] = 1
        self.inv[1] = 1
        for i in range(2, n+1):
            self.fac[i] = self.fac[i-1] * i % MOD
            self.inv[i] = MOD - self.inv[MOD % i] * (MOD // i) % MOD
            self.finv[i] = self.finv[i-1] * self.inv[i] % MOD

    def calc(self, k):
        if k < 0:
            return 0
        return self.fac[self.n] * (self.finv[k] * self.finv[self.n-k] % self.MOD) % self.MOD

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

    # 隣り合う組がK以下のパターンを総当たりして解く
    if N > 1:
        cmbclass = COM(N-1, mod)
        cmb = cmbclass.calc
    else:
        cmb = lambda x:1
    res = 0
    for i in range(K+1):
        res += M * cmb(i) % mod * pow(M-1, N-i-1, mod)


    print(res % mod) 


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):

mod = 998244353

class COM:
    def __init__(self, n, MOD):
        self.n = n
        self.MOD = MOD
        self.fac = [0] * (n+1)
        self.finv = [0] * (n+1)
        self.inv = [0] * (n+1)
        self.fac[0] = self.fac[1] = 1
        self.finv[0] = self.finv[1] = 1
        self.inv[1] = 1
        for i in range(2, n+1):
            self.fac[i] = self.fac[i-1] * i % MOD
            self.inv[i] = MOD - self.inv[MOD % i] * (MOD // i) % MOD
            self.finv[i] = self.finv[i-1] * self.inv[i] % MOD

    def calc(self, k):
        if k < 0:
            return 0
        return self.fac[self.n] * (self.finv[k] * self.finv[self.n-k] % self.MOD) % self.MOD

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

    # 隣り合う組がK以下のパターンを総当たりして解く
    cmb = COM(N-1, mod)
    res = 0
    for i in range(K+1):
        res += M * cmb.calc(i) % mod * pow(M-1, N-i-1, mod)

    print(res % mod) 


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

Fixed submission:
N, M = map(int,input().split())
good = [0]*N

H = list(map(int,input().split()))

for j in range(M):
  a, b = map(int,input().split())
  if(H[a-1] == H[b-1]):
    good[a-1] += 1
    good[b-1] += 1
  elif(H[a-1] < H[b-1]):
    good[a-1] += 1
  else:
    good[b-1] += 1
count = 0
for i in range(N):
  if(good[i] == 0):
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
good = [0]*N

H = list(map(int,input().split()))

for j in range(M):
  a, b = map(int,input().split())
  if(H[a-1] == H[b-1]):
    good[a-1] += 1
    good[b-1] += 1
  elif(H[a-1] < H[b-1]):
    good[a-1] += 1
  elif(H[b-1] < H[a-1]:
    good[b-1] += 1
count = 0
for i in range(N):
  if(good[i] == 0):
    count += 1
print(count)
Problem p02699 (python)

Fixed submission:
S, W = map(int, input().split())

if(S > W):
  print("safe")
else:
  print("unsafe")

Buggy submission (verdict: Runtime Error):
S, W = int(input().split())

if(S > W):
  print("safe")
else:
  print("unsafe")
Problem p02701 (python)

Fixed submission:
import collections
N = int(input())
s=[]
for i in range(N):
  s.append(input())
c = collections.Counter(s)
 
print(len(c))

Buggy submission (verdict: Runtime Error):
N = int(input())
s=[]
for i in range(N):
  s.append(input())
num = 0

while(len(s) != 0):
  flag = 0
  a = s[0]
  num += 1
  for i in range(len(s)):
    if(s[0] == s[i]):
      s.remove(a)
    
print(num)

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

s=[]
flag = 0
for i in range(N):
  s.append(input())
num = 0

while(len(s) != 0):
  for i in range(len(s)):
    if(s[0] == s[i]):
      flag += 1
  for i in range(flag):
    s.remove(s[0])
  num += 1
print(num)
Problem p02629 (python)

Fixed submission:
alphabets = [""] + [s for s in "abcdefghijklmnopqrstuvwxyz"]

s = int(input())

nums = []

while s > 0:
  nums.append((s - 1) % 26 + 1)
  s = (s - 1) // 26

res = ""
  
for _ in range(len(nums)):
  res = res + alphabets[nums.pop()]

print(res)

Buggy submission (verdict: Runtime Error):
aalphabets = [""] + [s for s in "abcdefghijklmnopqrstuvwxyz"]

s = int(input())

nums = []

while s > 0:
  nums.append((s - 1) % 26 + 1)
  s = (s - 1) // 26

res = ""
  
for _ in range(len(nums)):
  res = res + alphabets[nums.pop()]

print(res)
Problem p03013 (python)

Fixed submission:
import math

def fib(n):
  if n==1:
    return 1
  elif n<=0:
    return 0
  tmp1,tmp2=1,2
  for _ in range(n-2):
    tmp1,tmp2=tmp2,tmp1+tmp2
  return tmp2

n,m=map(int,input().split())
if m==0:
  print(fib(n)%1000000007)
  exit()
a=[int(input()) for _ in range(m)]
ans=1

if n==2 and a[0]==1:
  print(1)
  exit()

for i in range(m):
  if i==0 and a[0]==1:
    pass
  if i==0 and a[0]!=1:
    ans*=fib(a[i]-1)
  elif i>0 and a[i]-a[i-1]==2:
    pass
  elif i>0 and a[i]-a[i-1]!=2:
  	ans*=fib(a[i]-a[i-1]-2)
  ans%=1000000007
  
if n-a[-1]>1: 
  ans*=fib(n-a[-1]-1)
ans%=1000000007
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]
ans=1

def fib(n):
  if n==1:
    return 1
  elif n<=0:
    return 0
  tmp1,tmp2=1,2
  for _ in range(n-2):
    tmp1,tmp2=tmp2,tmp1+tmp2
  return tmp2

for i in range(m):
  if i==0 and a[0]==1:
    pass
  if i==0 and a[0]!=1:
    ans*=a[i]-1
  elif i>0:
  	ans*=fib(a[i]-a[i-1]-2)
  ans%=1000000007

ans*=fib(n-a[-1]-1)
ans%=1000000007
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]
ans=1

def fib(n):
  if n==1:
    return 1
  elif n<=0:
    return 0
  tmp1,tmp2=1,2
  for _ in range(n-2):
    tmp1,tmp2=tmp2,tmp1+tmp2
  return tmp2

for i in range(m):
  if i==0 and a[0]==1:
    pass
  if i==0 and a[0]!=1:
    ans*=a[i]-1
  elif i>0:
  	ans*=fib(a[i]-a[i-1]-2)
  ans%=1000000007

ans*=fib(n-a[-1]-1)
ans%=1000000007
print(ans)
Problem p02550 (python)

Fixed submission:
def main():
    n,x,m=map(int,input().split())
    visited=[0]*m
    visit_sum=[0]*m
    i=1
    sm=x
    visited[x]=1
    visit_sum[x]=x
    work=x
    while i < n:
        work**=2
        work%=m
        sm+=work
        i+=1
#        print(sm,work)
        if not visited[work]:
            visited[work]=i
            visit_sum[work]=sm
        else :
            break
    else :
        print(sm)
        exit()
    loop_sum=sm-visit_sum[work]
    loop_num=i-visited[work]
    if visited[work]!=1: 
        initial_sum=visit_sum[visited.index(visited[work]-1)]
    else :
        initial_sum=0

    out=initial_sum
#    print(out)
    out+=(n-visited[work]+1)//loop_num*loop_sum
#    print(out)
    work_num=(n-visited[work]+1)%loop_num
    if work_num>0:
        out+=visit_sum[visited.index(visited[work]-1+work_num)]-initial_sum
        
    print(out)

main()

Buggy submission (verdict: Runtime Error):
def main():
    n,x,m=map(int,input().split())
    visited=[0]*m
    visit_sum=[0]*m
    i=1
    sm=x
    visited[x]=1
    visit_sum[x]=x
    work=x
    while i < n:
        work**=2
        work%=m
        sm+=work
        i+=1
#        print(sm,work)
        if not visited[work]:
            visited[work]=i
            visit_sum[work]=sm
        else :
            break
    else :
        print(sm)
        exit()
    loop_sum=sm-visit_sum[work]
    loop_num=i-visited[work]
    initial_sum=visit_sum[visited.index(visited[work]-1)]

    out=initial_sum
#    print(out)
    out+=(n-visited[work]+1)//loop_num*loop_sum
#    print(out)
    work_num=(n-visited[work]+1)%loop_num
    if work_num>0:
        out+=visit_sum[visited.index(visited[work]-1+work_num)]-initial_sum
    print(out)

main()
Problem p02759 (python)

Fixed submission:
import math

n = int(input())
print(math.ceil(n/2))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())

ans = ['' for _ in range(N)]

for _ in range(M):
    s, c = map(str, input().split())
    if (ans[int(s)-1] != '') and (ans[int(s)-1] != c):
        print("-1")
        break
    else:
        ans[int(s)-1] = c
else:
    if (N > 1) and (ans[0] == ''):
        ans[0] = '1'
    ans = ['0' if s == '' else s for s in ans]

    if (N > 1) and (ans[0] == '0'):
        print("-1")
    else:
        print(''.join(ans))
Problem p02622 (python)

Fixed submission:
S = list(i for i in input())
T = list(i for i in input())

counter = 0

while(S != T):
    for i in range(len(S)):
        if S[i] != T[i]:
            S[i] = T[i]
            counter = counter + 1
        else:
            pass

print(counter)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
counter = 0

while(S != T):
    for i in range(len(S)):
        if S[i] != T[i]:
            S[i] = T[i]
            counter = counter + 1
        else:
            pass

print(counter)
Problem p02622 (python)

Fixed submission:
S = input()
T = input()
ans = 0
for i in range(len(S)):
  if(S[i] != T[i]):
    ans += 1
print(str(ans))

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
for i in range(len(S)):
  if(S[i] != T[i]):
    ans += 1
print(str(ans))
Problem p02659 (python)

Fixed submission:
A,B = input().split()
A = int(A)
B = B.replace(".","")
B = int(B)
ans = int((A * B)//100)
print(str(ans))

Buggy submission (verdict: Runtime Error):
A,B = map(input().split())
A = int(A)
B = B.replace(".","")
B = int(B)
ans = int((A * B)//100)
print(str(ans))
Problem p02699 (python)

Fixed submission:
S,W = map(int,input().split())
if(S > W):
  print("safe")
else:
  print("unsafe")

Buggy submission (verdict: Runtime Error):
S,W = int(input().split())
if(S > W):
  print("safe")
else:
  print("unsafe")
Problem p02723 (python)

Fixed submission:
S = input()
if(S[2] == S[3] and S[4] == S[5]):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
S = input()
if(S[3] == S[4] and S[5] == S[6]):
  print("Yes")
else:
  print("No")
Problem p02785 (python)

Fixed submission:
N,K = map(int,input().split())
H = list(map(int,input().split()))
H = sorted(H)[::-1]
del H [0:K]
print(str(sum(H)))

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
H = list(map(int,input().split()))
H = sorted(H)[::-1]
for i in range(K):
  del H[0]
print(str(sum(H)))

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
H = list(map(int,input().split()))
H = sorted(H)[::-1]
for i in range(K):
  del H[0]
print(str(sum(H)))
Problem p02897 (python)

Fixed submission:
N = int(input())
if(N % 2 == 0):
  n = N // 2
else:
  n = (N + 1) // 2
print(str(n / N))

Buggy submission (verdict: Runtime Error):
N = int(input)
n = N / 2
print(str(n / N))
Problem p02989 (python)

Fixed submission:
N = int(input())
d = list(map(int,input().split()))
d = sorted(d)
chuou1 = d[N//2-1]
chuou2 = d[(N//2)]
if(chuou2 - chuou1 < 0):
  print("0")
else:
  print(str(chuou2 - chuou1))

Buggy submission (verdict: Runtime Error):
N = int(input())
d = list(map(int,input().split()))
chuou1 = d[N//2]
chuou2 = d[(N//2)+1]
print(str(chuou2 - chuou1))
Problem p03208 (python)

Fixed submission:
N,K = map(int,input().split())
h = []
ans = 10**10
for i in range(N):
  tmp = int(input())
  h.append(tmp)
h = sorted(h)
for i in range(N-K+1):
  h2 = h[i]
  h3 = h[i+K-1]
  ans = min(h3 - h2,ans)
print(str(ans))

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
h = [0]*N
for i in range(N):
    h[i] = int(input())
h = sorted(h)
ans = 10**10
for i in range(N-2):
    tmp = h[i+K-1] - h[i]
    ans = min(tmp,ans)
print(ans)
Problem p03345 (python)

Fixed submission:
A,B,C,K = map(int,input().split())
if(K == 0):
  ans = A - B
elif(K % 2 == 1):
  ans = B - A
else:
  ans = A - B
if(ans > 10 ** 18):
  print("Unfair")
else:
  print(str(ans))

Buggy submission (verdict: Runtime Error):
A,B,C,K = map(int,input().split())
a,b,c = 0
for i in range(K):
  a = B + C
  b = A + C
  c = A + B
  A = a
  B = b
  C = c
if (abs(A - B) < 10**18):
  print("Unfair")
else:
  print(str(A - B))
Problem p02753 (python)

Fixed submission:
S=str(input())
if len(set(S))==1:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
S=str(input())
if len(set(S))=1:
  print("No")
 else:
  print(Yes)
Problem p03803 (python)

Fixed submission:
A,B=map(int,input().split())
if A==B:
  print("Draw")
elif A==1:
  print("Alice")
elif B==1:
  print("Bob")
elif A>B:
  print("Alice")
else:
  print("Bob")

Buggy submission (verdict: Runtime Error):
A,B=map(int,input().split())
if A==B:
  print("Draw")
elif A==1:
  print("Alice")
elif B==1:
  print(Bob)
elif A>B:
  print("Alice")
else:
  print("Bob")
Problem p02785 (python)

Fixed submission:
N,K = map(int,input().split())
ls = list(map(int,input().split()))
ls.sort(reverse=True)
if N <= K:
    print(0)
else:    
    print(sum(ls[K:N+1]))

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
ls = list(map(int,input().split()))
ls.sort(reverse=True)
for i in range(K):
    ls.pop(0)

print(sum(ls))
Problem p03774 (python)

Fixed submission:
N,M = map(int,input().split())
lsab = []
for i in range(N):
    a,b = map(int,input().split())
    lsab.append([a,b])
lscd = []
for j in range(M):
    c,d= map(int,input().split())
    lscd.append([c,d])

lsans = []
for i in range(N):
    max1 = 4*10**8+100
    ans = 0
    for j in range(M):
        dis = abs(lsab[i][0]-lscd[j][0])+abs(lsab[i][1]-lscd[j][1])
        if dis < max1:
            ans = j+1
            max1 = dis
    lsans.append(ans)

for i in range(N):
    print(lsans[i])

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
lsab = []
for i in range(N):
    a,b = map(int,input().split())
    lsab.append([a,b])
lscd = []
for j in range(M):
    c,d= map(int,input().split())
    lscd.append([c,d])

lsans = []
for i in range(N):
    max1 = 2*10**8+1
    for j in range(M):
        dis = abs(lsab[i][0]-lscd[j][0])+abs(lsab[i][1]-lscd[j][1])
        if dis < max1:
            ans = j+1
            max1 = dis
    lsans.append(ans)

for i in range(N):
    print(lsans[i])

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
lsab = []
for i in range(N):
    a,b = map(int,input().split())
    lsab.append([a,b])
lscd = []
for j in range(M):
    c,d= map(int,input().split())
    lscd.append([c,d])

lsans = []
for i in range(N):
    max1 = 2*10**8+100
    for j in range(M):
        dis = abs(lsab[i][0]-lscd[j][0])+abs(lsab[i][1]-lscd[j][1])
        if dis < max1:
            ans = j+1
            max1 = dis
    lsans.append(ans)

for i in range(N):
    print(lsans[i])

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
lsab = []
for i in range(N):
    a,b = map(int,input().split())
    lsab.append([a,b])
lscd = []
for j in range(M):
    c,d= map(int,input().split())
    lscd.append([c,d])

lsans = []
for i in range(N):
    max1 = 2*10**8+1
    for j in range(M):
        dis = abs(lsab[i][0]-lscd[j][0])+abs(lsab[i][1]-lscd[j][1])
        if dis < max1:
            ans = j+1
            max1 = dis
    lsans.append(ans)

for i in range(N):
    print(lsans[i])

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
lsab = []
for i in range(N):
    a,b = map(int,input().split())
    lsab.append([a,b])
lscd = []
for j in range(M):
    c,d= map(int,input().split())
    lscd.append([c,d])

lsans = []
for i in range(N):
    max1 = 10**8
    for j in range(M):
        dis = abs(lsab[i][0]-lscd[j][0])+abs(lsab[i][1]-lscd[j][1])
        if dis < max1:
            ans = j+1
            max1 = dis
    lsans.append(ans)

for i in range(N):
    print(lsans[i])
Problem p02623 (python)

Fixed submission:
n,m,k = map(int,input().split())

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

a, b = [0], [0]
for i in range(n):
     a.append(a[i] + A[i])
for i in range(m):
     b.append(b[i] + B[i])

ans, j = 0, m
for i in range(n + 1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i + j)

print(ans)

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

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

if k < a[0] and k < b[0]:
    print(0)
    exit()

if sum(a) + sum(b) <= k:
    print(n+m)
    exit()

a_temp = a[0]
b_temp = b[0]
temp = 0
count = 0
hour = 0
i = 0
j = 0

while k > hour:
    
    count += 1
    if a_temp <= b_temp:
        hour += a_temp
        i += 1
        if i == len(a):
            a_temp = 10**10
        else:
            a_temp = a[i]
    else:
        hour += b_temp
        j += 1
        if j == len(b):
            b_temp = 10**10
        else:
            b_temp = b[i]

print(count)
Problem p02659 (python)

Fixed submission:
import math
from decimal import Decimal
n, m = input().split()
x = Decimal(n)
y = Decimal(m)
#print(n,m)
ans = math.floor(x*y)
print(ans)

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

count = 0

def sosu(n,z):
    for i in range(z, int(math.sqrt(n))+1):
        if n%i == 0:
            return i
            break
    return -1

if sosu(n,2) == -1 and n != 1:
    print(1)
    exit()

ans  = 0
z = 2

def hantei(n):
    i = sosu(n,2)
    s = 0
    if sosu(n,2) == -1:
        return True
    if sosu(n,2) > 0:
        s = n ** (1/i)
        if int(s) == math.floor(s):
            #print(n,s)
            return True
        else:
            return False

memo = []

while(n != 1) :
    ans = sosu(n,z)
    print(n,ans,z)
    if ans == -1:
        if memo.count(n) == 0 and hantei(n):
            count +=1
            break
        else:
            break

    if hantei(ans) :
        memo.append(ans)
        z = ans+1
        n = n//ans
        count += 1
    else:
        z = ans +1
    #print(count)



print(count)

Buggy submission (verdict: Runtime Error):
import math
n, m = input().split()
x = decimal(n)
y = decimal(m)
ans = math.floor(x*y)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n, m = input().split()
x = decimal(n)
y = dicimal(m)
ans = math.floor(x*y)
print(ans)
Problem p02711 (python)

Fixed submission:
N = int(input());

if N%10 == 7:
  print("Yes")
elif (N - N%10)%100 == 70:
  print("Yes")
elif (N - N%100) == 700:
  print("Yes") 
else :
  print("No")

Buggy submission (verdict: Runtime Error):

n = int(input())
c = list(input())

r = c.count("R")
g = c.count("G")
b = c.count("B")

ans = r*g*b
count  = 0
sub1 = 0

for i in range(n):
    for j in range(i+1,n):
        if 2*j-i >= n or 2*j-i <0:
            break
        elif c[2*j-i] != c[i] and c[i] != c[j] and c[2*j-i] != c[j]:
                sub1 += 1


print(ans-sub1)
Problem p02759 (python)

Fixed submission:
n = int(input())

if n%2 == 0:
    ans = n//2
else:
    ans = (n+1)//2

print(ans)

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

if n%2 = 0:
    ans = n//2
else:
    ans = (n+1)//2

print(ans)ß
Problem p02777 (python)

Fixed submission:
s,t = input().split()
a,b = map(int,input().split())
u = input()
          
if u == s:
	print(a-1,b)
elif u == t:
    print(a,b-1)
else:
    print(a,b)

Buggy submission (verdict: Runtime Error):
s,t = input().split()
a,b = map(int,input().split()
u = input()
          
if u == s:
	print(a-1,b)
elif u == t:
    print(a,b-1)
else:
    print(a,b)
Problem p02570 (python)

Fixed submission:
d, t, s = map(int, input().split( ))
if d/s <= t:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
d, t, s = map(int, input().split( ))
if d/s <= t:
    print(Yes)
else:
    print(No)

Buggy submission (verdict: Runtime Error):
d, t, s = map(int, input().split())
if s * t => d
    print(Yes)
else:
    print(No)

Buggy submission (verdict: Runtime Error):
d, t, s = map(int, input().split())
if s * d => t
    print(Yes)
else:
    print(No)

Buggy submission (verdict: Runtime Error):
d, t, s = map(int, input().split())
if d/s <= t:
    print(Yes)
else:
    print(No)
Problem p02693 (python)

Fixed submission:
k = int(input())
a, b = map(int, input().split())
if b // k - a // k > 0:
    print('OK')
elif a % k == 0:
    print('OK')
else:
    print('NG')

Buggy submission (verdict: Runtime Error):
k = int(input())
a, b = map(int, input().split())
if a % k == 0:
    print('OK')
elif (b-a) // k >= 1:
    print('OK')
else:
    print(NG)
Problem p02723 (python)

Fixed submission:
S = input()
if S[2] == S[3] and S[4] == S[5]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
S = input()
if S[3] == S[4] and S[5] == S[6]:
    print('Yes')
else:
    print('No')
Problem p02754 (python)

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

x = n % (a + b)
y = n // (a + b) 
ans = a * y + min(x, a)
print(ans)

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

if a == 0:
  print(0)
else:
  x = n % (a + b)
  y = n // (a + b)
  
ans = a * y + min(x, a)
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=input()
n=len(s)
count=0
a=[0 for i in range(n)]
for i in range(3,n):
    a[i]=10**i%2019
if n<4:
    print(0)
else:
    for i in reversed(range(2,n)):
        k=int(s[i-2:i+1])
        h=3
        for j in reversed(range(0,i-2)):
            k=k+a[h]*int(s[j])
            h+=1
            if k%2019==0:
                count+=1
    print(count)
Problem p02759 (python)

Fixed submission:
n=int(input())
if n%2==0:
    print(n//2)
else:
    print(n//2+1)

Buggy submission (verdict: Runtime Error):
a,b,c  = map(int, input().split())
d,e,f  = map(int, input().split())
g,h,i  = map(int, input().split())
n=int(input())
A = []
for j in range(n):
    A.append(int(input()))
if (a in A) and (b in A) and (c in A):
    print("Yes")
elif d in A and e in A and f in A:
    print("Yes")
elif g in A and h in A and i in A:
    print("Yes")
elif a in A and d in A and g in A:
    print("Yes")
elif b in A and e in A and h in A:
    print("Yes")
elif c in A and f in A and i in A:
    print("Yes")
elif a in A and e in A and i in A:
    print("Yes")
elif c in A and e in A and g in A:
    print("Yes")
else:
    print("No")
Problem p02771 (python)

Fixed submission:
a, b,c = map(int, input().split())
if a==b and a!=c:
    print("Yes")
elif a==c and a!=b:
    print("Yes")
elif b==c and a!=b:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())
S = []
for j in range(N):
    S.append(input())
from collections import Counter
S2=collections.Counter(S)
S1=S2.most_common()

S3=[]
S3.append(S1[0][0])
for i in range(1,len(S1)):
    if S1[i][1]==S1[0][1]:
        S3.append(S1[i][0])
    else:
        break
S3=' '.join(sorted(S3))
print(S3)