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

Fixed submission:
H,W=map(int,input().split())
s=[list(input()) for i in range(H)]
dx=[0,0,-1,1]
dy=[1,-1,0,0]
for i in range(H):
    for j in range(W):
        if s[i][j]=="#":
            flag=0
            for k in range(4):
                x=i+dx[k]
                y=j+dy[k]
                if 0<=x<H and 0<=y<W:
                    if s[x][y]=="#":
                        flag=1
            if flag==0:
                print("No")
                exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())
s=[list(input()) for i in range(H)]
dx=[0,0,1,-1]
dy=[-1,1,0,0]
L=[0]
k=0
#s[i][j]
#i in range(H)
#j in range(W)
def dfs(x,y):
    s[x][y]="."
    L[k]+=1
    for p in range(4):
        nx=x+dx[p]
        ny=y+dy[p]
        if 0<=nx<H and 0<=ny<W:
            if s[nx][ny]=="#":
                dfs(nx,ny)
for i in range(H):
    for j in range(W):
        if s[i][j]=="#":
            dfs(i,j)
            k+=1
            L.append(0)
if min(L[:-1])==1:
    print("No")
else:
    print("Yes")
#print(L[:-1])
Problem p03385 (python)

Fixed submission:
S=list(input())
S.sort()
if S[0]=="a" and S[1]=="b" and S[2]=="c":
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
def a:return "Yes" if "".join(sorted(list(input())))=="abc" else "No"
print(a())
Problem p03427 (python)

Fixed submission:
N = input()


def digitsum(n):
    s = str(n)
    S = 0
    for i in s:
        S += int(i)
    return S


d = len(str(N)) - 1
k = int(N[0])
print(max([digitsum(N),digitsum((k*10**d)-1)]))

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
x = [0 for i in range(N)]
y = [0 for i in range(N)]
for i in range(N):
    x[i], y[i] = map(int, input().split())


def mindis(t):
    j = 0
    for i in range(N):
        if x[i]*math.sin(t)+y[i]*math.cos(t)<x[j]*math.sin(t)+y[i]*math.cos(t):
            j = i
    return j


r = [0 for i in range(N)]
M = 2500000
for i in range(M):
    k = mindis(2*math.pi*i/M)
    r[k] += 1
S = sum(r)
for i in range(N):
    print(r[i]/S)
Problem p03433 (python)

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

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
s = [[i for i in input()]for i in range(H)]
maze = [[False for i in range(W)] for i in range(H)]
bknum = 0
for i in range(H):
    for j in range(W):
        if s[i][j]==".":
            maze[i][j]=True
        else:
            maze[i][j]=False
            bknum += 1


def ncell(i, j):
    tmp = [[i-1,j],[i+1,j],[i,j-1],[i,j+1]]
    out = []
    for p in tmp:
        if 0<=p[0]<H and 0<=p[1]<W and maze[i][j]:
            out.append(p)
    return out

d = [[1000 for j in range(W)] for i in range(H)]
prev = [[-1 for j in range(W)] for i in range(H)]
d[0][0]=0
Q = set()
for i in range(H):
    for j in range(W):
        if maze[i][j]:
            Q.add(i*W+j)
