Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from scipy.sparse import*;f=lambda:list(map(int,input().split()));N,M,R=f();r=f();a,b,c=zip(*map(f,[0]*M));a=csgraph.dijkstra(csr_matrix((c,(a,b)),[N+1]*2),0,r);print(int(min(sum(a[e[i]][r[e[i+1]]]for i in range(R-1))for e in __import__('itertools').permutations(range(R)))))

Fixed submission:
from scipy.sparse import*
N,M,R=map(int,raw_input().split())
r=[int(e) for e in raw_input().split()]
a,b,c=zip(*(map(int,raw_input().split())for _ in range(M)))
a=csgraph.dijkstra(csr_matrix((c,(a,b)),[N+1]*2),0,r)
print int(min(sum(a[e[i]][r[e[i+1]]]for i in range(R-1))for e in __import__('itertools').permutations(range(R))))

Buggy python submission (verdict: Runtime Error):
from scipy.sparse import*;f=lambda:map(int,raw_input().split());N,M,R=f();r=f();a,b,c=zip(*map(f,[0]*M));a=csgraph.dijkstra(csr_matrix((c,(a,b)),[N+1]*2),0,r);print int(min(sum(a[e[i]][r[e[i+1]]]for i in range(R-1))for e in __import__('itertools').permutations(range(R))))

Fixed submission:
from scipy.sparse import*
N,M,R=map(int,raw_input().split())
r=[int(e) for e in raw_input().split()]
a,b,c=zip(*(map(int,raw_input().split())for _ in range(M)))
a=csgraph.dijkstra(csr_matrix((c,(a,b)),[N+1]*2),0,r)
print int(min(sum(a[e[i]][r[e[i+1]]]for i in range(R-1))for e in __import__('itertools').permutations(range(R))))

Buggy python submission (verdict: Runtime Error):
from scipy.sparse import*;f=lambda*z:map(int,raw_input().split());N,M,R=f();r=f();a,b,c=list(zip(*map(f,[0]*M)));a=csgraph.dijkstra(csr_matrix((c,(a,b)),[N+1]*2),0,r);print int(min(sum(a[e[i]][r[e[i+1]]]for i in range(R-1))for e in __import__('itertools').permutations(range(R))))

Fixed submission:
from scipy.sparse import*
N,M,R=map(int,raw_input().split())
r=[int(e) for e in raw_input().split()]
a,b,c=zip(*(map(int,raw_input().split())for _ in range(M)))
a=csgraph.dijkstra(csr_matrix((c,(a,b)),[N+1]*2),0,r)
print int(min(sum(a[e[i]][r[e[i+1]]]for i in range(R-1))for e in __import__('itertools').permutations(range(R))))
Buggy python submission (verdict: Runtime Error):
from heapq import*
n=int(input())
a=[-int(e)for e in input().split()]
r=0
heapify(a)
while 1:
	x=heappop(a)
	if x>-n:break
	c=-x//n
	x+=c*n
	for _ in range(n-1):a[i]-=c
	heappush(a,x)
	r+=c
print(r)

Fixed submission:
#!/usr/bin/python
from heapq import*
n=int(input())
a=[-int(e)for e in input().split()]
r=0
heapify(a)
while 1:
	x=heappop(a)
	if x>-n:break
	c=-x//n
	x+=c*n
	a=[e-c for e in a]
	heappush(a,x)
	r+=c
print(r)

Buggy python submission (verdict: Runtime Error):
from heapq import*
n=int(input())
a=[-int(e)for e in input().split()]
r=0
heapify(a)
while 1:
	x=heappop(a)
	if x>-n:break
	c=-x//n
	x+=c*n
	for _ in range(n-1):a[i]-=c
	heappush(a,x)
	r+=c
print(r)

Fixed submission:
#!/usr/bin/python
from heapq import*
n=int(input())
a=[-int(e)for e in input().split()]
r=0
heapify(a)
while 1:
	x=heappop(a)
	if x>-n:break
	c=-x//n
	x+=c*n
	a=[e-c for e in a]
	heappush(a,x)
	r+=c
