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

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

hlist = [0]*H
wlist = [0]*W
sets = set()
for i in range (M):
    h,w = map(lambda x: int(x)-1,input().split())
    hlist[h]+=1
    wlist[w]+=1
    sets.add((h,w))

hmax = 0
hind = []
for i in range(H):
    if hmax < hlist[i]:
        hmax = hlist[i]
        hind = [i]
    elif hmax == hlist[i]:
        hind.append(i)


wmax = 0
wind = []
for i in range(W):
    if wmax < wlist[i]:
        wmax = wlist[i]
        wind = [i]
    elif wmax == wlist[i]:
        wind.append(i)


flag = False
for h in hind:
    for w in wind:
        if (h,w) not in sets:
            flag = True
            break
    if flag:
        break

if flag:
    print(hmax + wmax)
else:
    print(hmax + wmax - 1)

Buggy submission (verdict: Runtime Error):
H,W,M = map(int,input().split())
m =[[0]*W for _ in range (H)]
hlist = [0]*H
wlist = [0]*W
for i in range (M):
    h,w = map(lambda x: int(x)-1,input().split())
    m[h][w] = 1
    hlist[h]+=1
    wlist[w]+=1

hmax = 0
hind = []
for i in range(H):
    if hmax < hlist[i]:
        hmax = hlist[i]
        hind = [i]
    elif hmax == hlist[i]:
        hind.append(i)


wmax = 0
wind = []
for i in range(W):
    if wmax < wlist[i]:
        wmax = wlist[i]
        wind = [i]
    elif wmax == wlist[i]:
        wind.append(i)


flag = False
for h in hind:
    for w in wind:
        if m[h][w] == 0:
            print(hmax + wmax)
            flag = True
            break
    if flag:
        break

if not flag:
    print(hmax + wmax - 1)
Problem p02594 (python)

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

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

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

Buggy submission (verdict: Runtime Error):
X = int(input())
X = range(-40 < 40)
if X > 30:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
X = input()
if X > 30:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
X = input()
X = range(-40,40)
if X > 30:
  print("Yes")
else:
  print("No")
Problem p02546 (python)

Fixed submission:

s=input()
if s[-1]=="s":
    print(s+'es')
else:
    print(s+'s')

Buggy submission (verdict: Runtime Error):
s = input
if Taknese == s:
print("Takneses")
else:
  print("Taknese")
  
if apple == s:
print("apples")
else:
  print("apple")
  
if bus == s:
print("buses")
else:
  print("bus")
Problem p02552 (python)

Fixed submission:
x=int(input())
if x==0:
    print(1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
x=int(input())
if x.=0:
    print(0)
else:
    print(1)
Problem p02570 (python)

Fixed submission:
#template
def inputlist(): return [int(j) for j in input().split()]
#template
"""
H,W = inputlist()
st = inputlist()
gl = inputlist()
maze = ['0']*H
for i in range(H):
    maze[i] = list(input())
table = [[10**9+7]*W for _ in range(H)]

"""
D,T,S = inputlist()
time = D//S + int(D%S != 0)
if time <= T:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
D,T,S = inputlist()
time = D//S + int(D%S != 0)
if time <= T:
    print("Yes")
else:
    print("No")
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().spilt())

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

Fixed submission:
N,K = map(int,input().split())
D = {}
for i in range(N):
    D[i+1] = 0
for i in range(K):
    d = input()
    A = list(map(int,input().split()))
    for a in A:
        D[a] += 1
ans = 0
for i in range(N):
    if D[i+1] == 0:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
D = {}
for i in range(N):
    D[i+1] = 0
for i in range(K):
    d = input()
    A = list(map(int,input().split()))
    for a in A:
        d[a] += 1
ans = 0
for i in range(N):
    if D[i+1] == 0:
        ans += 1
print(ans)
Problem p02729 (python)

Fixed submission:
N,M = map(int,input().split())
ans = (N*(N-1))//2 + (M*(M-1))//2
print(ans)

Buggy submission (verdict: Runtime Error):
L = int(input())
ans = L**3
ans = ans / 27
print(ans)
Problem p02785 (python)

Fixed submission:
N,K = map(int,input().split())
H = list(map(int,input().split()))
H.sort()
ans = 0
for i in range(min(K,N)):
    H.pop()
