Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
if N >= M:
  print(0)
  exit()
  
X = list(map(int,input().split()))

X.sort()
dX,dX1 = [],[]
for i in range(M-1):
  dX.append(X[i+1]-X[i])
  dX1.append(X[i+1]-X[i])
seppoint = []

  
for i in range(N-1):
  dXmax = [j for j,v in enumerate(dX) if v == max(dX)]
  if len(dXmax) > 1: 
    sumdist0 = 2*10**5
    for k in dXmax:
      dXtmp = dX[:k] + dX[k+1:]
      sumdist1 = (sum(dXtmp))
      if sumdist0 > sumdist1:
        sumdist0 = sumdist1
        dX = dXtmp
        seppoint.append(k)
  else:
    dX = dX[:dXmax[0]] + dX[dXmax[0]+1:]
    seppoint.append(dXmax[0])
print(sum(dX))
#seppoint.sort()
#print(seppoint)
#for i in seppoint:
# dX1[i] = -1
#print(dX1)
#anslist = []
#tmpans = 0

#for i in range(len(dX1)):
#  if dX1[i] == -1:
#    anslist.append(tmpans)
#    tmpans = 0
#  else:
 #   tmpans += dX1[i]
 #   if i == len(dX1)-1:
 #     anslist.append(tmpans)
 #    tmpans = 0
 # print(anslist)
    
#print(max(anslist))

Fixed submission:
N, M = map(int, input().split())
#if N >= M:
#  print(0)
#  exit()
  
X = list(map(int,input().split()))

X.sort()
diff = []

for i in range(1,M):
  diff.append(X[i]-X[i - 1])

diff.sort()

for i in range(N - 1):
  if len(diff) != 0:
    diff.pop()