print(r)
Buggy python submission (verdict: Runtime Error):
from scipy.sparse import*;f=lambda*z:map(int,raw_input().split());d=lambda s:csgraph.dijkstra(csr_matrix(([1]*n,(a,b)),[n+1]*2),0,s);n,=f();a,b=zip(*map(f,[0]*n));g=d(1);h=d(n);print['Snuke','Fennec'][sum(g[i]>h[i]for i in range(n+1))*2<n]

Fixed submission:
from scipy.sparse import*
f=lambda*z:map(int,raw_input().split())
d=lambda s:csgraph.dijkstra(csr_matrix(([1]*len(a),(a,b)),[n+1]*2),0,s)
n,=f()
a,b=zip(*map(f,[0]*~-n))
g=d(1)
h=d(n)
print 'Snuke'if sum(g[i]>h[i] for i in range(n+1))*2>=n else'Fennec'

Buggy python submission (verdict: Runtime Error):
from scipy.sparse import*;f=lambda*z:map(int,raw_input().split());d=lambda s:csgraph.dijkstra(csr_matrix(([1]*n,(a,b)),[n+1]*2),0,s);n,=f();a,b=zip(*map(f,[0]*~-n));g=d(1);h=d(n);print['Snuke','Fennec'][sum(g[i]>h[i]for i in range(n+1))*2<n]

Fixed submission:
from scipy.sparse import*
f=lambda*z:map(int,raw_input().split())
d=lambda s:csgraph.dijkstra(csr_matrix(([1]*len(a),(a,b)),[n+1]*2),0,s)
n,=f()
a,b=zip(*map(f,[0]*~-n))
g=d(1)
h=d(n)
print 'Snuke'if sum(g[i]>h[i] for i in range(n+1))*2>=n else'Fennec'
Buggy python submission (verdict: Time Limit Exceeded):
f=lambda s,y1,x1,y2,x2:s[y2][x2]-s[y2][x1-1]-s[y1-1][x2]+s[y1-1][x1-1]
H,W,N=map(int,raw_input().split())
a=[map(int,raw_input()) for _ in [0]*H]
s,s1,s2=[ [[0]*(W+1) for _ in [0]*-~H] for _ in [0]*3 ]
for h in range(H):
	for w in range(W):
		s[h+1][w+1]=s[h+1][w]+s[h][w+1]-s[h][w]+a[h][w]
		s1[h+1][w+1]=s1[h+1][w]+s1[h][w+1]-s1[h][w]+(a[h][w]*(w+1<W and a[h][w+1]))
		s2[h+1][w+1]=s2[h+1][w]+s2[h][w+1]-s2[h][w]+(a[h][w]*(h+1<H and a[h+1][w]))
for _ in [0]*N:
	y1,x1,y2,x2=map(int,raw_input().split())
	print f(s,y1,x1,y2,x2)-f(s1,y1,x1,y2,x2-1)-f(s2,y1,x1,y2-1,x2)

Fixed submission:
f=lambda s,y1,x1,y2,x2:s[y2][x2]-s[y2][x1-1]-s[y1-1][x2]+s[y1-1][x1-1]
H,W,N=map(int,raw_input().split())
a=[map(int,raw_input()) for _ in [0]*H]
s,s1,s2=[ [[0]*(W+1) for _ in [0]*-~H] for _ in [0]*3 ]
for h in range(H):
	for w in range(W):
		s[h+1][w+1]=s[h+1][w]+s[h][w+1]-s[h][w]+a[h][w]
		s1[h+1][w+1]=s1[h+1][w]+s1[h][w+1]-s1[h][w]+(a[h][w]*(w+1<W and a[h][w+1]))
		s2[h+1][w+1]=s2[h+1][w]+s2[h][w+1]-s2[h][w]+(a[h][w]*(h+1<H and a[h+1][w]))
for _ in [0]*N:
	y1,x1,y2,x2=map(int,raw_input().split())
	print f(s,y1,x1,y2,x2)-f(s1,y1,x1,y2,x2-1)-f(s2,y1,x1,y2-1,x2)
Buggy python submission (verdict: Runtime Error):
def f(a):
	s=0;q=a[:n];s=sum(q);heapify(q);yield s
	for e in a[n:2*n]:s+=e-heappushpop(q,e);yield s
from heapq import*;r=reversed;n,*a=map(int,open(0).read().split());print(max(map(sum,zip(f(a),r(f([-e for e in r(a)]))))))