ans += sum(H)
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
H = list(map(int,input().split()))
H.sort()
ans = K
for i in range(K):
    H.pop()
ans += sum(H)
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
H = list(map(int,input().split()))
H.sort()
ans = K
for i in range(K):
    H.pop()
ans += sum(H)
Problem p02793 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7
def power(a,b):
    if b == 0:
        return 1
    if b % 2 == 0:
        d = power(a,b//2)
        return d*d%mod
    elif b % 2 == 1:
        return a*power(a,b-1)%mod
import fractions
l = A[0]
g = A[0]
for i in range(1,N):
    x = A[i]
    g = fractions.gcd(l,x)
    l = l*x//g
l = l % mod
ans = 0
for i in range(N):
    ans += l*power(A[i],mod-2) % mod
ans = ans%mod
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = map(int,input().split())
mod = 10**9+7
def power(a,b):
    if b == 0:
        return 1
    if b % 2 == 0:
        d = power(a,b//2)
        return d*d%mod
    elif b % 2 == 1:
        return a*power(a,b-1)%mod
import fractions
l = A[i]
g = A[i]
for i in range(1,N):
    x = A[i]
    g = fractions.gcd(l,x)
    l = l*x%g
l = l % mod
ans = 0
for i in range(N):
    ans += l*power(A[i],mod-2) % mod
ans = ans%mod
print(ans)
Problem p02819 (python)

Fixed submission:
X =int(input())
def f(n):
    for i in range(2,int(n**0.5)+1):
        if n%i == 0:
            return False
    return True
for i in range(X,100004):
    if f(i):
        print(i)
        break

Buggy submission (verdict: Runtime Error):
X =int(input())
def f(n):
    for i in range(2,int(n**0.5)+1):
        if n%i == 0:
            return False
    return True
for i in range(X,100004):
    if f(i):
        return(i)
        break
Problem p02820 (python)

Fixed submission:
N,K = map(int,input().split())
R,S,P  =  map(int,input().split())
t = input()
s = []
for i in range(N):
    s.append(t[i])
ans = 0
for i in range(K):
    if s[i] == 'r':
        ans += P
        s[i] = 'a'
    elif s[i] == 's':
        ans += R
        s[i] = 'b'
    else:
        ans += S
        s[i] = 'c'
T = []
for i in range(K,N):
    if s[i] == 'r':
        if s[i-K] != 'a':
            ans += P
            s[i] = 'a'
    elif s[i] == 's':
        if s[i-K] != 'b':
            ans += R
            s[i] = 'b'
    else:
        if s[i-K] != 'c':
            ans += S
            s[i] = 'c'
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
R,S,P  =  map(int,input().split())
S = input()
ans = 0
for i in range(K):
    if S[i] == “r”:
        ans += P
    elif S[i] == “s”:
        ans += R
    else:
        ans += S
T = []
for i in range(K,N):
    if S[i] ==“r”:
        if S[i-K] == “r”:
            if i in T:
                ans += P
            else:
                T.append(i)
        else:
             ans += P
    elif S[i] == “s”:
        if S[i-K] == “s”:
            if i in T:
                ans += R
            else:
                T.append(i)
        else:
             ans += R
       else:
            if S[i-K] == “p”:
                if i in T:
                    ans += S
                else:
                    T.append(i)
            else:
                ans +=S
print(ans)
Problem p02833 (python)

Fixed submission:
N = int(input())
d = [0 for i in range(31)]
b = 0
if N % 2 == 0:
    for i in range(30):
        x = 30 - i
        y = 5**x
        a = (N//y)//2
        d[x] = a - b
        b = a
    ans = 0
    for i in range(1,31):
        ans += (d[i]*i)
else:
    ans = 0
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
d = [0 for i in range(19)]
if N % 2 == 1:
    ans = 0
f = 0
else:
    for i in range(18):
        x = 18 - i
        y = 10**y
        a = N // y
        d[x] = a - f
        f = a
    ans = 0
    for i in range(1,19):
        ans += (d[i]*i)
print(ans)
Problem p02836 (python)

Fixed submission:
S = input()
N = len(S)
a = 0
n = N//2
for i in range(n):
    k = -(i+1)
    if S[i] != S[k]:
        a += 1
print(a)

Buggy submission (verdict: Runtime Error):
S = input()
N = len(s)
a = 0
n = N//2
for i in range(n):
    k = -(i+1)
    if S[i] != S[k]:
        a += 1
print(a)
Problem p02847 (python)

Fixed submission:
S = input()
if S == 'SUN':
    print(7)
elif S == 'MON':
    print(6)
elif S == 'TUE':
    print(5)
elif S == 'WED':
    print(4)
elif S == 'THU':
    print(3)
elif S == 'FRI':
    print(2)
else:
    print(1)

Buggy submission (verdict: Runtime Error):
N = int(input())
W = []
G = [[] for i in range(N+1)]
for i in range(N-1):
    a,b = map(int,input().split())
    W.append((a,b))
    G[a].append(b)
    G[b].append(a)
K = 0
for i in range(1,N+1):
    n = len(G[i])
    K = max(K,n)
print(K)
C = [[i for i in range(1,K+1)] for j in range(N+1)]
import copy 
w = copy.deepcopy(W)
d = [[0 for i in range(N+1)] for j in range(N+1)]
w.sort()
for i in range(N-1):
    a,b = W[i]
    print(d[a][b])

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
S = []
d = {}
A = list(map(int,input().split()))
ans = 0
sum =0
for i in range(1,N+1):
    sum += A[i-1] % K
    s = (sum - i) % K
    if i > K:
        x = S.pop(0)
        d[x] -= 1
    elif i < K:
        if s == 0:
            ans += 1
    if s not in d:
        d[s] = 0
    ans += d[s]
    d[s] += 1
    S.append(s)
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
if S = 'SUN':
    print(7)
elif S = 'MON':
    print(6)
elif S = 'TUE':
    print(5)
elif S = 'WED':
    print(4)
elif S = 'THU':
    print(3)
elif S = 'FRI':
    print(2)
else:
    print(1)
Problem p02851 (python)

Fixed submission:
N,K = map(int,input().split())
S = []
d = {}
A = list(map(int,input().split()))
ans = 0
sum =0
for i in range(1,N+1):
    sum += A[i-1] % K
    s = (sum - i) % K
    if i > K:
        x = S.pop(0)
        d[x] -= 1
    elif i < K:
        if s == 0:
            ans += 1
    if s not in d:
        d[s] = 0
    ans += d[s]
    d[s] += 1
    S.append(s)
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
S = []
d = {}
d[0] = 0
A = list(map(int,input().split()))
ans = 0
sum =0
for i in range(1,N+1):
    sum += A[i-1] % K
    s = (sum - i) % K
    if i >= K:
        x = S.pop(0)
        d[x] -= 1
    else:
        if s == 0:
            ans += 1
    if s not in d:
        d[s] = 0
    ans += d[s]
    d[s] += 1
    S.append(s)
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
S = []
d = {}
for i in range(K):
    d[i] = 0
d[0] = 1
A = list(map(int,input().split()))
s = 0
ans = 0
for i in range(1,N+1):
    s = (s+A[i-1])%K
    k = (s-i)%K
    if i >= K:
        x = S.pop(0)
        d[x] -= 1
    ans += d[k]
    d[k] += 1
    S.append(k)
print(ans)

Buggy submission (verdict: Runtime Error):
d = {}
S = []
N,K = map(int,input().split())
A = list(map(int,input().split()))
s = 0
for i in range(1,N+1):
    s = (s+A[i-1])%K
    k = (s-i)%K
    if k not in S:
        S.append(k)
        d[k] = 0
    d[k] += 1
ans = 0
for i in range(len(S)):
    x = S[i]
    y = d[x]
    ans += (y*(y-1))//2
ans += d[0]
print(ans)
Problem p02860 (python)

Fixed submission:
N = int(input())
s = input()
ans = 'No'
if N % 2 == 0:
    n = N//2
    a = s[:n]
    b = s[n:]
    if a == b:
        ans = 'Yes'
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
s = input()
ans = 'No'
if N % 2 == 0:
    n = N/2
    a = s[:n]
    b = s[n:]
    if a == b:
        ans = 'Yes'
print(ans)
Problem p02863 (python)

Fixed submission:
N,T = map(int,input().split())
C = []
for i in range(N):
    a,b = map(int,input().split())
    C.append([a,b])
C.sort()
dp = [[0 for i in range(T)]for j in range(N+1)]
for i in range(1,N+1):
    a,b = C[i-1][0],C[i-1][1]
    for t in range(1,T):
        p = dp[i-1][t]
        if t >= a:
            q = dp[i-1][t-a] + b
            dp[i][t] = max(p,q)
        else:
            dp[i][t] = p
M = 0
for i in range(1,N+1):
    M = max(M,C[i-1][1]+dp[i-1][T-1])
print(M)

Buggy submission (verdict: Runtime Error):
N,T = map(int,input().split())
import numpy as np
A = []
B = []
C = []
for i in range(N):
    a,b = map(int,input().split())
    C.append([a,b])
C.sort()
dp = [[0 for i in range(T)]for j in range(N+1)]
for i in range(1,N+1):
    a,b = C[i-1][0],C[i-1][1]
    for t in range(1,T):
        p = dp[i-1][t]
        if t >= a:
            q = dp[i-1][t-a] + b
            dp[i][t] = max(p,q)
        else:
            dp[i][t] = p
M = 0
for i in range(1,N+1):
    M = max(M,C[i-1][1]+dp[i-1][T-1])
print(M)

Buggy submission (verdict: Runtime Error):
N,T = map(int,input().split())
import copy
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
C = zip(B,A)
C = sorted(C)
B,A = zip(*C)
A = list(A)
B = list(B)
dp = [[0 for i in range(T)]for j in range(N+1)]
dp1 = [[[]for i in range(T)]for j in range(N+1)]
for i in range(1,N+1):
    a,b = A[i-1],B[i-1]
    for t in range(1,T):
        p = dp[i-1][t]
        if t >= a:
            q = dp[i-1][t-a] + b
            if p > q:
                dp[i][t] = p
                dp1[i][t] = copy.deepcopy(dp1[i-1][t])
            elif p < q:
                dp[i][t] = q
                dp1[i][t] = copy.deepcopy(dp1[i-1][t-a])
                dp1[i][t].append(b)
            else:
                dp[i][t] = p
                mp = max(dp1[i-1][t])
                mq = max(dp1[i-1][t-a])
                mq = max(mq,b)
                if mp >= mq:
                    dp1[i][t] = copy.deepcopy(dp1[i-1][t-a])
                    dp1[i][t].append(b)
                else:
                    dp1[i][t] = copy.deepcopy(dp1[i-1][t])
        else:
            dp[i][t] = p
            dp1[i][t] = copy.deepcopy(dp1[i-1][t])
M = 0
for i in range(N):
    b = B[N-1-i]
    if b not in dp1[N][T-1]:
        M = b
        break
print(dp[N][T-1]+M)
Problem p02880 (python)

Fixed submission:
N = int(input())
a = [ ]
for i in range(1,10):
    for j in range(i,10):
        b = i*j
        a.append(b)
if a.count(N) == 0:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [ ]
for i in range(1:10):
    for j in range(i:10):
        b = i*j
        a.append(b)
if a.count(N) == 0:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [ ]
for i in range(1:10):
    for j in range(i:10):
        b = i*j
        a.append(b)
if a.count(N) == 0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [ ]
for i in range(1:10):
    for j in range(i:10):
        b = i*j
        a.append(b)
if list.count(N) == 0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [ ]
for i in range(1:10):
	for j in range(i:10):
		b = i*j
        a.append(b)
if list.count(N) == 0:
	print('Yes')
else:
	print('No')
Problem p02881 (python)

Fixed submission:
N = int(input())
import math
n = math.floor(N**0.5)
s = N + 1
for i in range(1,n + 1):
    if N % i == 0:
        a = i + (N/i)
        s = a
print(int(s-2))

Buggy submission (verdict: Runtime Error):
N = int(input())
import math
n = math.floor(N**0.5)
s = N + 1
for i in range(1,n):
    if N % i == 0:
        a = i + (N/i)
        if s >= a:
            s = a
print(int(a-2))

Buggy submission (verdict: Runtime Error):
N = int(input())
s = N + 1
t = 0
for i in range(1,N**0.5):
    if N % i == 0:
        a = i + (N//i)
        if s > a:
            t = a
print(a-2)

Buggy submission (verdict: Runtime Error):
N = int(input())
s = N + 1
for i in range(N):
    if N % i == 0:
        a = i + (N/i)
        if s > a:
            s = a
print(a-2)
Problem p02891 (python)

Fixed submission:
A = input()
n = len(A)
S = []
R = [A[n-1]]
for i in range(n):
    S.append(A[i])
    R.append(A[i])
K = int(input())
s = 0
p = S[0]
q = S[n-1]
for i in range(n-1):
    x = S[i]
    y = S[i+1]
    if x == y:
        S[i+1] = 1
        s += 1
t = 0
for j in range(n):
    x = R[j]
    y = R[j+1]
    if x == y:
        R[j+1] = 1
        t += 1
if p != q:
    ans = s*K
else:
    if S[n-1] == 1:
        ans = s*K
    else:
        if R[n] == 1:
            k = K//2
            ans = (K-k)*s + k*t
        else:
            ans = s + (K-1)*t
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
S2 = S + S
K = int(input())
n = len(S2)
i = 0
s = 0
while i < n-1 :
    i += 1
    x = S2[i]
    y = S2[i+1]
    if x == y:
        s += 1
        i += 1
p = s//2
q = s-p
ans = p + q*(K-1)

Buggy submission (verdict: Runtime Error):
S = str(input())
K = int(input())
n = len(S)
s = [ ]
for i in range(n):
    s.append(S[i])
s.append(S[0])
t = 0
for i in range(n):
    if s[i] == s[i+1]:
        s[i+1] = A
        t = t + 1
if s[n] == s[0]:
    T = t*K
else:
    if K == 1
    T = (t*K) - 1
print(T)

Buggy submission (verdict: Runtime Error):
S = str(input())
K = int(input())
s = [ ]
for i in range(K):
    s.append(S[i])
s.append(S[0])
t = 0
for i in range(K):
    if s[i] == s[i+1]:
        s[i+1] = s_i
        t = t + 1
if s[K] == s[0]:
    T = (t*K) - 1
else:
    T = t*K
print(T)
Problem p03018 (python)

Fixed submission:
S = input()
N = len(S)
a = 0
ans = 0
f = 0
for i in range(N-1):
    if S[i] == 'A':
        a += 1
    elif S[i] == 'B':
        if S[i+1] == 'C':
            ans += a
            f = 1
        else:
            a = 0
    else:
        if f != 1:
            a = 0
        else:
            f = 0
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
a = 0
ans = 0
for i in range(N):
    if S[i] == 'A':
        a += 1
    elif S[i] == 'B':
        if S[i+1] == 'C':
            ans += a
        else:
            a = 0
    else:
        a = 0
print(ans)
Problem p03041 (python)

Fixed submission:
N,K = map(int,input().split())
S = input()
s = []
for i in range(N):
    x = S[i]
    if i == K-1:
        if x == 'A':
            x = 'a'
        elif x == 'B':
            x = 'b'
        else:
            x = 'c'
    s.append(x)
ans = s[0]
for i in range(1,N):
    ans += s[i]
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
S = input()
S[K-1] = S[K-1].lower()
print(S)
Problem p03135 (python)

Fixed submission:
T,X = map(int,input().split())
print(T/X)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()
ans = X[-1] - X[0]
d = []
for i in range(M-1):
    d.append(X[i+1]-X[i])
d.sort()
n = min(N-1,M-1)
for i in range(n):
    ans -= d[-i]
print(ans)
Problem p03137 (python)

Fixed submission:
N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()
d = []
for i in range(M-1):
    d.append(X[i+1]-X[i])
d.sort()
n = min(M-1,N-1)
for i in range(n):
    d.pop()
ans = sum(d)
print(ans)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()
ans = X[-1] - X[0]
d = []
for i in range(N-1):
    d.append(X[i+1]-X[i])
d.sort()
n = min(N-1,M-1)
for i in range(n):
    ans -= d[-i]
print(ans)
Problem p03221 (python)

Fixed submission:
N,M = map(int,input().split())
A = [[] for i in range(N+1)]
B = []
d = {}
for i in range(M):
    p,y = map(int,input().split())
    B.append((p,y))
    A[p].append(y)
for i in range(N+1):
    A[i].sort()
    n = len(A[i])
    for j in range(n):
        d[A[i][j]] = j+1
for i in range(M):
    p,y = B[i]
    q = d[y]
    m = 6 - len(str(p))
    n = 6 - len(str(q))
    ans = "0"*m + str(p) + "0"*n + str(q)
    print(ans)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = [[] for i in range(N+1)]
B = []
d = {}
for i in range(M):
    p,y = map(int,input().split())
    B.append((p,y))
    A[p].append(y)
for i in range(N+1):
    A[i].sorted
    n = len(A[i])
    for j in range(n):
        d[A[i][j]] = j+1
for i in range(M):
    p,y = B[i]
    q = d[y]
    m = 6 - len(str(p))
    n = 6 - len(str(q))
    ans = "0"*m + str(p) + "0"*m + str(q)
    print(ans)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = [[] for i in range(N+1)]
B = []
d = {}
for i in range(M):
    p,y = map(int,input().split())
    B.append((p,y))
    A[p].append(y)
for i in range(N+1):
    A[i].sorted
    n = len(A[i])
    for j in range(n):
        d[A[i][j]] = j+1
for i in range(M):
    p,y = B[i]
    q = d[y]
    m = 6 - len(str(p))
    n = 6 - len(str(q))
    ans = "0"*m + str(p) + "0"*m + str(q)
Problem p03776 (python)

Fixed submission:
from math import factorial
def comb(n,r):
    return factorial(n) // factorial(r) // factorial(n - r)
N,A,B = map(int,input().split())
V = list(map(int,input().split()))
V.sort()
x = V[-1]
ans = 0
for i in range(1,A+1):
    ans += V[-i]
    x = V[-i]
ans = ans/A
print(ans)
count = 0
import bisect
y = N - bisect.bisect(V,x)
if x == V[-1]:
    n = V.count(x)
    for i in range(A,min(B,V.count(x))+1):
        z = i - y
        count += comb(n,z)
else:
    z = A - y
    n = V.count(x)
    count += comb(n,z)
print(count)

Buggy submission (verdict: Runtime Error):
from math import factorial
def combi(n,r):
    return factorial(n) / factorial(r) / factorial(n - r)
N,A,B = map(int,input().split())
V = list(map(int,input().split()))
V.sort()
x = V[-1]
ans = 0
for i in range(1,A+1):
    ans += V[-i]
    x = V[-i]
ans = ans/A
print(ans)
count = 0
import bisect
y = N - bisect.bisect(V,x)
if x == V[-1]:
    n = V.count(x)
    for i in range(A,min(B,V.count(x))+1):
        z = i - y
        count += comb(n,z)
else:
    z = A - y
    n = V.count(x)
    count += comb(n,z)
print(count)
Problem p03804 (python)

Fixed submission:
N,M = map(int,input().split())
A = []
B = []
for i in range(N):
    A.append(input())
for i in range(M):
    B.append(input())
flag = 0
for i in range(N-M+1):
    for k in range(N-M+1):
        p = 1
        for j in range(i,i+M):
            a = A[j][k:k+M]
            b = B[j-i]
            if a != b:
                p = 0
                break
        if p == 1:
            flag = 1
        

if flag == 1:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N,M = int(input())
A = []
B = []
for i in range(N):
    A.append(input())
for i in range(M):
    B.append(input())
for i in range(N-M+1):
    for k in range(N-M+1):
        p = 1
        for j in range(i,i+M):
            a = A[j][k:k+M]
            b = B[j-i][k+M]
            if a != b:
                p = 0
        ans += 1
print(ans)
Problem p03805 (python)

Fixed submission:
N,M = map(int,input().split())
G = [[] for i in range(N+1)]
for i in range(M):
    a,b = map(int,input().split())
    G[a].append(b)
    G[b].append(a)
l = [i for i in range(2,N+1)]
import itertools
ans = 0
for v in itertools.permutations(l):
    v = list(v)
    flag = 1
    s = 1
    t = 1
    while v:
        s = t
        t = v.pop(0)
        if t not in G[s]:
            flag = 0
            break
    ans += flag
print(ans)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
G = [[] for i in range(N+1)]
for i in range(M):
    a,b = map(int,input().split())
    G[a].append(b)
    G[b].append(a)
l = [i for i in range(2,N+1)]
import itertools
ans = 0
for v in itertools.permutations(l):
    s = 1
    t = 1
    while v:
        s = t
        t = v.pop(0)
        if t not in G[s]:
            break
    if len(v) == 0:
        ans += 1
print(ans)