print(sum(diff))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N, W = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
INF = 10**11+1
dp = [[-1]*(W+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
  w,v = A[i-1]
  for j in range(W+1):
    dp[i][j] = dp[i-1][j]
    if j >= w and dp[i-1][j-w] != -1:
      dp[i][j] = max(dp[i-1][j-w]+v,dp[i][j])
print(max(dp[-1]))

Fixed submission:
N, W = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
dp = [[-1]*(W+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
  w,v = A[i-1]
  for j in range(W+1):
    dp[i][j] = dp[i-1][j]
    if j >= w and dp[i-1][j-w] != -1:
      dp[i][j] = max(dp[i-1][j-w]+v,dp[i][j])
print(max(dp[-1]))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N, W = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
INF = 10**11+1
dp = [[-1]*(W+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
  w,v = A[i-1]
  for j in range(W+1):
    if dp[i-1][j] != -1:
      dp[i][j] = dp[i-1][j]
    if j >= w and dp[i-1][j-w] != -1:
      dp[i][j] = max(dp[i-1][j-w]+v,dp[i][j])
print(max(dp[-1]))

Fixed submission:
N, W = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
dp = [[-1]*(W+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
  w,v = A[i-1]
  for j in range(W+1):
    dp[i][j] = dp[i-1][j]
    if j >= w and dp[i-1][j-w] != -1:
      dp[i][j] = max(dp[i-1][j-w]+v,dp[i][j])
print(max(dp[-1]))
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
table = []
for i in range(N):
  w,v = map(int, input().split())
  table.append((w,v))
INF = W+1
dp = [[INF]*(10**3*N+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
  for k in range(10**3*N+1):
    w,v = table[i-1]
    dp[i][k] = dp[i-1][k]
    if v<=k and dp[i-1][k-v] <= INF:
      dp[i][k] = min(dp[i][k],dp[i-1][k-v]+w)

for i in range(10**3*N,-1,-1):
  if 0<= dp[-1][i] <= W:
    print(i)
    exit()


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

N, W = map(int, input().split())
table = []
for i in range(N):
  w,v = map(int, input().split())
  table.append((w,v))
INF = W+1
dp = [[INF]*(10**3*N+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
  for k in range(10**3*N+1):
    w,v = table[i-1]
    dp[i][k] = dp[i-1][k]
    if v<=k and dp[i-1][k-v] <= INF:
      dp[i][k] = min(dp[i][k],dp[i-1][k-v]+w)

for i in range(10**3*N,-1,-1):
  if 0<= dp[-1][i] <= W:
    print(i)
    exit()

Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
table = []
for i in range(N):
  w,v = map(int, input().split())
  table.append((w,v))
INF = W+1
dp = [[INF]*(10**3*N+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
  for k in range(10**3*N+1):
    w,v = table[i-1]
    dp[i][k] = dp[i-1][k]
    if v<=k and dp[i-1][k-v] <= INF:
      dp[i][k] = min(dp[i][k],dp[i-1][k-v]+w)

for i in range(10**3*N,-1,-1):
  if 0<= dp[-1][i] <= W:
    print(i)
    exit()


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

N, W = map(int, input().split())
table = []
for i in range(N):
  w,v = map(int, input().split())
  table.append((w,v))
INF = W+1
dp = [[INF]*(10**3*N+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
  for k in range(10**3*N+1):
    w,v = table[i-1]
    dp[i][k] = dp[i-1][k]
    if v<=k and dp[i-1][k-v] <= INF:
      dp[i][k] = min(dp[i][k],dp[i-1][k-v]+w)

for i in range(10**3*N,-1,-1):
  if 0<= dp[-1][i] <= W:
    print(i)
    exit()
Buggy python submission (verdict: Runtime Error):
import bisect
N, M = map(int, input().split())
city = []
table = [0]*M
count = [0]*M
for i in range(M):
  P, Y = map(int, input().split())
  P -= 1
  city.append((i,P,Y))
city.sort(key=lambda x:x[2])
for i, P, Y in city:
  count[P] += 1
  x = str(count[P])
  P = str(P+1)
  ans = P.zfill(6)+x.zfill(6)
  table[i] = ans
for i in range(M):
  print(table[i])

Fixed submission:
N, M = map(int, input().split())
PY = [list(map(int,input().split())) for i in range(M)]
for i in range(M):
  PY[i].append(i)
  
PY.sort(key=lambda x:x[1])
pcount = {i:0 for i in range(1,N+1)}
ID = {i:"" for i in range(1,M+1)}

for i in range(M):
  pcount[PY[i][0]] += 1
  PY[i].append("{:0=6}".format(PY[i][0]) + "{:0=6}".format(pcount[PY[i][0]]))
PY.sort(key=lambda x:x[2])
for i in range(M):
  print(PY[i][3])

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N, M = map(int, input().split())
city = []
table = [[] for i in range(N)]
for i in range(M):
  P, Y = map(int, input().split())
  city.append((P,Y))
  bisect.insort_left(table[P-1],Y)
for P, Y in city:
  x = str(bisect.bisect_left(table[P-1],Y)+1)
  P = str(P)
  ans = P.zfill(6)+x.zfill(6)
  print(ans)

Fixed submission:
N, M = map(int, input().split())
PY = [list(map(int,input().split())) for i in range(M)]
for i in range(M):
  PY[i].append(i)
  
PY.sort(key=lambda x:x[1])
pcount = {i:0 for i in range(1,N+1)}
ID = {i:"" for i in range(1,M+1)}

for i in range(M):
  pcount[PY[i][0]] += 1
  PY[i].append("{:0=6}".format(PY[i][0]) + "{:0=6}".format(pcount[PY[i][0]]))
PY.sort(key=lambda x:x[2])
for i in range(M):
  print(PY[i][3])
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
N, M = map(int, input().split())
S = input()
T = input()
L = N*M//gcd(N,M)
memo = []

for i in range(N):
  memo.append(i*L//N)
for i in range(M):
  tmp = i*L//M
  if tmp in memo:
    if S[tmp//(L//N)] == T[i]:
      continue
    else:
      print(-1)
      exit()
print(L)


Fixed submission:
from fractions import gcd
N, M = map(int, input().split())
S = input()
T = input()
L = N*M//gcd(N,M)
a = L//N
b = L//M
c = a*b//gcd(a,b)
i = 0
while i<L:
  if S[i//(L//N)] != T[i//(L//M)]:
    print(-1)
    exit()
  i += c
print(L)
Buggy python submission (verdict: Runtime Error):
import collections

n = int(input())
v = list(map(int, input().split()))
odd, even = [], []

for i in range(n):
  if i % 2 == 0:
    even.append(v[i])
  else:
    odd.append(v[i])

    
codd = collections.Counter(odd)
ceven = collections.Counter(even)
mostodd = codd.most_common()[0]
mosteven = ceven.most_common()[0]

if mostodd[0] != mosteven[0]:
  ans = n - mostodd[1] - mosteven[1]
else:
  if mostodd[1] >= mosteven[1]:
    if len(ceven.most_common()) > 1:
      even2nd = ceven.most_common()[1] 
    else:
      even2nd = 0
    ans = n - mostodd[1] - even2nd
  else:
    if len(codd.most_common()) > 1:
      odd2nd = codd.most_common()[1] 
    else:
      odd2nd = 0
    ans = n - odd2nd - mosteven[1] 
print(ans)
    

Fixed submission:
import collections

n = int(input())
v = list(map(int, input().split()))
odd, even = [], []

for i in range(n):
  if i % 2 == 0:
    even.append(v[i])
  else:
    odd.append(v[i])

    
codd = collections.Counter(odd)
ceven = collections.Counter(even)
mostodd = codd.most_common()[0]
mosteven = ceven.most_common()[0]

if mostodd[0] != mosteven[0]:
  ans = n - mostodd[1] - mosteven[1]
else:
  if len(ceven.most_common()) > 1:
    even2nd = ceven.most_common()[1][1]
  else:
    even2nd = 0
  ans1 = n - mostodd[1] - even2nd
  if len(codd.most_common()) > 1:
    odd2nd = codd.most_common()[1][1]
  else:
    odd2nd = 0
  ans2 = n - odd2nd - mosteven[1] 
  ans = min(ans1, ans2)
print(ans)
Buggy python submission (verdict: Runtime Error):
N, X = map(int, input().split())
x = list(map(int, input().split()))

xdef = [abs(x[i]-X) for i in range(N)]
def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z

if N == 1:
  print(xdef[0])
else:
  tmp = gcd(xdef[0], xdef[1])
  for i in range(1,N):
    gcd = gcd(tmp,xdef[i])
  print(gcd)

Fixed submission:
N, X = map(int, input().split())
x = list(map(int, input().split()))

xdef = [abs(x[i]-X) for i in range(N)]
def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z

if N == 1:
  print(xdef[0])
else:
  tmp = gcd(xdef[0], xdef[1])
  for i in range(1,N):
    tmp = gcd(tmp,xdef[i])
  print(tmp)

Buggy python submission (verdict: Runtime Error):
N, X = map(int, input().split())
x = list(map(int, input().split()))

xdef = [abs(x[i]-X) for i in range(N)]
def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z
    
tmp = gcd(xdef[0], xdef[1])
for i in range(2,N):
  gcd = gcd(tmp,xdef[i])
print(gcd)

Fixed submission:
N, X = map(int, input().split())
x = list(map(int, input().split()))

xdef = [abs(x[i]-X) for i in range(N)]
def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z

if N == 1:
  print(xdef[0])
else:
  tmp = gcd(xdef[0], xdef[1])
  for i in range(1,N):
    tmp = gcd(tmp,xdef[i])
  print(tmp)
Buggy python submission (verdict: Runtime Error):
H, W = map(int,input().split())
A = [list(map(int,input().split())) for i in range(H)]
n = 0
memo = []

for x in range(W):
  for y in range(H-1):
    if A[y][x]%2 == 1:
      A[y][x] -= 1
      A[y+1][x] += 1
      n += 1
      memo.append([y+1,x+1,y+2,x+1])
for x in range(W):
  if A[H-1][x]%2 == 1:
    A[H-1][x] -= 1
    A[H-1][x+1] += 1
    memo.append([H,x+1,H,x+2])
    n += 1
print(n)
for i in range(n):
  print(" ".join(map(str,memo[i])))

Fixed submission:
H, W = map(int, input().split())
a = [list(map(int, input().split())) for i in range(H)]
N = 0
ans = []
for x in range(W):
  for y in range(H-1):
    if a[y][x]%2 == 1:
      a[y][x] -= 1
      a[y+1][x] += 1
      ans.append([y+1,x+1,y+2,x+1])
      N += 1
for x in range(W-1):
  if a[H-1][x]%2 == 1:
    a[H-1][x] -= 1
    a[H-1][x+1] += 1
    ans.append([H,x+1,H,x+2])
    N += 1
print(N)
for i in ans:
  print(" ".join(map(str,i)))
Buggy python submission (verdict: Runtime Error):
x1, y1, x2, y2 = map(int, input().split())

l = max(abs(x1-x2), abs(x2-y2))

if x1 == x2 and y1 > y2:
  x3, y3, x4, y4 = x2+l, y2, x1+l, y1
elif x1 < x2 and y1 == y2:
  x3, y3, x4, y4 = x2, y2+l, x1, y1+l
elif x1 == x2 and y1 < y2:
  x3, y3, x4, y4 = x2-l, y2, x1-l, y1
elif x1 > x2 and y1 == y2:
  x3, y3, x4, y4 = x2, y2-l, x1, y1-l
print(x3, y3, x4, y4)



Fixed submission:
x1, y1, x2, y2 = map(int, input().split())
  
dx, dy = x2-x1, y2-y1
x3, y3, x4, y4 = x2-dy, y2+dx, x1-dy, y1+dx

print(x3, y3, x4, y4)
Buggy python submission (verdict: Runtime Error):
import bisect

N, K = map(int, input().split())
x = list(map(int, input().split()))
ans = 10**9
#print(bisect.bisect(x, 0))

for i in range(len(x) - K + 1):
  if x[i] <= 0 and x[i+K-1] >= 0:
    tmp = abs(x[i]) + x[i+K-1] + min(abs(x[i]), x[i+K-1])
  elif i == bisect.bisect(x, 0):
    tmp = x[i+K-1]
  elif i+K-1 == bisect.bisect(x, 0):
    tmp = abs[x[i]]
#  print("i:{}, i+K-1:{}, tmp:{}".format(i, i+K-1, tmp))
  ans = min(tmp, ans)
print(ans)

Fixed submission:
import bisect

N, K = map(int, input().split())
x = list(map(int, input().split()))
ans, tmp = 10**9, 10**9

#print(bisect.bisect(x, 0))

for i in range(len(x) - K + 1):
  if x[i] <= 0 and x[i+K-1] >= 0:
    tmp = abs(x[i]) + x[i+K-1] + min(abs(x[i]), x[i+K-1])
  elif x[i] < 0 and x[i+K-1] <= 0:
    tmp = abs(x[i])
  elif x[i] >= 0 and x[i+K-1] > 0:
    tmp = x[i+K-1]
#  elif i == bisect.bisect(x, 0)-1:
#    tmp = x[i+K-1]
#  elif i+K-1 == bisect.bisect(x, 0)-1:
#    tmp = abs[x[i]]
#  print("i:{}, i+K-1:{}, tmp:{}".format(i, i+K-1, tmp))
  ans = min(tmp, ans)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int,input().split())
br = [list(map(int,input().split())) for i in range(M)]
br.sort(key=lambda x:x[1])
state = [1]*(N-1)
ans = 0

for i in range(M):
  if 0 in state[br[i][0]-1:br[i][1]-1]:
    continue
  else:
    state[br[i][1]-2] = 0
    ans += 1
print(ans)

Fixed submission:
from operator import itemgetter
N, M = map(int, input().split())
table = []
for i in range(M):
  a,b = map(int, input().split())
  table.append((a,b))
t = 0
ans = 0
table.sort(key=itemgetter(1))
for a,b in table:
  if t < a:
    ans += 1
    t = b-1
print(ans)
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
sw = [list(str(input())) for i in range(H)]
dx = [1,0,-1,0]
dy = [0,1,0,-1]

for i in range(H):
  for j in range(W):
    if sw[i][j] == "#":
      counter = 0
      for k in range(4):
        if i+dx[k] < 0 or i+dx[k] >= H or j+dy[k] < 0 or j+dy[k] >= H:
          counter += 1
        elif sw[i+dx[k]][j+dy[k]] == ".":
          counter += 1
      if counter == 4:
        print("No")
        exit()
print("Yes")

Fixed submission:
H, W = map(int, input().split())
s = [list(input()) for i in range(H)]
check = [[False]*W]*H
dx = -1,0,1,0
dy = 0,-1,0,1

for h in range(H):
  for w in range(W):
    bcount = 0 #隣接する黒ますの個数
    if s[h][w] == "#":
      for i in range(4):
        if 0 <= h+dx[i] <= H-1 and 0 <= w+dy[i] <= W-1 and s[h+dx[i]][w+dy[i]] == "#":
            bcount += 1
      if bcount == 0:
        print("No")
        exit()
print("Yes")
Buggy python submission (verdict: Runtime Error):
N = int(input())
red = []
blue = []
chosen = [0]*N
ans = 0
for i in range(N):
  a,b = map(int, input().split())
  red.append((a,b))
for i in range(N):
  c,d = map(int, input().split())
  blue.append((c,d))
  
red.sort(key=lambda x:x[1])
blue.sort(key=lambda x:x[0])

for i in range(N):
  for j in range(N):
    if blue[i][0] >= red[j][0] and blue[i][1] >= red[j][1] and chosen[j] == 0
      chosen[j] = 1
      ans += 1
      break
      
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
N = int(input())
R = []
B = []
ans = 0
for i in range(N):
  a,b = map(int,input().split())
  R.append((a,b))
for i in range(N):
  c,d = map(int,input().split())
  B.append((c,d))
R.sort(key=lambda x:x[0])
B.sort(key=lambda x:x[0])
H = []
l = 0
for i in range(N):
  for j in range(l,N):
    if R[j][0] > B[i][0]:
      l = j
      break
    H.append(R[j])
  H.sort(key=lambda x:x[1], reverse=True)
  for k in range(len(H)):
    if H[k][1] < B[i][1]:
      H.pop(k)
      ans += 1
      break
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
X,Y = map(int,input().split())
print(int(math.floor(Y/X,2)+1))

Fixed submission:
X, Y = map(int, input().split())
A = X
count = 0

while A <= Y:
  count += 1
  A = A * 2
  
print(count)
Buggy python submission (verdict: Runtime Error):
S = input()
l = len(S)
ans = 0

for i in range(2**(l-1)):
    T = S[0]
    for j in range(l-1):
        if i>>j & 1:
            T = T + ""
        else:
            T = T + "+"
        T = T+S[j+1]
    if eval(T) == 7:
        print(T+"=7")

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

N = len(S) #+,-の入りうる場所はN-1か所 

for i in range(2**(N-1)):
  ans = S[0]
  plmi=["-"]*(N-1)
  for j in range(N-1):
    if (i >> j) & 1:
      ans -= S[j+1]
    else:
      ans += S[j+1]
      plmi[j] = "+"
      
  if ans == 7:
    print(S[0],plmi[0],S[1],plmi[1],S[2],plmi[2],S[3],"=7", sep="")
    break
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

ls = len(S)
lt = len(T)

for i in range(ls-lt+1):
    for j in range(lt):
        if S[i] != "?" and S[i] != T[j]:
            break
    else:
       left = i

ans = S[:i]+T+S[i+lt:]
print(ans.replace("?","a"))

Fixed submission:
S2 = input()
T = input()
N = len(S2)

Tplace = {i:False for i in range(N)}
#print(Tplace)

for i in range(N-len(T)+1):
  counter = 0
  for j in range(len(T)):
    if S2[i+j] == T[j] or S2[i+j] == "?":     
      counter += 1
#      print(S2[i+j],T[j],counter)
      continue
    else:
#      print(2,i,j,S2[i+j])
      break
#  print(3)
  if counter == len(T):
    Tplace[i] = True
#print(Tplace)

ans = []

for key, value in Tplace.items():
  if value:
    tmp = S2[:key] + T + S2[key+len(T):] 
    tmp2 = tmp.replace('?', 'a')
    ans.append(tmp2)
ans.sort()
print(ans[0] if len(ans) > 0 else "UNRESTORABLE")
Buggy python submission (verdict: Runtime Error):
A, B, C, D, E, F = map(int, input().split())
M = 0
Concmax = 0

for i in range(F//100//A+1):
  WA = i*100*A
  for k in range((F-WA)//100//B+1):
    WB = k*100*B
    W = WA+WB
    if W <= F:
      for j in range((F-W)//C+1):
        SC = j*C
        for l in range((F-W-C)//D+1):
          SD = l*D
          S = SC+SD
          if 0 < W+S <= F and S <= W*E/100:
            Conc = S/(S+W)
            if Conc > Concmax:
              Concmax= Conc
              Sans = S
              M = S+W
#              print(WA,WB,SC,SD,Conc)
print(M,Sans)

Fixed submission:
A, B, C, D, E, F = map(int, input().split())
ans = 0
W = set()
S = set()

for i in range(F):
  x1 = 100 * A * i
  if x1 > F:
    break
  for j in range(F):
    x2 = x1 + 100 * B * j
    if x2 > F or x2 == 0:
      break
    W.add(x2)
for i in range(F):
  y1 = C * i
  if y1 > F:
    break
  for j in range(F):
    y2 = y1 + D * j
    if y2 > F:
      break
    S.add(y2)

W = list(set(W))
S = list(set(S))

for i in range(len(W)):
  for j in range(len(S)):
    tmp = S[j]/W[i]
    tmp1 = S[j] + W[i]
    if tmp1 <= F and ans <= tmp <= E/100:
      ans = tmp
      ans1 = tmp1
      ans2 = S[j]
print(ans1, ans2)

Buggy python submission (verdict: Runtime Error):
A, B, C, D, E, F = map(int, input().split())
ans = 0
W = set()
S = set()

for i in range(F):
  x1 = 100 * A * i
  if x1 > F:
    break
  for j in range(F):
    x2 = x1 + 100 * B * j
    if x2 > F or x2 == 0:
      break
    W.add(x2)
for i in range(F):
  y1 = C * i
  if y1 > F:
    break
  for j in range(F):
    y2 = y1 + D * j
    if y2 > F:
      break
    S.add(y2)

W = list(set(W))
S = list(set(S))

for i in range(len(W)):
  for j in range(len(S)):
    tmp = S[j]/W[i]
    tmp1 = S[j] + W[i]
    if tmp1 <= F and ans < tmp <= E/100:
      ans = tmp
      ans1 = tmp1
      ans2 = S[j]
print(ans1, ans2)

Fixed submission:
A, B, C, D, E, F = map(int, input().split())
ans = 0
W = set()
S = set()

for i in range(F):
  x1 = 100 * A * i
  if x1 > F:
    break
  for j in range(F):
    x2 = x1 + 100 * B * j
    if x2 > F or x2 == 0:
      break
    W.add(x2)
for i in range(F):
  y1 = C * i
  if y1 > F:
    break
  for j in range(F):
    y2 = y1 + D * j
    if y2 > F:
      break
    S.add(y2)

W = list(set(W))
S = list(set(S))

for i in range(len(W)):
  for j in range(len(S)):
    tmp = S[j]/W[i]
    tmp1 = S[j] + W[i]
    if tmp1 <= F and ans <= tmp <= E/100:
      ans = tmp
      ans1 = tmp1
      ans2 = S[j]
print(ans1, ans2)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]
array = []
ans = 0

for i in range(N):
  if A[i] not in array:
    array.append(A[i])
    if A.count(A[i]) % 2 == 1:
      ans += 1
print(ans)


Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
array = []
ans = 0
A.sort()
count = 0

for i in range(N):
  count += 1
  if i == N-1:
    if count%2 == 1:
      ans += 1
#    print(A[i], count, ans)
    
#  elif A[i] == A[i+1]:
#    print(A[i], count, ans)
    
  elif A[i] != A[i+1]:
    if count % 2 == 1:
      ans += 1
#    print(A[i], count, ans)
    count = 0

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]
array = []
ans = 0

for i in range(N):
  if A[i] not in array:
    array.append(A[i])
    if A.count(A[i]) % 2 == 1:
      ans += 1
  print(i, array, ans)


Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
array = []
ans = 0
A.sort()
count = 0

for i in range(N):
  count += 1
  if i == N-1:
    if count%2 == 1:
      ans += 1
#    print(A[i], count, ans)
    
#  elif A[i] == A[i+1]:
#    print(A[i], count, ans)
    
  elif A[i] != A[i+1]:
    if count % 2 == 1:
      ans += 1
#    print(A[i], count, ans)
    count = 0

print(ans)
Buggy python submission (verdict: Runtime Error):
import collections 
N = int(input())
A = [int(i) for i in input().split()]
A = collections.Counter(A)
A = sorted(A.items(), key=lambda x:x[0],reverse = True)
e = []

for k,v in A:
  if v >= 4:
    e.append([k]*2)
  elif v >= 2:
    e.append(k)
  if len(e) >= 2:
    break
if len(e) < 2:
  ans = 0
else:
  ans = e[0]*e[1]
print(ans)

Fixed submission:
import collections 
N = int(input())
A = [int(i) for i in input().split()]
A = collections.Counter(A)
A = sorted(A.items(), key=lambda x:x[0],reverse = True)
e = []

for k,v in A:
  if v >= 4:
    e.append(k)
    e.append(k)
  elif v >= 2:
    e.append(k)
  if len(e) >= 2:
    break
if len(e) < 2:
  ans = 0
else:
  ans = e[0]*e[1]
print(ans)