Fixed submission:
import sys,heapq
n=int(sys.stdin.readline())
a=list(map(int,sys.stdin.readline().split()))
sa=sb=0
la=[]
lb=[]
for i in range(n):
	sa+=a[i]
	heapq.heappush(la,a[i])
ra=[sa]
for i in range(n,2*n):
	sa+=a[i]
	heapq.heappush(la,a[i])
	sa-=heapq.heappop(la)
	ra.append(sa)
for i in range(3*n-1,2*n-1,-1):
	sb+=a[i]
	heapq.heappush(lb,-a[i])
rb=[sb]
for i in range(2*n-1,n-1,-1):
	sb+=a[i]
	heapq.heappush(lb,-a[i])
	sb+=heapq.heappop(lb)
	rb.append(sb)
print(max(x-y for x,y in zip(ra,reversed(rb))))

Buggy python submission (verdict: Runtime Error):
def f(a):
	s=0;q=[]
	for i in range(n):s+=a[i];heappush(q,a[i])
	r=[s]
	for i in range(n,2*n):s+=a[i];s-=heappushpop(q,a[i]);r+=[s]
	return r
import sys;from heapq import*;n,*a=list(map(int,sys.stdin.read().split()));print(max(x+y for x,y in zip(f(a),f(list(reversed(-e for e in a))))))

Fixed submission:
import sys,heapq
n=int(sys.stdin.readline())
a=list(map(int,sys.stdin.readline().split()))
sa=sb=0
la=[]
lb=[]
for i in range(n):
	sa+=a[i]
	heapq.heappush(la,a[i])
ra=[sa]
for i in range(n,2*n):
	sa+=a[i]
	heapq.heappush(la,a[i])
	sa-=heapq.heappop(la)
	ra.append(sa)
for i in range(3*n-1,2*n-1,-1):
	sb+=a[i]
	heapq.heappush(lb,-a[i])
rb=[sb]
for i in range(2*n-1,n-1,-1):
	sb+=a[i]
	heapq.heappush(lb,-a[i])
	sb+=heapq.heappop(lb)
	rb.append(sb)
print(max(x-y for x,y in zip(ra,reversed(rb))))

Buggy python submission (verdict: Runtime Error):
def f(a):
	s=0;q=[]
	for i in range(n):s+=a[i];heappush(q,a[i])
	r=[s]
	for i in range(n,2*n):s+=a[i];s-=heappushpop(q,a[i]);r+=[s]
	return r
import sys;from heapq import*;n,*a=list(map(int,sys.stdin.read().split()));print(max(x+y for x,y in zip(f(a),f(reversed(-e for e in a)))))

Fixed submission:
import sys,heapq
n=int(sys.stdin.readline())
a=list(map(int,sys.stdin.readline().split()))
sa=sb=0
la=[]
lb=[]
for i in range(n):
	sa+=a[i]
	heapq.heappush(la,a[i])
ra=[sa]
for i in range(n,2*n):
	sa+=a[i]
	heapq.heappush(la,a[i])
	sa-=heapq.heappop(la)
	ra.append(sa)
for i in range(3*n-1,2*n-1,-1):
	sb+=a[i]
	heapq.heappush(lb,-a[i])
rb=[sb]
for i in range(2*n-1,n-1,-1):
	sb+=a[i]
	heapq.heappush(lb,-a[i])
	sb+=heapq.heappop(lb)
	rb.append(sb)
print(max(x-y for x,y in zip(ra,reversed(rb))))
Buggy python submission (verdict: Runtime Error):
N,A,B,C,D=map(int,raw_input().split());Z=[1]+[0]*N;M=10**9+7;I=[1,1];F=I+[];R=I+[]
for i in range(2,N+1):I+=[(M-M/i)*I[M%i]%M];F+=[i*F[-1]%M];R+=[I[i]*R[-1]%M]
for i in range(A,B+1):Z=[(Z[j]+sum(Z[j-i*k]*F[N-j+i*k]*R[N-j]*pow(R[i],k,M)*R[k]for k in range(C,min(D,j/i)+1)))%M for j in range(N+1)]
print Z[N]

