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

Fixed submission:
s = int(input())


if s >= 30:
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
c= list(input()) 
if c.count('R') == N:
	print(0)
	exit()
div=0
addcnt = 0
if N %2 == 1:
	div =1
	Q = c[int(N/2)]
	# print(Q)
	if Q == 'W':
		addcnt +=1
		# print('QQQ!')
clist_L = c[:int(N/2)]
clist_R = c[int(N/2)+div:]
Lcnt = clist_L.count('W')
Rcnt = clist_R.count('R')
if Lcnt - Rcnt <=0:
	print(Rcnt-addcnt)
else:
	print(Lcnt-Rcnt+addcnt)
Problem p02987 (python)

Fixed submission:
def main():
  s=input()
  flg=0
  if s.count(s[0])!=2:
    flg=1
  s=s.replace(s[0],'')
  if len(s)>0 and s.count(s[0])!=2:
    flg=1
  if flg==1:
    print('No')
  else:
    print('Yes')  
main()

Buggy submission (verdict: Runtime Error):
def main():
  s=input()
  flg=0
  if s.count(s[0])!=2:
    flg=1
  s=s.replace(s[0],'')
  if s.count(s[0])!=2:
    flg=1
  if flg==1:
    print('No')
  else:
    print('Yes')  
main()
Problem p03804 (python)

Fixed submission:
def main():
  num = list(map(int,input().split()))
  n=num[0]
  m=num[1]
  a = [input() for i in range(n)]
  b = [input() for i in range(m)]

  flg=0
  
  for i in range(0 , n):
    if m==1 and a[i].find(b[0])!=-1:
      flg=1
      break
    while n-i >= m and a[i].find(b[0])!=-1:
      start=a[i].find(b[0])
      for j in range(1 , m):
        if a[i+j][start:start+m]!=b[j]:
          break
        if j==m-1:
          flg=1
      if flg==1:
        break
      a[i]=a[i][a[i].find(b[0])+1:]
    if flg==1:
        break
        
  if flg==1:
    print("Yes")
  else:
    print("No")

main()

Buggy submission (verdict: Runtime Error):
def main():
  num = list(map(int,input().split()))
  n=num[0]
  m=num[1]
  a = [input() for i in range(n)]
  b = [input() for i in range(m)]

  flg=0
  
  for i in range(0 , n):
    while a[i].find(b[0])!=-1:
      ##print("while",a[i])
      start=a[i].find(b[0])
      for j in range(1 , m):
        ##print("i=",i)
        ##print("j=",j)
        ##print("a[i+j]=",a[i+j])
        if a[i+j][start:start+m]!=b[j]:
          break
        if j==m-1:
          flg=1
      if flg==1:
        break
      a[i]=a[i][a[i].find(b[0])+1:]
    if flg==1:
        break
        
  if flg==1:
    print("Yes")
  else:
    print("No")

main()
Problem p02594 (python)

Fixed submission:
x=int(input())
ans=0
if 30<=x:
    ans='Yes'
else:
    ans='No'
print(ans)

Buggy submission (verdict: Runtime Error):
x=int(input())
ans=0
if 30=<x:
    ans='Yes'
else:
    ans='No'
print(ans)
Problem p02753 (python)

Fixed submission:
S=input()
list(S)
if S[0]==S[1] and S[1]==S[2]:
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
S=input()
list(S)
if S[0]==S[1]==s[2]:
  print('No')
else:
  print('Yes')
Problem p02676 (python)

Fixed submission:
k = int(input())
s = input()

if len(s) <= k:
  print(s)
else:
  print(s[:k] + "...")

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

if len(s) <= k:
  print(s)
else:
  print(s[:k] + ...)
Problem p02595 (python)

Fixed submission:
N, D = map(int, input().split())

x = [0] * N
y = [0] * N

for i in range(N):
  x[i], y[i] = map(int, input().split())
  
counter = 0

for i in range(N):
  dist = x[i] * x[i] + y[i] * y[i]
  if dist <= D*D:
    counter += 1

print(counter)

Buggy submission (verdict: Runtime Error):
N, D = input().split()

x = [0] * N
y = [0] * N