while(len(Q)!=0):
    u = list(Q)[0]
    du = d[u//W][u%W]
    for v in Q:
        if d[v//W][v%W]<du:
            du = d[v//W][v%W]
            u=v
    Q -=set([u])
    for v in ncell(u//W, u%W):
        if d[v[0]][v[1]]>d[u//W][u%W]+1:
            d[v[0]][v[1]]=d[u//W][u%W]+1
            prev[v[0]][v[1]]=u
length=d[H-1][W-1]
if length != 1000:
    print(H*W-length-1-bknum)
else:
    print(-1)
Problem p03438 (python)

Fixed submission:
N = int(input())
st = input().split()
a = [0 for i in range(N)]
A = 0
for i in range(N):
    a[i] = int(st[i])
    A += a[i]
st = input().split()
b = [0 for i in range(N)]
B = 0
for i in range(N):
    b[i] = int(st[i])
    B += b[i]
def cost(n):
    if n == 0:
        return [0, 0]
    elif n < 0:
        return [0, -n]
    elif n > 0 and n % 2 == 0:
        return [n//2, 0]
    else:
        return [(n+1)//2, 1]

K = B - A
PC = 0
MC = 0
for i in range(N):
    c = cost(b[i] - a[i])
    PC += c[0]
    MC += c[1]
if PC <= K and MC <= K and ((K-PC)*2 == (K-MC)):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
st = input().split()
a = [int(i) for i in input().split()]
A = sum(a)
b = [int(i) for i in input().split()]
B = sum(b)
def cost(n):
    if n == 0:
        return [0, 0]
    elif n < 0:
        return [0, -n]
    elif n > 0 and n % 2 == 0:
        return [n//2, 0]
    else:
        return [(n+1)//2, 1]

K = B - A
PC = 0
MC = 0
for i in range(N):
    c = cost(b[i] - a[i])
    PC += c[0]
    MC += c[1]
if PC <= K and MC <= K and ((K-PC)*2 == (K-MC)):
    print("Yes")
else:
    print("No")
Problem p03457 (python)

Fixed submission:
N = int(input())
t = [0 for i in range(N + 1)]
x = [0 for i in range(N + 1)]
y = [0 for i in range(N + 1)]
for i in range(N):
    t[i + 1], x[i + 1], y[i + 1] = map(int, input().split())
flag = 1
for i in range(N):
    dl = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])
    dt = t[i + 1] - t[i]
    if dl > dt or (dl - dt) % 2 == 1:
        flag = 0
        break
if flag == 1:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N=int(input());t=[0]*(N+1);x=[0]*(N+1);y=[0]*(N+1);flag=1
for i in range(N):t[i+1],x[i+1],y[i+1]=map(int,input().split())
for i in range(N):a=abs(x[i+1]-x[i])+abs(y[i+1]-y[i])-t[i+1]+t[i];flag=0;break if a>0 or a%2
print("Yes" if flag else "No")
Problem p03474 (python)

Fixed submission:
A,B=map(int, input().split())
S=input()
if S[A]=="-":
    st=S.split("-")
    n=st[0];m=st[1]
    if n.isdigit() and m.isdigit():
        print("Yes")
    else:
        print("No")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
A,B=map(int, input().split())
S=input()
if S[A]=="-":
    n,m=S.split("-")
    if n.isdigit() and m.isdigit():
        print("Yes")
    else:
        print("No")
else:
    print("No")
Problem p03485 (python)

Fixed submission:
st=input().split()
a=int(st[0])
b=int(st[1])
if (a+b)%2==0:
    print((a+b)//2)
else:
    print((a+b+1)//2)

Buggy submission (verdict: Runtime Error):
s=list(input())
t=list(input())
ss=''.join(sorted(ss))
tt=''.join(sorted(tt,reverse=true))
if ss<tt:
    print("Yes")
else:
    print("No")
Problem p03486 (python)

Fixed submission:
ss=input()
tt=input()
s=[]
t=[]
for i in ss:
    s.append(i)
for i in tt:
    t.append(i)
sss=sorted(s)
ttt=sorted(t)
ssss=""
tttt=""
for i in sss:
    ssss+=i
for i in range(len(ttt)):
    tttt+=ttt[len(ttt)-i-1]
if ssss<tttt:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s=list(input())
t=list(input())
ss=''.join(sorted(ss))
tt=''.join(sorted(tt,reverse=true))
if ss<tt:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s=list(input())
t=list(input())
ss=''+join(sorted(ss))
tt=''+join(sorted(tt,reverse=true))
if ss<tt:
    print("Yes")
else:
    print("No")
Problem p03501 (python)

Fixed submission:
s=input().split()
N=int(s[0]);A=int(s[1]);B=int(s[2])
if (N*A<=B):
    print("{0}".format(N*A))
else:
    print("{0}".format(B))

Buggy submission (verdict: Runtime Error):
st=input().split()
N=int(st[0]);A=int(st[1]);B=int(st[2])
print min([N*A,B])

Buggy submission (verdict: Runtime Error):
st=input().split()
N=int(st[0]);A=int(st[1]);B=int(st[2])
print min(N*A,B)

Buggy submission (verdict: Runtime Error):
st=input().split()
N=int(st[0]);A=int(st[1]);B=int(st[2])
print("{0}".format(min(A*N,B))

Buggy submission (verdict: Runtime Error):
st=input().split()
N=int(st[0]);A=int(st[1]);B=int(st[2]);
print("{0}".format(min(A*N,B))
Problem p03543 (python)

Fixed submission:
N=input()
if N[0]==N[1] and N[1]==N[2]:
  print("Yes")
elif N[1]==N[2] and N[2]==N[3]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
st=input().split()
H=int(st[0]);W=int(st[1])
c=[[0 for i in range(10)] for i in range(10)]
A=[[0 for i in range(W)]for i in range(H)]
for i in range(10):
    st=input().split()
    for j in range(10):
        c[i][j]=int(st[j])
for i in range(H):
    st=input().split()
    for j in range(W):
        A[i][j]=int(st[j])
import math
def Dijkstra(s):
    d=[math.inf]*10
    d[s]=0
    Q=list(range(10))
    V=list(range(10))
    while(len(Q)>0):
        u=Q[0]
        for i in Q:
            if d[i]<d[u]:
                u=i
        Q.remove(u)
        Vtmp=list(range(10))
        Vtmp.remove(u)
        for v in Vtmp:
            if (d[v]>d[u]+c[u][v]):
                d[v]=d[u]+c[u][v]
    return d[1]
result=0
DD=[0]*10
for i in range(10):
    DD[i]=Dijkstra(i)
for i in range(H):
    for j in range(W):
        if A[i][j]!=-1:
            result+=DD[A[i][j]]
print(result)

Buggy submission (verdict: Runtime Error):
st=input().split()
H=int(st[0]);W=int(st[1])
c=[[0 for i in range(10)] for i in range(10)]
A=[[0 for i in range(W)]for i in range(H)]
for i in range(10):
    st=input().split()
    for j in range(10):
        c[i][j]=int(st[j])
for i in range(H):
    st=input().split()
    for j in range(W):
        A[i][j]=int(st[j])
import math
def Dijkstra(s):
    d=[math.inf]*10
    d[s]=0
    Q=set(range(10))
    V=set(range(10))
    while(len(Q)>0):
        u=list(Q)[0]
        for i in Q:
            if d[i]<d[u]:
                u=i
        Q-={u}
        for v in V-{u}:
            if (d[v]>d[u]+c[u][v]):
                d[v]=d[u]+c[u][v]
    return d[1]
result=0
DD=[0]*10
for i in range(10):
    DD[i]=Dijkstra(i)
for i in range(H):
    for j in range(W):
        if A[i][j]!=-1:
            result+=DD[A[i][j]]
print(result)
Problem p03555 (python)

Fixed submission:
S=input()
T=input()
if S==T[::-1]:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

from datetime import datetime
K = int(input())
start = datetime.now()
def KSum(n):
    k = 0
    for i in str(n):
        k += int(i)
    return k

m = KSum(K)
j = 1
while((datetime.now()-start).total_seconds() < 1.8):
    for x in range(100):
	    P = KSum(K*j)
    	if m > P:
        	m = P
    	j += 1
print(m)
Problem p03558 (python)

Fixed submission:
from collections import deque
K=int(input())
reached=[0 for i in range(K)]
reached[1]=1
dist=[0 for i in range(K)]
q=deque([])
q.append(1)
while(len(q)>0):
    r=q.popleft()
    v=(r+1)%K
    reached[r]=1
    if (reached[v]==0):
        q.append(v)
        dist[v]=dist[r]+1
    v=(r*10)%K
    if (reached[v]==0):
        q.appendleft(v)
        dist[v]=dist[r]
    if (reached[0]==1):
        break
print(dist[0]+1)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

from datetime import datetime
K = int(input())
start = datetime.now()
def KSum(n):
    k = 0
    for i in str(n):
        k += int(i)
    return k

m = KSum(K)
j = 1
while((datetime.now()-start).total_seconds() < 1.8):
    for x in range(100):
	    P = KSum(K*j)
    	if m > P:
        	m = P
    	j += 1
print(m)

Buggy submission (verdict: Runtime Error):
from datetime import datetime
K = int(input())
start = datetime.now()
def KSum(n):
    k = 0
    for i in str(n):
        k += int(i)
    return k

m = KSum(K)
j = 1
while((datetime.now()-start).total_seconds() < 1.8):
  	for x in range(100):
	    P = KSum(K*j)
    	if m > P:
        	m = P
    	j += 1
print(m)
Problem p03565 (python)

Fixed submission:
Sd = input()
T = input()
if len(Sd) < len(T):
    print("UNRESTORABLE")
else:
    D = []
    for i in range(len(Sd) - len(T) + 1):
        flag = 1
        S = Sd
        for j in range(len(T)):
            if Sd[i+j] == "?" or Sd[i+j] == T[j]:
                S = S[:i+j]+T[j]+S[i+j+1:]
            else:
                flag = 0
        if flag == 1:
            D.append(S.replace("?", "a"))
    D.sort()
    if len(D) == 0:
        print("UNRESTORABLE")
    else:
        print(D[0])

Buggy submission (verdict: Runtime Error):
Sd = input()
T = input()
if len(Sd) < len(T):
    print("UNRESTORABLE")
else:
    D = []
    for i in range(len(Sd) - len(T) + 1):
        flag = 1
        S = Sd
        for j in range(len(T)):
            if Sd[i+j] == "?" or Sd[i+j] == T[j]:
                S = S[:i+j]+T[j]+S[i+j+1:]
            else:
                flag = 0
        if flag == 1:
            D.append(S.replace("?", "a"))
D.sort()
if len(D) == 0:
    print("UNRESTORABLE")
else:
    print(D[0])
Problem p03575 (python)

Fixed submission:
V, E = map(int, input().split())
a = [0 for i in range(E)]
b = [0 for i in range(E)]
m = [[0 for i in range(V)] for i in range(V)]
for i in range(E):
    a[i], b[i]=map(int, input().split())
    m[a[i]-1][b[i]-1]+=1
    m[b[i]-1][a[i]-1]+=1
S=0
for n in range(E):
    m[a[n]-1][b[n]-1]-=1
    m[b[n]-1][a[n]-1]-=1
    U=[[] for i in range(V)]
    for i in range(V):
        for j in range(V):
            if m[i][j]!=0:
                U[i].append(j)
    P=[set() for i in range(E+1)]
    P[0].add(0)
    Q=set()
    R=[False for i in range(V)]
    for i in range(1,E+1):
        for u in P[i-1]:
            for v in U[u]:
                if not(R[v]):
                    R[v]=True
                    P[i].add(v)
                    Q.add(v)
        if len(P[i])==0:
            break
    if len(Q)!=V:
        S+=1
    m[a[n]-1][b[n]-1]+=1
    m[b[n]-1][a[n]-1]+=1
print(S)

Buggy submission (verdict: Runtime Error):
import numpy
N, M = map(int, input().split())
mat = [[0 for i in range(N)] for i in range(N)]
a = [0 for i in range(M)]
b = [0 for i in range(M)]
for i in range(M):
    st = input().split()
    a[i] = int(st[0])-1
    b[i] = int(st[1])-1
    mat[a[i]][b[i]]+=1
    mat[b[i]][a[i]]+=1

ans = 0
for n in range(M):
    mtx = numpy.array(mat)
    mtx[a[n],b[n]] -= 1
    mtx[b[n],a[n]] -= 1
    roopex = numpy.zeros([N, N])
    for i in range(N):
        for j in range(N):
            if mtx[i, j] != 0:
                roopex[i, j] = 1
    rootnum = numpy.dot(mtx, mtx)
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if rootnum[i, j] != 0:
                    roopex[i, j] = 1
        rootnum = numpy.dot(rootnum, mtx)
    flag = 0
    for i in range(N):
        for j in range(N):
            if roopex[i, j] == 0:
                flag = 1
                break
        if flag == 1:
            break
    if flag == 1:
        ans += 1

print(ans)
Problem p03583 (python)

Fixed submission:
N=int(input())
for h in range(1,3501):
	for n in range(1,3501):
		A=N*h*n
		B=4*h*n-N*n-N*h
		if B<=0:
			continue
		if A%B==0:
			print(h,n,A//B)
			exit()

Buggy submission (verdict: Runtime Error):
N=int(input())
for h in range(1,3501):
	for n in range(1,3501):
		A=N*h*n
		B=4*h*n-N*n-N*h
        if B<0:
            continue
		if A%B==0:
			print(h,n,A//B)
			exit()

Buggy submission (verdict: Runtime Error):
N=int(input())
for h in range(1,3501):
	for n in range(1,3501):
		A=N*h*n
		B=4*h*n-N*n-N*h
		if A%B==0 and B>0:
			print(h,n,A//B)
			exit()
Problem p03587 (python)

Fixed submission:
print(input().count("1"))

Buggy submission (verdict: Runtime Error):
print(sum([int(list(input())[i]) for i in range(6)]))
Problem p03597 (python)

Fixed submission:
N = int(input())
A = int(input())
print(N ** 2 - A)

Buggy submission (verdict: Runtime Error):
A, B, C, D, E, F = map(int, input().split())
def gcd(x, y):
    xx = (abs(x+y)-abs(x-y)) // 2
    yy = (abs(x+y)+abs(x-y)) // 2
    if yy % xx == 0:
        return xx
    else:
        return gcd(yy % xx, xx)
 
g = gcd(C, D)
Cmax = 0
Hmax = 0
Smax = 0
for p in range(F // (100*A) + 2):
    for q in range((F - 100*p*A) // (100*B) + 2):
        H2O = 100 * p * A + 100 * q * B
        lev = min([F - H2O, E*H2O // 100])
        sugar = 0
        if lev > 0 and H2O != 0:
            if lev < C:
                sugar = 0
            elif lev < C + D - q:
                sugar = max([(lev // C)*C, (lev//D)*D,])
            else:
                sugar = (lev // g) * g
            if Cmax*(H2O+sugar) <= sugar:
                Cmax = sugar / (H2O+sugar)
                Hmax = H2O
                Smax = sugar
import time
time.sleep(A*0.08)
print("{0} {1}".format(Smax+Hmax, Smax))

Buggy submission (verdict: Runtime Error):
A, B, C, D, E, F = map(int, input().split())
def gcd(x, y):
    xx = (abs(x+y)-abs(x-y)) // 2
    yy = (abs(x+y)+abs(x-y)) // 2
    if yy % xx == 0:
        return xx
    else:
        return gcd(yy % xx, xx)

g = gcd(C, D)
Cmax = 0
Hmax = 0
Smax = 0
for p in range(F // (100*A) + 2):
    for q in range((F - 100*p*A) // (100*B) + 2):
        H2O = 100 * p * A + 100 * q * B
        lev = min([F - H2O, E*H2O // 100])
        sugar = 0
        if lev > 0 and H2O != 0:
            if lev < C:
                sugar = 0
            elif lev < C + D - q:
                sugar = max([(lev // C)*C, (lev//D)*D,])
            else:
                sugar = (lev // g) * g
            if Cmax*(H2O+sugar) <= sugar:
                Cmax = sugar / (H2O+sugar)
                Hmax = H2O
                Smax = sugar

print("{0} {1}".format(Smax+Hmax, Smax))
Problem p03613 (python)

Fixed submission:
N = int(input())
a = [0 for i in range(N)]
st = input().split()
for i in range(N):
  a[i] = int(st[i])
m = min(a); M = max(a)
b = [0 for i in range(M - m + 1)]
for i in range(N):
  b[a[i]-m] += 1
c = [0 for i in range(M - m + 1)]
if len(b) >= 2:
	c[0] = b[0] + b[1]
	c[M - m] = b[M - m] + b[M - m - 1]
	for i in range(1, M - m):
	  c[i] = b[i-1] + b[i] + b[i+1]
	print(max(c))
else:
  print(max(b))

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [0 for i in range(N)]
st = input().split()
for i in range(N):
  a[i] = int(st[i])
m = min(a); M = max(a)
b = [0 for i in range(M - m + 1)]
for i in range(N):
  b[a[i]-m] += 1
c = [0 for i in range(M - m + 1)]
c[0] = b[0] + b[1]
c[M - m] = b[M - m] + b[M - m - 1]
for i in range(1, M - m):
  c[i] = b[i-1] + b[i] + b[i+1]
print(max(c))
Problem p03625 (python)

Fixed submission:
N = int(input())
st = input().split()
A = [0 for i in range(N)]
for i in range(N):
  A[i] = int(st[i])

A.sort(reverse = True)
U = []
for i in range(N-1):
  if A[i] == A[i+1]:
    U.append(A[i])
    A[i] = -1
    A[i+1] = -1
  if len(U) >= 2:
    break
if len(U) >= 2:
	print(U[0] * U[1])
else:
  print(0)

Buggy submission (verdict: Runtime Error):
N = int(input())
st = input().split()
A = [0 for i in range(N)]
for i in range(N):
  A[i] = int(st[i])

A.sort(reverse = True)
U = []
for i in range(N-1):
  if A[i] == A[i+1]:
    U.append(A[i])
    A[i] = -1
    A[i+1] = -1
  if len(U) >= 2:
    break
print(U[0] * U[1])
Problem p03637 (python)

Fixed submission:
N = int(input())
a = [int(i) for i in input().split()]
P=0
Q=0
R=0
for i in range(N):
    if a[i]%4==0:
        P+=1
    elif a[i]%4==2:
        Q+=1
    else:
        R+=1
if (Q==0 and R>P+1) or (Q!=0 and R>P):
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
N = int(input())
R = [0 for i in range(2)]
st = input().split()
for i in range(N):
    k = int(st[i])
    m = 0
    if k % 4 == 1 or k % 4 == 3:
        m = 0
    elif k % 4 == 2:
        m = 1
    else:
        m = 2
    R[m] += 1
    

if R[1]+R[2]*2 < 2*(N-1):
    print("No")
else:
    print("Yes")
Problem p03643 (python)

Fixed submission:
print("ABC{0}".format(input()))

Buggy submission (verdict: Runtime Error):
print("ABC{0}".format(input())
Problem p03646 (python)

Fixed submission:
K = int(input())
N = 50
a = [i+K//N for i in range(N)]
for i in range(K%N):
    for j in range(N):
        if i%N==j:
            a[j]+=N
        else:
            a[j]-=1
print(N)
print(str(a)[1:][:-1].replace(", ", " "))

Buggy submission (verdict: Runtime Error):
K = int(input())
N = 10
a = [i for i in range(N)]
for k in range(K//N):
    a[k]+=K//N
for i in range(K%N):
    for j in range(N):
        if i==j:
            a[j]+=N
        else:
            a[j]-=1
print(N)
print(str(a)[1:][:-1].replace(", ", " "))

Buggy submission (verdict: Runtime Error):
K = int(input())
N = 10
a = [i for i in range(N)]
for k in range(K//N):
    a[i]+=K//N
for i in range(K%N):
    for j in range(N):
        if i==j:
            a[j]+=N
        else:
            a[j]-=1
print(N)
print(str(a)[1:][:-1].replace(", ", " "))
Problem p03693 (python)

Fixed submission:
r,g,b = map(int, input().split())
if (g*2+b)%4 == 0:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
r,g,b = map(int, input().split())
if (g*2+b)%4 == 0:
    print(“YES”)
else:
    print(“NO”)
Problem p03694 (python)

Fixed submission:
n=int(input())
a=[int(i) for i in input().split()]
print(max(a)-min(a))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[i for i in input().split()]
print(max(a)-min(a))
Problem p03695 (python)

Fixed submission:
N=int(input())
a=[int(i)//400 for i in input().split()]
s=set()
r=0
for i in range(N):
    if a[i]>=8:
        r+=1
    else:
        s.add(a[i])
print("{0} {1}".format(max([1,len(s)]),len(s)+r))

Buggy submission (verdict: Runtime Error):
N=int(input())
a=[int(i)//400 for i in input().split()]
s=set()
r=0
for i in range(N):
    if a[i]==7:
        r+=1
    else:
        s.add(a[i])
print("{0} {1}".format(min([1,len(s)]),len(s)+r)
Problem p03730 (python)

Fixed submission:
def gcd(x,y):
    p=max([x,y])
    q=min([x,y])
    if p%q==0:
        return q
    else:
        return gcd(q,p%q)

A, B, C = map(int, input().split())
if C%gcd(A,B)==0:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
import math
A, B, C = map(int, input().split())
if C%math.gcd(A,B)==0:
    print("YES")
else:
    print("NO")
Problem p03747 (python)

Fixed submission:
N,L,T=map(int,input().split())
X=[0 for i in range(N)]
W=[0 for i in range(N)]
D=0
for i in range(N):
    X[i],W[i]=map(int,input().split())
    W[i]=-2*W[i]+3
    D+=(X[i]+T*W[i])//L
D%=N
Y=sorted([((T*W[i])+X[i])%L for i in range(N)])
for i in range(N):
    print(Y[(D+i)%N])

Buggy submission (verdict: Runtime Error):
N,L,T=map(int,input().split())
X=[0 for i in range(N)]
W=[0 for i in range(N)]
for i in range(N):
    X[i],W[i]=map(int,input().split())
Y=[0 for i in range(N)]
for i in range(N):
    if W[i]==1:
        Y[i]=(X[i]+T)%L
    else:
        Y[i]=(X[i]-T)%L
def dist(i,j):
    if (3-2*W[i])*(3-2*W[j])==1:
        return -1
    else:
        if 3-2*W[i]==1:
            D=(X[j]-X[i])%L
            return D//2
        else:
            D=(X[i]-X[j])%L
            return D//2
z=0
dt=3-2*W[0]
for i in range(1,N):
    ds=3-2*W[i]
    if dt*ds==1:
        continue
    z+=dt*((T//L)*2)
    K=T%L
    if K>=dist(0,i):
        z+=dt
    if K>=dist(0,i)+L//2:
        z+=st
z=-z%N
Z=Y[z:]+Y[:z]
for i in range(N):
    print(Z[i])
Problem p03762 (python)

Fixed submission:
N,M=map(int,input().split())
x=[int(i) for i in input().split()]
y=[int(i) for i in input().split()]
P=10**9+7
X=0
Y=0
for i in range(1,N+1):
  X+=x[i-1]*(2*i-1-N)
  X=X%P
for j in range(1,M+1):
  Y+=y[j-1]*(2*j-1-M)
  Y=Y%P
print((X*Y)%P)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
x=[int(i) for i in input().split()]
y=[int(i) for i in input().split()]
P=10**9+7
X=0
Y=0
for i in range(1,M+1):
  X+=x[i-1]*(2*i-1-M)
  X=X%P
for j in range(1,N+1):
  Y+=y[j-1]*(2*j-1-N)
  Y=Y%P
print((X*Y)%P)
Problem p03844 (python)

Fixed submission:
st=input().split()
A=int(st[0])
B=int(st[2])
op=st[1]
if op=="+":
  print(A+B)
else:
  print(A-B)

Buggy submission (verdict: Runtime Error):
st=input().split()
A=int(st[0])
B=int(st[1])
op=st[2]
if op=="+":
  print(A+B)
else:
  print(A-B)
Problem p04016 (python)

Fixed submission:
import math
def f(b,n):
    if n<b:
        return n
    else:
        return f(b,n//b)+(n%b)
N=int(input())
S=int(input())
if N==S:
    print(N+1)
else:
    for b in range(2,int(math.sqrt(N))+2):
        if f(b,N)==S:
            print(b)
            exit()
    ans=10**13
    for p in range(1,int(math.sqrt(N))+2):
        if (N-S)%p!=0:
            continue
        b=(N-S)//p+1
        if b<=1:
            continue
        if f(b,N)==S:
            ans=b
    if ans==10**13:
        print(-1)
    else:
        print(ans)

Buggy submission (verdict: Runtime Error):
import math
def f(b,n):
    if n<b:
        return n
    else:
        return f(b,n//b)+(n%b)
N=int(input())
S=int(input())
if N==S:
    print(N+1)
else:
    for b in range(2,int(math.sqrt(N))+2):
        if f(b,N)==S:
            print(b)
            exit()
    for p in range(int(math.sqrt(N))+2):
        b=(N-S)//(p+1)
        if f(b,N)==S:
            print(b)
            exit()
    print(-1)