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

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

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
res = sum(b)
for i in range(len(a) - 1):
  if a[i+1] == a[i] + 1:
    res += c[a[i]]
print(res)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
res = sum(b)
for i in range(len(a) - 1):
  if a[i+1] = a[i] + 1:
    res += c[i]
print(res)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
res = sum(b)
for i in len(range(a)) - 1:
  if a[i+1] = a[i] + 1:
    res += c[i]
print(res)
Problem p02951 (python)

Fixed submission:
a, b, c = map(int, input().split())
print(max(0, c-(a-b)))

Buggy submission (verdict: Runtime Error):
n = int(input())
res = 0
keta = 1
for i in range(1, n+1):
  if i % (10 ** keta) == 0:
    keta += 1
  if keta % 2 == 1:
    res += 1
print(res)
Problem p03015 (python)

Fixed submission:
l = input()
dpf = [0] * (len(l) + 2)
dpf[len(l)-1] = 3
mod = 1000000007
for i in range(len(l)-2, -1, -1):
    dpf[i] = (3 * dpf[i+1]) % mod
#print(dpf)
# def dfs(i):
#     if i == len(l)-1:
#         if l[i] == '1':
#             return 3
#         else:
#             return 1
#     if l[i] == '0':
#         return dfs(i+1)
#     return (dpf[i+1] + (dfs(i+1) * 2) % mod) % mod
#
# print(dfs(0))

dp = [0] * (len(l))
dp[-1] = 1
if l[-1] == '1':
    dp[-1] = 3
for i in range(len(l)-2, -1, -1):
    if l[i] == '0':
        dp[i] = dp[i+1]
    else:
        dp[i] = (dpf[i+1] + (dp[i+1]*2)%mod)%mod
print(dp[0])

Buggy submission (verdict: Runtime Error):
pf[len(l)-1] = 3
mod = 1000000007
for i in range(len(l)-2, -1, -1):
    dpf[i] = (3 * dpf[i+1]) % mod
#print(dpf)
def dfs(i):
    if i == len(l):
        return 1
    if l[i] == '0':
        return dfs(i+1)
    return (dpf[i+1] + (dfs(i+1) * 2) % mod) % mod
 
print(dfs(0))

Buggy submission (verdict: Runtime Error):
l = input()
dpf = [0] * (len(l) + 2)
dpf[len(l)-1] = 3
mod = 1000000007
for i in range(len(l)-2, -1, -1):
    dpf[i] = (3 * dpf[i+1]) % mod
#print(dpf)
def dfs(i):
    if i == len(l)-1:
        if l[i] == '1':
            return 3
        else:
            return 1
    if l[i] == '0':
        return dfs(i+1)
    return (dpf[i+1] + (dfs(i+1) * 2) % mod) % mod

print(dfs(0))
Problem p03038 (python)

Fixed submission:
N, M = map(int, input().split())
a = list(map(int, input().split()))
bc = [tuple(map(int, input().split())) for _ in range(M)]
bc.sort(key=lambda x: x[1], reverse=True)
rest = N
for b, c in bc:
  a += [c] * min(rest, b)
  rest -= min(rest, b)
a.sort(reverse=True)
print(sum(a[:N]))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = list(map(int, input().split()))
bc = [tuple(map(int, input().split())) for _ in range(M)]
bc.sort(key=lambda x: x[1], reverse=True)
rest = N
for b, c in bc:
  a += [c] * min(rest, b)
  rest -= min(rest, b)
a.sort(reversed=True)
print(sum(a[:N]))
Problem p03207 (python)

Fixed submission:
N = int(input())
p = [int(input()) for _ in range(N)]
p.sort()
p[-1] //= 2
print(sum(p))

Buggy submission (verdict: Runtime Error):
N = int(input())
p = [int(input()) for _ in range(N)]
p.sort()
p[-1] //= 2
print(p.sum())
Problem p03208 (python)