for i in range(N):
  x[i], y[i] = map(int, input().split())
  
counter = 0

for i in range(N):
  dist = x[i] * x[i] + y[i] * y[i]
  if dist <= D*D:
    counter += 1

print(counter)

Buggy submission (verdict: Runtime Error):
N, D = input().split()

x = [0] * N
y = [0] * N

for i in range(N):
  x[i], y[i] = map(int, input().split())
  
counter = 0

for i in range(N):
  dist = x[i] * x[i] + y[i] * y[i]
  if dist <= D:
    counter += 1

print(counter)

Buggy submission (verdict: Runtime Error):
import math

N, D = input().split()

x = [0] * N
y = [0] * N

for i in range(N):
  x[i], y[i] = map(int, input().split())
  
counter = 0

for i in range(N):
  dist = x[i] * x[i] + y[i] * y[i]
  if dist <= D:
    counter += 1

print(counter)
Problem p02594 (python)

Fixed submission:
def main():
    x = int(input())
 
    if x >= 30:
        print("Yes")
    else:
        print("No")
main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.reaedline

def main():
	x = int(input())

	if x >= 30:
      print("Yes")
    else:
      print("No")
main()
Problem p02596 (python)

Fixed submission:
import sys
input=sys.stdin.readline


def main():
    k = int(input())

    if k % 2 == 0:
        print(-1)
        return

    rest = [7 % k]

    for i in range(k):
        rest.append(rest[-1] * 10 % k)

    tmp = 0
    for i in range(k):
        if (tmp + rest[i]) % k == 0:
            print(i + 1)
            return
        else:
            tmp = (tmp + rest[i]) % k
    else:
        print(-1)
main()

Buggy submission (verdict: Runtime Error):
import sys
input - sys.stdin.readline
def main():
    K = int(input())
    
    if K%2==0:
        print(-1)
        return
    
    if K % 7:
        L = 9*K
    else:
        L = 9*K//7
    a = 1
    for i in range(1,K+10):
        a = (a * 10) % L
        if a == 1:
            print(i)
            return
    print(-1)
main()
Problem p02598 (python)

Fixed submission:
import sys
input = sys.stdin.readline

def main():
    N,K = map(int, input().split())
    A = list(map(int, input().split()))
    
    l,r = 0, max(A)
    while l < r-1:
        mid = (l+r)//2
        cnt = 0
        for a in A:
            if a % mid:
                cnt+= a//mid
            else:
                cnt += a//mid - 1
            
        if cnt <= K:
            r = mid
        else:
            l = mid
    print(r)
    
main()

Buggy submission (verdict: Runtime Error):
input = open("input.in").readline

def main():
    N,K = map(int, input().split())
    A = list(map(int, input().split()))
    
    l,r = 0, max(A)
    while l < r-1:
        mid = l + (r-l)//2
        cnt = 0
        for a in A:
            cnt+= a//mid
            
        if cnt <= K:
            r = mid
        else:
            l = mid
    print(r)
    
main()
Problem p02594 (python)

Fixed submission:
X=int(input())
if X<30:
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
if X<29:
  print('No')
else:
  print('Yes')
Problem p02595 (python)

Fixed submission:
import math
 
N, D = list(map(int, input().split(' ')))
 
cnt = 0
def check(p, q):
  r = p**2 + q**2
  return math.sqrt(r)
 
for i in range(N):
  p, q = list(map(int, input().split(' ')))
  if check(p, q) <= D:
    cnt += 1
 
print(cnt)

Buggy submission (verdict: Runtime Error):
import math

N, D = list(map(int, input().split(' ').rstrip()))

cnt = 0
def check(p, q):
  r = p**2 + q**2
  return math.sqrt(r)

for i in range(N):
  p, q = list(map(int, input().split(' ').rstrip()))
  if check(p, q) <= D:
    cnt += 1

print(cnt)
Problem p02723 (python)

Fixed submission:
s = input()
ret = "No"
if s[2] == s[3] and s[4]==s[5]:
    ret = "Yes"
print("{}".format(ret))

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

zero = False
if 0 in a:
    a.remove(0)
    n = n - 1
    zero = True
    #print("contain 0.")