Fixed submission:
N,A,B,C,D=map(int,input().split());Z=[1]+[0]*N;M=10**9+7;I=[1,1];F=I+[];R=I+[]
for i in range(2,N+1):I+=[(M-M//i)*I[M%i]%M];F+=[i*F[-1]%M];R+=[I[i]*R[-1]%M]
for i in range(A,B+1):Z=[(Z[j]+sum(Z[j-i*k]*F[N-j+i*k]*R[N-j]*pow(R[i],k,M)*R[k]for k in range(C,min(D,j//i)+1)))%M for j in range(N+1)]
print(Z[N])
Buggy python submission (verdict: Runtime Error):
from functools import*
@lru_cache
def d(n):x=n//2;return n+1 if n<2 else d(x)+d(~-x)+d(n+~x)
print(d(int(input()))%(10**9+7))

Fixed submission:
from functools import*
@lru_cache(maxsize=None)
def d(n):x=n//2;return n+1 if n<2 else d(x)+d(~-x)+d(n+~x)
print(d(int(input()))%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
from functools import*
@lru_cache(0)
def d(n):x=n//2;return n+1 if n<2 else d(x)+d(~-x)+d(n+~x)
print(d(int(input()))%(10**9+7))

Fixed submission:
from functools import*
@lru_cache(maxsize=None)
def d(n):x=n//2;return n+1 if n<2 else d(x)+d(~-x)+d(n+~x)
print(d(int(input()))%(10**9+7))
Buggy python submission (verdict: Runtime Error):
M=10**9+7;D=[];i=1;r=0;N,K=map(int,input().split())
while i*i<=N:
	if N%i==0:D.append(i);i*i<N and D.append(N//i)
	i+=1
D.sort();N=[]
for i in range(len(D)):
	N.append(pow(K,-~D[i]//2,M))
	for j in range(i):
		if D[i]%D[j]==0:N[i]=(N[i]-N[j])%M
	r=(r+(N[i]*D[i]*pow(2,M-2+D[i]%2,M)))%M
print(r)

Fixed submission:
M=10**9+7;D=[];i=1;r=0;N,K=map(int,raw_input().split())
while i*i<=N:
	if N%i==0:D.append(i);i*i<N and D.append(N/i)
	i+=1
D.sort();N=[]
for i in range(len(D)):
	N.append(pow(K,-~D[i]/2,M))
	for j in range(i):
		if D[i]%D[j]==0:N[i]=(N[i]-N[j])%M
	r=(r+(N[i]*D[i]*pow(2,M-2+D[i]%2,M)))%M
print r
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**9)
INF = 2**30
N = int(input())
A = list(map(int, input().split()))
E = []
for i in range(N):
    E.append([])
for i in range(N-1):
    u, v = list(map(int, input().split()))
    u -= 1
    v -= 1
    E[u].append(v)
    E[v].append(u)

ans = [0] * N
dp = [INF] * (N+10)

def dfs(now, par, len):
    ng = -1
    ok = len+5
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if A[now] <= dp[mid]:
            ok = mid
        else:
            ng = mid
    memo = dp[ok]
    dp[ok] = A[now]

    ng1 = 0
    ok1 = len+5
    while ok1 - ng1 > 1 :
        mid = (ok1 + ng1) // 2
        if dp[mid] == INF:
            ok1 = mid
        else:
            ng1 = mid
    ans[now] = ok1

    for to in E[now]:
        if to == par:
            continue
        dfs(to, now, len+1)
    dp[ok] = memo

dfs(0, -1, 0)

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


Fixed submission:
import sys
import bisect
sys.setrecursionlimit(10**9)
INF = 2**30
N = int(input())
A = list(map(int, input().split()))
E = []
for i in range(N):
    E.append([])
for i in range(N-1):
    u, v = list(map(int, input().split()))
    u -= 1
    v -= 1
    E[u].append(v)
    E[v].append(u)

ans = [0] * N
dp = [INF] * N

def dfs(now, par, len):
    ok = bisect.bisect_left(dp, A[now])
    memo = dp[ok]
    dp[ok] = A[now]

    ok1 = bisect.bisect_left(dp, INF)
    ans[now] = ok1

    for to in E[now]:
        if to == par:
            continue
        dfs(to, now, len+1)
    dp[ok] = memo

dfs(0, -1, 0)

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

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**9)
INF = 2**30
N = int(input())
A = list(map(int, input().split()))
E = []
for i in range(N):
    E.append([])
for i in range(N-1):
    u, v = list(map(int, input().split()))
    u -= 1
    v -= 1
    E[u].append(v)
    E[v].append(u)

ans = [0] * N
dp = [INF] * (N+10)

def dfs(now, par):
    ng = -1
    ok = N+5
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if A[now] <= dp[mid]:
            ok = mid
        else:
            ng = mid
    memo = dp[ok]
    dp[ok] = A[now]

    ng1 = 0
    ok1 = N+5
    while ok1 - ng1 > 1 :
        mid = (ok1 + ng1) // 2
        if dp[mid] == INF:
            ok1 = mid
        else:
            ng1 = mid
    ans[now] = ok1

    for to in E[now]:
        if to == par:
            continue
        dfs(to, now)
    dp[ok] = memo


dfs(0, -1)

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


Fixed submission:
import sys
import bisect
sys.setrecursionlimit(10**9)
INF = 2**30
N = int(input())
A = list(map(int, input().split()))
E = []
for i in range(N):
    E.append([])
for i in range(N-1):
    u, v = list(map(int, input().split()))
    u -= 1
    v -= 1
    E[u].append(v)
    E[v].append(u)

ans = [0] * N
dp = [INF] * N

def dfs(now, par, len):
    ok = bisect.bisect_left(dp, A[now])
    memo = dp[ok]
    dp[ok] = A[now]

    ok1 = bisect.bisect_left(dp, INF)
    ans[now] = ok1

    for to in E[now]:
        if to == par:
            continue
        dfs(to, now, len+1)
    dp[ok] = memo

dfs(0, -1, 0)

for i in range(N):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**9)

mod = 1000000007
INF = 110110110

N = int(input())
A = list(map(int, input().split()))
PA = []
for i in range(N):
    PA.append((A[i], i))
PA.sort(reverse=True)

dp = [[0 for j in range(N+1)] for i in range(N+1)]

for i in range(N+1):
    for j in range(N+1):
        dp[i][j] = -INF * INF

dp[0][0] = 0

for i in range(N):
    for j in range(N):
        if i+j >= N:
            continue
        w = PA[i+j][0]
        at = PA[i+j][1]
        dp[i+1][j] = max(dp[i+1][j], dp[i][j] + w * abs(at - i))
        dp[i][j+1] = max(dp[i][j+1], dp[i][j] + w * abs(at - (N-1-j)))
ans = 0
for i in range(N+1):
    for j in range(N+1):
        ans = max(ans, dp[i][j]);
print(ans)


Fixed submission:
import sys
sys.setrecursionlimit(10**9)

mod = 1000000007
INF = 110110110

N = int(input())
A = list(map(int, input().split()))
PA = []
for i in range(N):
    PA.append((A[i], i))
PA.sort(reverse=True)

dp = [[0 for j in range(N+1)] for i in range(N+1)]

for i in range(N+1):
    for j in range(N+1):
        dp[i][j] = -INF * INF

dp[0][0] = 0

for i in range(N):
    for j in range(N):
        if i+j >= N:
            continue
        w = PA[i+j][0]
        at = PA[i+j][1]
        dp[i+1][j] = max(dp[i+1][j], dp[i][j] + w * abs(at - i))
        dp[i][j+1] = max(dp[i][j+1], dp[i][j] + w * abs(at - (N-1-j)))
ans = 0
for i in range(N+1):
    for j in range(N+1):
        ans = max(ans, dp[i][j]);
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**9)
mod = 998244353
N, S = list(map(int, input().split()))
A = list(map(int, input().split()))

ans = 0
num = [0] * 6020
for i in range(N):
    for j in range(3010, 0, -1):
        num[A[i]+j] += num[j]
        num[A[i]+j] %= mod
    num[A[i]] += i+1
    num[A[i]] %= mod
    ans += num[S] * (N - i)
    ans %= mod
    num[S] = 0
print(ans)


Fixed submission:
import sys
sys.setrecursionlimit(10**9)
mod = 998244353
N, S = list(map(int, input().split()))
A = list(map(int, input().split()))

ans = 0
num = [0] * 6020
for i in range(N):
    for j in range(3010, 0, -1):
        num[A[i]+j] += num[j]
        num[A[i]+j] %= mod
    num[A[i]] += i+1
    num[A[i]] %= mod
    ans += num[S] * (N - i)
    ans %= mod
    num[S] = 0
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, t = map(int, input().split())
print（b * (t // a))

Fixed submission:
a, b, t = map(int, input().split())
print(b * (t // a))
Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
c = input()
d = input()
e = input()
k = input()

x = min(a, b, c, d, e)
y = max(a, b, c, d, e)
if (y - x) <= k:
  print('Yay!')
else:
  print(':(')

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

x = min(a, b, c, d, e)
y = max(a, b, c, d, e)
if (y - x) <= k:
    print('Yay!')
else:
    print(':(')
Buggy python submission (verdict: Runtime Error):
import math

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

start = 0
end = int(1e9)

cost = 0
while start <= end:
	n = int(start+(end-start)/2)
	cost = a * n + b * len(str(n))
	# if cost == x:
	# 	break
	if cost < x:
		start = n+1;
	else:
		end = n-1;

print(max(0, start-1))



Fixed submission:
import math

a = input()

b = {
	"SUN":7,
	"MON":6,
	"TUE":5,
	"WED":4,
	"THU":3,
	"FRI":2,
	"SAT":1,
}

print(b[a])
Buggy python submission (verdict: Runtime Error):
S = input()
  
if s <= "2019/04/30":
  print("Heisei")
else:
  print("TBD")

Fixed submission:
S = input()
  
if S <= "2019/04/30":
  print("Heisei")
else:
  print("TBD")
Buggy python submission (verdict: Runtime Error):
from sys import exit

N = int(input())

if N == 1:
  print('Hello World')
  exit(0)

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

Fixed submission:
from sys import exit

N = int(input())

if N == 1:
  print('Hello World')
  exit(0)

A = int(input())
B = int(input())
print(A + B)
Buggy python submission (verdict: Runtime Error):
n = input()

def change(d):
  if d == '1':
    return '9'
  elif d == '9':
   	return '1'
  else
  	return d

print(''.join([change(d) for d in n]))

Fixed submission:
n = input()

def change(d):
  if d == '1':
    return '9'
  elif d == '9':
    return '1'
  else:
    return d

print(''.join([change(d) for d in n]))
Buggy python submission (verdict: Runtime Error):
print((N // 2) * (N - N // 2))

Fixed submission:
N = int(input())
print((N // 2) * (N - N // 2))
Buggy python submission (verdict: Runtime Error):
def main():
  N = int(input())

  for i range(26):
    if i * 4 > N:
      break
    if (N - i * 4) % 7 == 0:
      print('Yes')
      return
  print('No')

if __name__ == '__main__':
  main()
  

Fixed submission:
def main():
  N = int(input())

  for i in range(26):
    if i * 4 > N:
      break
    if (N - i * 4) % 7 == 0:
      print('Yes')
      return
  print('No')

if __name__ == '__main__':
  main()
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = []
for i in range(N):
  s.append(input())

M = int(input())
T = []
for i in range(M):
  t.append(input())

ans = 0
for s in S:
  score = 0
  for s2 in S:
    if s == s2:
      score += 1
  for t in T:
    if s == t:
      score -= 1
  ans = max(ans, score)

print(ans)

Fixed submission:
N = int(input())
S = []
for i in range(N):
  S.append(input())

M = int(input())
T = []
for i in range(M):
  T.append(input())

ans = 0
for s in S:
  score = 0
  for s2 in S:
    if s == s2:
      score += 1
  for t in T:
    if s == t:
      score -= 1
  ans = max(ans, score)

print(ans)

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

M = int(input())
T = []
for i in range(N):
  t.append(input())

ans = 0
for s in S:
  score = 0
  for s2 in S:
    if s == s2:
      score += 1
  for t in T:
    if s == t:
      score -= 1
  ans = max(ans, score)

print(ans)

Fixed submission:
N = int(input())
S = []
for i in range(N):
  S.append(input())

M = int(input())
T = []
for i in range(M):
  T.append(input())

ans = 0
for s in S:
  score = 0
  for s2 in S:
    if s == s2:
      score += 1
  for t in T:
    if s == t:
      score -= 1
  ans = max(ans, score)

print(ans)
Buggy python submission (verdict: Runtime Error):
abcd = input()

for mask in range(1 << 3):
  res = int(abcd[0])
  ans = abcd[0]
  
  for i in range(3):
    if ((mask >> i) & 1) == 1:
      res += int(abcd[i + 1])
      ans += '+' + abcd[i + 1]
    else:
      res -= int(abcd[i + 1])
      ans -= '-' + abcd[i + 1]
  
  if res == 7:
    print('{}=7', ans)
    break

Fixed submission:
abcd = input()

for mask in range(1 << 3):
  res = int(abcd[0])
  ans = abcd[0]
  
  for i in range(3):
    if ((mask >> i) & 1) == 1:
      res += int(abcd[i + 1])
      ans += '+' + abcd[i + 1]
    else:
      res -= int(abcd[i + 1])
      ans += '-' + abcd[i + 1]
  
  if res == 7:
    print('{}=7'.format(ans))
    break
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = 1

n = 1
while n * n <= N:
  ans = n * n

print(ans)


Fixed submission:
N = int(input())
ans = 1

n = 1
while n * n <= N:
  ans = n * n
  n += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
H, W = [int(x) for x in input().split()]
C = []
for i in range(H):
  C.append(input())
  
for i in range(2 * H):
  print(C[(i + 2) // 2])

Fixed submission:
H, W = [int(x) for x in input().split()]
C = []
for i in range(H):
  C.append(input())
  
for i in range(2 * H):
  print(C[i // 2])
Buggy python submission (verdict: Runtime Error):
import sys

read = sys.stdin.read
readline = sys.stdin.readline

N, M, Q, *abcd = map(int, read().split())
cand = [[0, 1]]

for _ in range(M):
    new_cand = []
    for j in cand:
        for k in range(j[-1], M + 1):
            new_cand.append(j[:] + [k])
    cand = new_cand[:]

answer = 0
abcd = tuple(zip(*[iter(abcd)] * 4))
for seq in cand:
    t = 0
    for a, b, c, d in abcd:
        if seq[b] - seq[a] == c:
            t += d

    answer = max(answer, t)

print(answer)


Fixed submission:
import sys

read = sys.stdin.read
readline = sys.stdin.readline

N, M, Q, *abcd = map(int, read().split())
cand = [[0, 1]]

for _ in range(N - 1):
    new_cand = []
    for j in cand:
        for k in range(j[-1], M + 1):
            new_cand.append(j[:] + [k])
    cand = new_cand[:]

answer = 0
abcd = tuple(zip(*[iter(abcd)] * 4))
for seq in cand:
    t = 0
    for a, b, c, d in abcd:
        if seq[b] - seq[a] == c:
            t += d
    answer = max(answer, t)

print(answer)
Buggy python submission (verdict: Runtime Error):
import sys

read = sys.stdin.read
readline = sys.stdin.readline

N, K = map(int, read().split())
d = abs(N - K)
N %= d
if abs(N - K) < N:
    print(abs(N - K))
else:
    print(N)


Fixed submission:
import sys

read = sys.stdin.read
readline = sys.stdin.readline

N, K = map(int, read().split())
if N == K:
    print(0)
elif N > K:
    N %= K
    print(min(N, abs(N - K)))
else:
    print(min(N, abs(N - K)))
Buggy python submission (verdict: Runtime Error):
N = int(input())

answer = [(97, 'a')]
for _ in range(N - 1):
    new_answer = []
    for i, j in answer:
        for k in range(97, i + 1):
            new_answer.append((k, j + chr(k)))
        new_answer.append((i+1,j+chr(i+1))
    answer = new_answer[:]

answer = [j for _, j in answer]
answer.sort()
print('\n'.join(answer))


Fixed submission:
N = int(input())

answer = [(97, 'a')]
for _ in range(N - 1):
    new_answer = []
    for i, j in answer:
        for k in range(97, i + 2):
            new_answer.append((max(k, i), j + chr(k)))
    answer = new_answer[:]

answer = [j for _, j in answer]
answer.sort()
print('\n'.join(answer))