Fixed submission:
N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]
h.sort()
ans = 1<<31
for i in range(N-K+1):
  ans = min(ans, h[i+K-1]-h[i])
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]
h.sort()
ans = 1<<31
for i in range(N-K)+1:
  ans = min(ans, h[i+K-1]-h[i]
print(ans)
Problem p03209 (python)

Fixed submission:
N, X = map(int, input().split())
pat = [1 for _ in range(N+1)]
mai = [1 for _ in range(N+1)]
for i in range(1, N+1):
  mai[i] = 2 * mai[i-1] + 3
  pat[i] = 2 * pat[i-1] + 1

def cnt_pat(x, n):
  if n == 0:
    return 1
  if x == 1:
    return 0
  if x <= mai[n] // 2:
    return cnt_pat(x-1, n-1)
  if x == mai[n] // 2 + 1:
    return pat[n-1] + 1
  if x < mai[n]:
    return pat[n-1] + 1 + cnt_pat(x-mai[n]//2-1, n-1)
  if x == mai[n]:
    return pat[n]
  
print(cnt_pat(X, N))

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
pat = [1 for _ in range(N+1)]
mai = [1 for _ in range(N+1)]
for i in range(1, N+1):
  mai[i] = 2 * mai[i-1] + 3
  pat[i] = 2 * pat[i-1] + 1

def cnt_pat(x, n):
  if n == 0:
    return 1
  if x == 1:
    return 0
  if x <= mai[n] // 2:
    return cnt_pat(x-1, n-1)
  if x == mai[n] // 2 + 1:
    return pat[n-1] + 1
  if x < mai[n]:
    return pat[n-1] + 1 + cnt_pat(x-mai[n]//2-1, n-1)
  if x == n:
    return pat[n]
  
print(cnt_pat(X, N))

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
pat = [1 for _ in range(N)]
mai = [1 for _ in range(N)]
for i in range(1, N+1):
  mai[i] = 2 * mai[i-1] + 3
  pat[i] = 2 * pat[i-1] + 1

def cnt_pat(x, n):
  if n == 0:
    return 1
  if x == 1:
    return 0
  if x <= mai[n] // 2:
    return cnt_pat(x-1, n-1)
  if x == mai[n] // 2 + 1:
    return pat[n-1] + 1
  if x < mai[n]:
    return pat[n-1] + 1 + cnt_pat(x-mai[n]//2-1, n-1)
  if x == n:
    return pat[n]
  
print(cnt_pat(X, N))

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
pat = [0 for _ in range(N+1)]
mai = [0 for _ in range(N+1)]
pat[1] = 1
mai[1] = 1
for i in range(2, N+1):
  mai[i] = 2 * mai[i-1] + 3
  pat[i] = 2 * pat[i-1] + 1

def cnt_pat(x, n):
  if n == 1:
    return 1
  if x == 1:
    return 0
  if x <= mai[n] // 2:
    return cnt_pat(x-1, n-1)
  if x == mai[n] // 2 + 1:
    return pat[n-1] + 1
  if x < mai[n]:
    return pat[n-1] + 1 + cnt_pat(x-mai[n]//2-1, n-1)
  if x == n:
    return pat[n]
  
print(cnt_pat(X, N))
Problem p03221 (python)

Fixed submission:
N, M = map(int, input().split())
li = [[] for _ in range(N+1)]
for i in range(M):
    p, y = map(int, input().split())
    li[p].append([i, y])
ans = [0 for _ in range(M)]
for i in range(1, N+1):
    iy = li[i]
    iy.sort(key=lambda x: x[1])
    for j in range(len(iy)):
        ans[iy[j][0]] = (i, j+1)
for shi in ans:
    print('{:06d}{:06d}'.format(shi[0], shi[1]))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
li = [[] for _ in range(N+1)]
for i in range(M):
    p, y = map(int, input().split())
    li[p].append([i, y])
ans = [0 for _ in range(M)]
for i in range(1, N+1):
    iy = li[i]
    iy.sort(key=lambda x: x[1])
    for j in range(len(iy)):
        ans[iy[j][0]] = (i, j+1)
for shi in ans:
    print(f'{shi[0]:06}{shi[1]:06}')
Problem p02693 (python)

Fixed submission:
k= int(input())
s= input().rstrip().split()
a = int(s[0])
b = int(s[1])
f = "NG"
for i in range(a,b+1):
  if i%k == 0:
    f = "OK"
if a == b:
  if a%k == 0:
    f = "OK"
print(f)

Buggy submission (verdict: Runtime Error):
k= int(input())
s= input().rsprit().split()
a = int(s[0])
b = int(s[1])
f = "NG"
for i in range(a,b):
  if i%k == 0:
    f = "OK"
print(f)

Buggy submission (verdict: Runtime Error):
入力
入力は以下の形式で標準入力から与えられる。
K
AB
出力
目標の達成が可能であれば OK と、不可能であれば NG と出力せよ。
k= int(input())
s= input().rsprit().split()
a = int(s[0])
b = int(s[1])
f = "NG"
for i in range(a,b):
	if i%k == 0:
  		f = "OK"
print(f)
Problem p03073 (python)

Fixed submission:
S = input()
back = 0
n = 0
for i in S:
    if i == back:
        back = '0' if i=='1' else '1'
        n += 1
    else:
        back = i

print(n);

Buggy submission (verdict: Runtime Error):
S = input()
back = 0
for i in S:
    if i == back:
        back = '0' if i=='1' else '1'
        n += 1
    else:
        back = S

print(n);
Problem p02688 (python)

Fixed submission:
N, K = map(int, input().split())
a = []
for i in range(K):
  di = int(input())
  a += list(map(int, input().split()))

a = set(a)
print(N - len(a))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
a = []
for i in range(K):
  di = int(input())
  for j in range(di):
    a.append(map(int, input().split())

a = set(a)
print(N - len(a))
Problem p02689 (python)

Fixed submission:
N, M = map(int, input().split())
H = list(map(int, input().split()))
a = [True] * N
for i in range(M):
  ai, bi = map(int, input().split())
  if H[ai-1] <= H[bi-1] :
    a[ai-1] = False
  if H[ai-1] >= H[bi-1]:
    a[bi-1] = False
print(sum(a))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
H = list(map(int, input().split()))
a = list(range(1,N+1))
for i in range(M):
  ai, bi = map(int, input().split())
  if H[ai-1] <= H[bi-1] :
    a.remove(ai)
  if H[ai-1] >= H[bi-1]:
    a.remove(bi)
print(len(a))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
H = list(map(int, input().split()))
a = list(range(1,N+1))
for i in range(M):
  ai, bi = map(int, input().split())
  if H[ai-1] < H[bi-1] :
    a.remove(ai)
  else:
    a.remove(bi)
print(len(a))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
H = list(map(int, input().split()))
a = list(range(1,N+1))
for i in range(M):
  ai, bi = map(int, input().split())
  if H[ai+1] < H[bi+1] :
    a.remove(ai)
  else:
    a.remove(bi)
print(len(a))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
H = list(map(int, input().split()))
a = []
[a.append(i) for i in range(1,N+1)]
for i in range(M):
  ai, bi = map(int, input().split())
  if H[ai+1] < H[bi+1] :
    a.remove(ai)
  else:
    a.remove(bi)
print(len(a))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
H = list(map(int, input().split()))
a = []
[a.append(i) for i in range(1,N+1)]
for i in range(M):
  ai, bi = map(int, input().split())
  if ai < bi:
    a.remove(ai)
  else:
    a.remove(bi)
print(len(a))
Problem p02699 (python)

Fixed submission:
s, w = map(int, input().split())
if s <= w:
  print('unsafe')
else:
  print('safe')

Buggy submission (verdict: Runtime Error):
s, w = map(int, input())
if s <= w:
  print('unsafe')
else:
  print('safe')
Problem p02701 (python)

Fixed submission:
n = int(input())
print(len(set(list([input() for _ in range(n)]))))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for _ in n:
  i = str(input())
  a.append(i)
print(len(set(a)))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for _ in n:
  a.append(input())
print(len(set(a)))
Problem p02688 (python)

Fixed submission:
N, K = map(int, input().split())
uid_list = []
for _ in range(K):
   input()
   for uid in [int(i) for i in input().split()]:
       uid_list.append(uid)
print(N - len(set(uid_list)))

Buggy submission (verdict: Runtime Error):
N, K = input().split()
d = []
A = []

for _ in K:
    d.append(input())
    num = d[-1]
    for i in num:
        A.append(input())

for j in max(d)+1:
    if j+1 in A:
        pass
    else:
        print(j+1)

Buggy submission (verdict: Runtime Error):
N, K = input().split()
d = []
A = []
for _ in K:
    d.append(int(input()))
    num = d[-1]
    for i in num:
        A.append(int(input()))

for j in max(d)+1:
    if j+1 in A:
        pass
    else:
        print(j+1)
Problem p02693 (python)

Fixed submission:
K = int(input())
A, B = map(int, input().split())
print("OK" if A <= B//K*K else "NG" )

Buggy submission (verdict: Runtime Error):
K = int(input())
A, B = input().split()

if B - A >= K-1:
    print("OK")
else:
    print("NG")

Buggy submission (verdict: Runtime Error):
K = int(input())
A, B = int(input().split())

if B - A >= K-1:
    print("OK")
else:
    print("NG")
Problem p02695 (python)

Fixed submission:
N, M, Q = map(int, input().split())
lists = [list(map(int, input().split())) for i in range(Q)]
ans = 0

def calc_score(A):
   score = 0
   for a, b, c, d in lists:
       if A[b - 1] - A[a - 1] == c:
           score += d
   return score

def dfs(A):
   global ans
   if len(A) == N:
       score = calc_score(A)
       ans = max(score, ans)
       return
   for n in range(A[-1], M + 1):
       dfs(A + [n])

dfs([1])
print(ans)

Buggy submission (verdict: Runtime Error):
N, M ,Q = map(int, input().aplist())
lists = [list(map(int, input().split())) for i in range(Q)]
ans = 0

def calc_score(A):
    score = 0
    for a, b, c, d in lists:
        if A[b -1] - A[a - 1] == c:
            score += d
    return score

def dfs(A):
    global ans
    if len(A) == N:
        score = calc_score(A)
        ans = max(score, ans)
        return
    for n in range(A[-1], M + 1):
        dfs(A + [n])
        
dfs([1])
print(ans)
Problem p02701 (python)

Fixed submission:
n=int(input())
s=[input() for _ in range(n)]

print(len(set(s)))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=[input() for _ in range(n)]

print(len(type(s)))

Buggy submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
S = []
while True:
    S.append(input())

print(len(Counter(S)))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = []
while True:
    S.append(input())

print(len(Counter(S)))
Problem p02711 (python)

Fixed submission:
n = input()
if '7' in n:
    print('Yes')
else:
    print('No')

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

n = input()
if '7' in N:
    print('Yes')
else:
    print('No')
Problem p02712 (python)

Fixed submission:
N = int(input())

list = [i for i in range(1, N+1) if not (i % 3 == 0 or i % 5 ==0)]

print(sum(list))

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

list = [i for i in range(1, N+1) if  (i % 3 != 0 or i % 5 !=0)]
print(sum(list))

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

list = [i for i in range(1, N+1) if not (i % 3 == 0 or i % 5 ==0)]
print(sum(list))
Problem p02793 (python)

Fixed submission:
from fractions import gcd
from functools import reduce
mod=10**9+7
n=int(input())
a=[int(i) for i in input().split()]
l=reduce(lambda x,y:x//gcd(x,y)*y,a)
ans=sum(map(lambda x:l//x,a))
print(ans%mod)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split()]

import fractions

G = A[0]
for i in range(N):
    G = G * A[i] // fractions.gcd(G, A[i])

ans = 0
for j in range(N):
    ans += G / A[j]

print(ans % (10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split()]

import fractions

G = A[0]
for i in range(N):
    G = G * A[i] // fractions.gcd(G, A[i])

ans = 0
for j in range(N):
    ans += G / A[j]

print(int(ans % (10**9 +7)))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split()]

import math


gcd = A[0]
for i in range(N):
    gcd = gcd * A[i] // math.gcd(gcd, A[i])

ans = 0
for j in range(N):
    ans += gcd / A[j]

print(int(ans % (10**9 +7)))

Buggy submission (verdict: Runtime Error):
import math

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

gcd = A[0]
for i in range(N):
    gcd = gcd * A[i] // math.gcd(gcd, A[i])

ans = 0
for j in range(N):
    ans += gcd / A[j]

print(int(ans % (10**9 +7)))
Problem p02819 (python)

Fixed submission:
import fractions
X = int(input())

half = int(X/2)
i = X
while i >=X:
    for j in range(2,int(i/2)):
        if fractions.gcd(i,j) == 1:
            pass

        else:
            i += 1
            continue

    print(i)
    exit()

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

half = int(X/2)
i = X
while i >=X:
    for j in range(2,int(i/2)):
        if math.gcd(i,j) == 1:
            pass

        else:
            i += 1
            continue

    print(i)
    exit()
Problem p02847 (python)

Fixed submission:
s = input()
week = ["SAT","FRI","THU","WED","TUE","MON","SUN"]
days = week.index(s) + 1
print(days)

Buggy submission (verdict: Runtime Error):
date = input()
A ={"SUN":0, "SAT":6, "FRI":5, "TUE":4, "WED":3, "THU":2, "FRI":1}

print(7 - A[date])

Buggy submission (verdict: Runtime Error):
date = input()
dic ={"SUN":0, "SAT":6, "FRI":5, "TUE":4, "WED":3, "THU":2, "FRI":1}

print(7 - dic[date])

Buggy submission (verdict: Runtime Error):
dic ={"SUN":0, "SAT":6, "FRI":5, "TUE":4, "WED":3, "THU":2, "FRI":1}

print(7 - dic[input()])
Problem p02948 (python)

Fixed submission:
from collections import defaultdict
import heapq
n,m=map(int,input().split())
dic=defaultdict(list)
for i in range(n):
    a,b=map(int,input().split())
    dic[a].append(-b)
    
li=[]
ans=0

for i in range(1,m+1):
    if dic[i]:
        for j in dic[i]:
            heapq.heappush(li,j)
    if li:
        ans+=heapq.heappop(li)
print(-ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
import heapq
n,m=map(int,input().split())
dic=defaultdict(list)
for i in range(n):
    a,b=map(int,input().split())
    dic[a]+=(-b)
    
li=[]
ans=0

for i in range(1,m+1):
    if dic[i]:
        for j in dic[i]:
            heapq.heappush(li,j)
    if li:
        ans+=heapq.heappop(li)
print(-ans)
Problem p03012 (python)

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

mini = float('inf')

for i in range(n):
    s1 = sum(w[0:i+1])
    s2 = sum(w[i+1:n])
    
    mini = min(abs(s2-s1),mini)
        
print(mini)

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

mini = foat('inf')

for i in range(n):
    s1 = sum(w[0:i+1])
    s2 = sum(w[i+1:n])
    
    mini = min(abs(s2-s1),mini)
        
print(mini)

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

s = sum(w)
ans = 0
for i in range(n):
    ans += w[i]
    if ans > s / 2:
        j = i
        break

aa = abs(sum[:j] - sum[j:])
bb = abs(sum[:j+1] - sum[j+1:])

print(min(aa, bb))

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

s = sum(w)
ans = 0
for i in range(n):
    ans += w[i]
    if ans > s / 2:
        j = i
        break

aa = abs(sum[:j] - sum[j:])
bb = abs(sum[:j+1] - sum[j+1:])

print(min(aa, bb))
Problem p03042 (python)

Fixed submission:
s = input()
a = int(s[0] + s[1])
b = int(s[2] + s[3])

if  1 <= a <= 12 and 1 <= b <= 12:
    print('AMBIGUOUS')
elif 1<= b <= 12:
    print('YYMM')
elif 1<= a <= 12:
    print('MMYY')
else:
    print('NA')

Buggy submission (verdict: Runtime Error):
s = input()
a = int(s[0] + s[1])
b = int(s[2] + s[3])

if a = 0 or b = 0:
    print('NA')
elif a>=13 and b >=13:
    print('NA')
elif a >= 13:
    print('YYMM')
elif b >= 13:
    print('MMYY')
else:
    print('AMBIGUOUS')
Problem p03077 (python)

Fixed submission:
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

mi=min(a,b,c,d,e)
if n%mi != 0:
    print((n//mi)+1+4)
else:
    print((n//mi)+4)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

mi=min(a,b,c,d,e)
if n%mi != 0
    print((n//mi)+1+4)
else:
    print((n//mi)+4)
Problem p03135 (python)

Fixed submission:
t,x = map(int, input().split())
print(float(t/x))

Buggy submission (verdict: Runtime Error):
t,x = map(int, input().split())
print(flost(t/x))
Problem p03252 (python)

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

dic={}
ans='Yes'
for i in range(n):
    if t[i] not in dic:
        dic[t[i]]=s[i]
    
    else:
        if dic[t[i]]==s[i]:
            continue
        else :
            ans='No'
            break
    
if len(dic)!=len(set(dic.values())):
    ans='No'
print(ans)

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

dic={}
ans='Yes'
for i in range(n):
    if t[i] not in dic:
        dic[t[i]]=s[i]
    
    else:
        if dic[t[i]]==s[i]:
            continue
        else :
            ans='No'
            break
    
if len(dic)!len(set(dic.values())):
    ans='No'
print(ans)

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

dic={}
ans='Yes'
for i in range(n):
    if s[i] in dic:
        if dic[t[i]]==t[i]:
            continue
        else:
            ans='No'
            break
    
    if t[i] not in dic:
        dic[t[i]]=s[i]
    else:
        if dic[t[i]]==s[i]:
            continue
        else :
            ans='No'
            break

print(ans)

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

dic={}
ans='Yes'
for i in range(n):
    if s[i] in dic:
        if dic[t[i]]==t[i]:
            continue
        else:
            ans='No'
            break
    
    if t[i] not in dic:
        dic[t[i]]=s[i]
    else:
        if dic[t[i]]==s[i]:
            continue
        else dic[t[i]] !=s[i]:
            ans='No'
            break

print(ans)

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

dic={}
ans='Yes'
for i in range(n):
    if s[i]==t[i] and s[i] in dic:
        ans='No'
        break
    
    if t[i] not in dic:
        dic[t[i]]=s[i]
    else:
        if dic[s[i]]==t[i]:
            continue
        else:
            ans='No'
            break

print(ans)
Problem p03634 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


n=int(input())
graph=[[] for i in range(n+1)]
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a].append((b,c))
    graph[b].append((a,c))
    
q,k=map(int,input().split())

dis=[None]*(n+1)

def set_dis(x,d):
    dis[x]=d
    for yy,dd in graph[x] :
        if dis[yy] is not None:
            continue
        set_dis(yy,dd+d)
set_dis(k,0)

for i in range(q):
    x,y=map(int,input().split())
    print(dis[x]+dis[y])

Buggy submission (verdict: Runtime Error):
from heapq import heappush, heappop
 
 
class Dijk:
    def __init__(self, n):
        self.table = [[] for i in range(n+1)]
        self.n = n+1
 
    def add(self, x, y, f):
        self.table[x].append((y, f))
 
    def di(self, s):
        inf = float('inf')
        self.val = [inf] * self.n
        self.val[s] = 0
        h = []
        heappush(h, (0, s))
        while h:
            q, i = heappop(h)
            if self.val[i] < q:
                continue
            for x, c in self.table[i]:
                if self.val[x] > self.val[i] + c:
                    self.val[x] = self.val[i] + c
                    heappush(h, (self.val[x], x))
 
    def dist(self, s, t):
        return self.val[t]

n= int(input())
dijk=Dijk(n)

for i in range(n-1):
    a,b,c=map(int,input().split())
    dijk.add(a,b,c)
    dijk.add(b,a,c)
q,k=map(int,input().split())
for i in range(q):
    x,y=map(int,input().split())
    dijk.di(x)
    ans=dijk.dist(x,i+1)
    dijk.di(i+1)
    ans+=dijk.dist(i+1,y)
    print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
graph=[[] for i in range(n+1)]
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a].append((b,c))
    graph[b].append((a,c))
    
q,k=map(int,input().split())

dis=[None]*(n+1)

def set_dis(x,d):
    dis[x]=d
    for yy,dd in graph[x] :
        if dis[yy] is not None:
            continue
        set_dis(yy,dd+d)
set_dis(k,0)

for i in range(q):
    x,y=map(int,input().split())
    print(dis[x]+dis[y])

Buggy submission (verdict: Runtime Error):
n=int(input())
graph=[[] for i in range(n+1)]
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a].append((b,c))
    graph[b].append((a,c))
    
q,k=map(int,input().split())

dis=[float('inf')]*(n+1)

def set_dis(x,d):
    dis[x]=d
    for yy,dd in graph[x] :
        if dis[yy]!=float('inf'):
            continue
        set_dis(yy,dd+d)
set_dis(k,0)

for i in range(q):
    x,y=map(int,input().split())
    print(dis[x]+dis[y])

Buggy submission (verdict: Runtime Error):
n=int(input())
graph=[[] for i in range(n+1)]
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a].append((b,c))
    graph[b].append((a,c))
    
q,k=map(int,input().split())

dis=[float('inf')]*(n+1)

def set_dis(x,d):
    dis[x]=d
    for yy,dd in graph[x] :
        if dis[yy]!=float('inf'):
            continue
        else:
            set_dis(yy,dd+d)
set_dis(k,0)

for i in range(q):
    x,y=map(int,input().split())
    print(dis[x]+dis[y])