l1 = a[n-1] - a[0]  # 0を通らない側
l2 = a[0] + k - a[n-1]  # 0を通る側
if zero == True:
    ret = l2
else:
    ret = l1 if l1 < l2 else l2
print("{}".format(ret))
Problem p02623 (python)

Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, 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 = [int(x) for x in input().strip().split()]
A = [int(x) for x in input().strip().split()]
B = [int(x) for x in input().strip().split()]
i = j = 0
ct = 0
while k > 0: 
  if i < N: 
    if A[i] < B[j] and k-A[i] >= 0: 
      ct +=1
      k -= A[i]
      i += 1
      continue
  if j < M: 
    if k-B[j] >= 0: 
      ct +=1
      k -= B[j]
      j +=1
    else: 
      break
  else: 
    break
print(ct)

Buggy submission (verdict: Runtime Error):
N, M, K = [int(x) for x in input().strip().split()]
A = [int(x) for x in input().strip().split()]
B = [int(x) for x in input().strip().split()]
i = j = 0
ct = 0
while k > 0: 
  if i < N: 
    if A[i] < B[j] and k-A[i] >= 0: 
      ct +=1
      k -= A[i]
      i += 1
      continue
  if j < M: 
    if k-B[j] >= 0: 
      ct +=1
      k -= B[j]
      j +=1
    else: 
      break
  else: 
    break
print(ct)

Buggy submission (verdict: Runtime Error):
Source Code 

Copy
Copy
N, M, K = [int(x) for x in input().strip().split()]
A = [int(x) for x in input().strip().split()]
B = [int(x) for x in input().strip().split()]
i = j = 0
ct = 0
while k > 0: 
  if i < N: 
    if A[i] < B[j] and k-A[i] >= 0: 
      ct +=1
      k -= A[i]
      i += 1
      continue
  if j < M: 
    if k-B[j] >= 0: 
      ct +=1
      k -= B[j]
      j +=1
    else: 
      break
  else: 
    break
print(ct)
print(ct)

Buggy submission (verdict: Runtime Error):
N, M, K = [int(x) for x in input().strip().split()]
A = [int(x) for x in input().strip().split()]
B = [int(x) for x in input().strip().split()]
i = j = 0
ct = 0
while k> 0: 
  if A[i] < B[j] and k-A[i] > 0: 
    k -= A[i]
    i +=1
    ct +=1
  elif k-B[j] > 0: 
    k -= B[j]
    j +=1
  	ct += 1
print(ct)

Buggy submission (verdict: Runtime Error):
N, M, K = [int(x) for x in input().strip().split()]
A = [int(x) for x in input().strip().split()]
B = [int(x) for x in input().strip().split()]
i = j = 0
ct = 0
while k > 0: 
  if A[i] < B[j] and k - A[i] > 0: 
    k -= A[i]
    i +=1
  elif k - B[j] > 0: 
    k -= B[j]
    j +=1
  ct += 1
print(ct)

Buggy submission (verdict: Runtime Error):
N, M, K = [int(x) for x in input().strip().split()]
A = [int(x) for x in input().strip().split()]
B = [int(x) for x in input().strip().split()]
i = j = 0
ct = 0
while k > 0: 
  if A[i] < B[j]: 
    k -= A[i]
    i +=1
  else: 
    k -= B[j]
    j +=1
  ct += 1
print(ct)
Problem p02819 (python)

Fixed submission:
import numpy as np

X = int(input())

def get_primes(n):
    numbers = set(range(n, 1, -1))
    primes = []
    while numbers:
        p = numbers.pop()
        primes.append(p)
        numbers.difference_update(set(range(p*2, n+1, p)))
    return primes

primes = sorted(get_primes(110000))

print(primes[list(np.array(primes) >= X).index(True)])

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

X = int(input())

def get_primes(n):
    numbers = set(range(n, 1, -1))
    primes = []
    while numbers:
        p = numbers.pop()
        primes.append(p)
        numbers.difference_update(set(range(p*2, n+1, p)))
    return primes

primes = sorted(get_primes(100000))

print(primes[list(np.array(primes) >= X).index(True)])

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

X = int(input())

def get_primes(n):
    numbers = set(range(n, 1, -1))
    primes = []
    while numbers:
        p = numbers.pop()
        primes.append(p)
        numbers.difference_update(set(range(p*2, n+1, p)))
    return primes

primes = sorted(get_primes(100000))

print(primes[list(np.array(primes) > X).index(True)])

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

X = int(input())

def get_primes(n):
    numbers = set(range(n, 1, -1))
    primes = []
    while numbers:
        p = numbers.pop()
        primes.append(p)
        numbers.difference_update(set(range(p*2, n+1, p)))
    return primes

primes = sorted(get_primes(10000))

print(primes[list(np.array(primes) > X).index(True)])
Problem p02820 (python)

Fixed submission:
import numpy as np

N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = str(input())

ans = 0
for k in range(K):
    orig_str = T[k::K]
    rep_str = orig_str.replace('rr', 'r').replace('ss', 's').replace('pp', 'p')
    point = rep_str.count('r') * P + rep_str.count('s') * R + rep_str.count('p') * S
    ans += point

print(ans)

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

N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = str(input())

# マシンの出し手を整列させて、K分割してペア作成
# TODO: zero padding
num_split = (N + K - 1) // K
if N % K != 0:
    machine_arr = np.array(list(T) + ['0'] * (N % K)).reshape((-1, num_split), order='F')
else:    
    machine_arr = np.array(list(T)).reshape((-1, num_split), order='F')

ans = 0
for idx in range(machine_arr.shape[0]):
    orig_str = ''.join(machine_arr[idx].tolist())
    rep_str = orig_str.replace('rr', 'r').replace('ss', 's').replace('pp', 'p')
    point = rep_str.count('r') * P + rep_str.count('s') * R + rep_str.count('p') * S
    ans += point

print(ans)
Problem p02831 (python)

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

a, b = list(map(int, input().split()))
print(int(lcm(a, b)))

Buggy submission (verdict: Runtime Error):
import numpy as np
a, b = list(map(int, input().split()))
print(int(np.lcm(a, b)))

Buggy submission (verdict: Runtime Error):
import numpy as np
a, b = list(map(int, input().split()))
print(np.lcm(a, b))
Problem p02595 (python)

Fixed submission:
n,d=map(int,input().split())
c=0
p=d*d
for j in range(n):
    x,y=map(int,input().split())
    if (x**2) + (y**2)<=p:
        c=c+1
print(c)

Buggy submission (verdict: Runtime Error):
n,d=map(int,input().split())
c=0
p=d*d
for j in range(n):
    x,y==map(int,input().split())
    if (x**2) + (y**2)==p:
        c=c+1
print(c)

Buggy submission (verdict: Runtime Error):
n,d=map(int,input().split())
c=0
p=d*d
for j in range(n):
	x,y==map(int,input().split())
    if (x**2) + (y**2)==p:
        c=c+1
print(c)
Problem p02594 (python)

Fixed submission:
N = int(input())
 
if N < 30:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
x = input()

if x >= 30:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
x = int(input())
 
if　x>29:
  print("Yes")
else:
  print("No")

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

if　x>29:
  print("yes")
else:
  print("no")
Problem p02693 (python)

Fixed submission:
K = int(input())
A, B = map(int, input().split())
cnt = 0
while 1:
  cnt+=K
  if A <= cnt <= B:
    print("OK")
    break
  if B < cnt:
    print("NG")
    break

Buggy submission (verdict: Runtime Error):

K = int(input())
A, B = map(int, input().split())
cnt = 0
while true:
  cnt+=K
  if a <= cnt <= b:
    print("OK")
    break
  if b < cnt:
    print("NG")
    break
Problem p02879 (python)

Fixed submission:
# -*- coding: utf-8 -*-
a, b = map(int, input().split())
if a<10 and b<10:
  print(a*b)
else:
  print(0-1)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a, b = map(int, input().split())
if a<10:
  if b<10:
    print(a*b)
    else:
      print('-1')
  else:
    print('-1')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a, b = map(int, input().split())
if a<10:
  if b<10:
    print(a*b)
    else:
      print(-1)
  else:
    print(-1)
Problem p02762 (python)

Fixed submission:
class UnionFind():
    def __init__(self,n):
        self.n = n
        
        # parents が負の時は要素数
        # parents が正の時は親の番号
        self.parents = [-1] * n
 
    # xの根を求める
    def find(self,x):
        if self.parents[x] < 0:
            return x
        else:
            # 根を再帰的に求める
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    # xとyを併合する
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
 
        # 根が同じ場合はreturn
        if x == y:
            return
 
        # ランクを考慮（要素数の少ない木を要素数の多い木に併合）
        if self.parents[x] > self.parents[y]:
            x,y = y,x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    # xの木の要素数を求める
    def size(self,x):
        return - self.parents[self.find(x)]
 
    # xとyが同じ木なのか確かめる
    def same(self,x,y):
        return self.find(x) == self.find(y)
 
 
n, m, k = (int(x) for x in input().split())

uf = UnionFind(n)
n_find = [0] * n

for i in range(m):
    a, b = (int(x) for x in input().split())

    a -= 1
    b -= 1

    n_find[a] += 1
    n_find[b] += 1
    uf.union(a, b)

ans = [uf.size(i) -1 - n_find[i] for i in range(n)] 

for i in range(k):
    c, d = (int(x) for x in input().split())

    c -= 1
    d -= 1

    if uf.same(c, d):
        ans[c] -= 1
        ans[d] -= 1

print(*ans)

Buggy submission (verdict: Runtime Error):
class UnionFind():
    def __init__(self,n):
        self.n = n
        
        # parents が負の時は要素数
        # parents が正の時は親の番号
        self.parents = [-1] * n
 
    # xの根を求める
    def find(self,x):
        if self.parents[x] < 0:
            return x
        else:
            # 根を再帰的に求める
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    # xとyを併合する
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
 
        # 根が同じ場合はreturn
        if x == y:
            return
 
        # ランクを考慮（要素数の少ない木を要素数の多い木に併合）
        if self.parents[x] > self.parents[y]:
            x,y = y,x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    # xの木の要素数を求める
    def size(self,x):
        return - self.parents[self.find(x)]
 
    # xとyが同じ木なのか確かめる
    def same(self,x,y):
        return self.find(x) == self.find(y)
 
 
n, m, k = (int(x) for x in input().split())

uf = UnionFind(n)
n_find = [0] * n

for i in range(n):
    a, b = (int(x) for x in input().split())

    a -= 1
    b -= 1

    n_find[a] += 1
    n_find[b] += 1
    uf.union(a, b)

ans = [uf.size(i) -1 - n_find[i] for i in range(n)] 

for i in range(k):
    c, d = (int(x) for x in input().split())

    c -= 1
    d -= 1

    if uf.same(c, d):
        ans[c] -= 1
        ans[d] -= 1

print(*ans)
Problem p02785 (python)

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

if k >= n:
    print(0)
else:
    h.sort()
    ans = 0
    for i in range(n - k):
        ans += h[i]
        
    print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort(reverse = True)

if k > n:
    print(0)
else:
    for i in range(k):
        h.pop(i)
        
    print(sum(h))
Problem p02873 (python)

Fixed submission:
def gauss(n):
    ans = int (n * (n + 1) / 2)
    return(ans) 

s = input().replace("><", "> <")
new_s = s.split(" ")

a = [0] * len(new_s)

for i in range(len(new_s)):
    if new_s[i].count("<") >= new_s[i].count(">"):
        a[i] = gauss(new_s[i].count("<"))
        a[i] += gauss(new_s[i].count(">") - 1)
    else:
        a[i] = gauss(new_s[i].count(">"))
        a[i] += gauss(new_s[i].count("<") - 1)

print(sum(a))

Buggy submission (verdict: Runtime Error):
def sum_triangle(x):
    if x > 0:
        return x + sum_triangle(x - 1)
    else:
        return 0
    

s = input().replace("><", "> <")
new_s = s.split(" ")

a = [0] * len(new_s)

for i in range(len(new_s)):
    if new_s[i].count("<") >= new_s[i].count(">"):
        a[i] = sum_triangle(new_s[i].count("<"))
        a[i] += sum_triangle(new_s[i].count(">") - 1)
    else:
        a[i] = sum_triangle(new_s[i].count(">"))
        a[i] += sum_triangle(new_s[i].count("<") - 1)

print(sum(a))
Problem p02933 (python)

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

if n >= 3200:
    print(s)
else:
    print("red")

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N, Q = map(int, input().split())
 
AB = [[int(x) for x in input().split()] for _ in range(N-1)] 
PX = [[int(x) for x in input().split()] for _ in range(Q)] 
 
graph = [[] for _ in range(N+1)]
for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)
 
value = [0] * (N+1)
for p, x in PX:
    value[p] +=x
 
def dfs(v, parent, add):
    value[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x, v, value[v])
 
dfs(1, 0, 0)
ans = ' '.join(map(str,value[1:]))
print(ans)

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
 
AB = [[int(x) for x in input().split()] for _ in range(N-1)] 
PX = [[int(x) for x in input().split()] for _ in range(Q)] 
 
graph = [[] for _ in range(N+1)]
for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)
 
value = [0] * (N+1)
for p, x in PX:
    value[p] +=x
 
def dfs(v, parent, add):
    value[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x, v, value[v])
 
dfs(1, 0, 0)
ans = ' '.join(map(str,value[1:]))
print(ans)
Problem p03252 (python)

Fixed submission:
S = input()
T = input()

converter = dict()

for s, t in zip(S, T):
    if converter.get(s) is not None:
        if converter[s] != t:
            print("No")
            break
    else:
        converter[s] = t
else:
    if len(converter.values()) != len(set(converter.values())):
        print("No")
    else:
        print("Yes")

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

b = []

for i in range(len(s)):
    c1 = s[i]
    c2 = t[i]
    if c1 == c2:
        for i in range(len(b)):
            if b[j][0] == c1:
                print("No")
                exit()
    if c1 != c2:
        for j in range(len(b)):
            if b[j][0] == c1 and b[j][1] != c2:
                print("No")
                exit()
            if b[j][0] != c1 and b[j][1] == c2:
                print("No")
                exit()
            if b[j][0] == c1 and b[j][1] == c2:
                break
        else:
            b.append([c1, c2])
else:
    print("Yes")

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

b = []

for i in range(len(s)):
    c1 = s[i]
    c2 = t[i]
    if c1 == c2:
        if b[j][0] == c1:
            print("No")
            exit()
    if c1 != c2:
        for j in range(len(b)):
            if b[j][0] == c1 and b[j][1] != c2:
                print("No")
                exit()
            if b[j][0] != c1 and b[j][1] == c2:
                print("No")
                exit()
            if b[j][0] == c1 and b[j][1] == c2:
                break
        b.append([c1, c2])
else:
    print("Yes")

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

a = [chr(i + ord("a")) for i in range(26)]
b = []

for i in range(len(s)):
    if s[i] != t[i]:
        c1 = s[i]
        c2 = t[i]
        if c2 not in a:
            for j in range(len(b)):
                if b[j][1] == c2 and b[j][0] != c1:
                    print("No")
                    exit()
        a.remove(c2)
        b.append([c1, c2])
else:
    print("Yes")
Problem p03617 (python)

Fixed submission:
Q, H, S, D = map(int, input().split())
N = int(input())

PS = [[Q * 8, 0.25], [H * 4, 0.5], [S * 2, 1], [D, 2]]

PS.sort(key=lambda x: x[0])


R = N
ans = 0
for i in range (4):
    if R == 0:
        break
    elif R >= PS[i][1]:
        ans += int(PS[i][0] * PS[i][1] // 2 * (R // PS[i][1]))
        R = R % PS[i][1]

print(ans)

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

PS = [[Q * 4, 0.25], [H * 2, 0.5], [S, 1], [D / 2, 2]]

PS.sort(key=lambda x: x[0])

# print(PS)

R = N
ans = 0
for i in range (4):
    if R == 0:
        break
    elif R >= PS[i][1]:
        ans += PS[i][0] * PS[i][1] * (R // PS[i][1])
        R = R % PS[i][1]
    # print("ans :", ans)

print(int(ans))