Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,x=map(int,raw_input().split())
a=map(int,raw_input().split())
i=0
num=0

while i<n-1:
        if a[i] + a[i+1] > x:
                a[i+1]=a[i+1]-1
                num=num+1
        else:
                i=i+1

print num

Fixed submission:
n,x=map(int,raw_input().split())
a=map(int,raw_input().split())
i=0
num=0

if a[0] > x:
        ans=a[0]-x
        a[0]=a[0]-ans
        num=num+ans
while i<n-1:
        if a[i] + a[i+1] > x:
                ans=a[i] + a[i+1] - x
                a[i+1]=a[i+1]-ans
                num=num+ans
        else:
                i=i+1

print num
Buggy python submission (verdict: Runtime Error):
a = [int(i) for i in raw_input().split()]
b = [int(i) for i in raw_input().split()]
n = len(a)
c = [(a[i]/100.0,b[i]/100.0,(a[i]+b[i])/100.0,a[i]*1.0/(a[i]+b[i]+1e-10)) for i in range(n)]
c.sort(key=lambda item: item[3], reverse=True)
u = [0] * n
res = 1
for i in range(n):
    du = min(res / (c[i][2]), 1)
    u[i] = du
    res -= du * c[i][2]
    if res <=0:
        break
ans = 0
for i in range(n):
    ans += c[i][0] * u[i]

print ans


Fixed submission:
a = [int(i) for i in raw_input().split()]
b = [int(i) for i in raw_input().split()]
c = [(a[i]/100.0,b[i]/100.0,(a[i]+b[i])/100.0,a[i]*1.0/(a[i]+b[i])) for i in range(len(a)) if a[i]+b[i]>0]
n = len(c)
c.sort(key=lambda item: item[3], reverse=True)
u = [0] * n
res = 1
for i in range(n):
    du = min(res / (c[i][2]), 1)
    u[i] = du
    res -= du * c[i][2]
    if res <=0:
        break
ans = 0
for i in range(n):
    ans += c[i][0] * u[i]

print ans

Buggy python submission (verdict: Runtime Error):
a = [int(i) for i in raw_input().split()]
b = [int(i) for i in raw_input().split()]
n = len(a)
c = [(a[i]/100.0,b[i]/100.0,(a[i]+b[i])/100.0,a[i]*1.0/(a[i]+b[i])) for i in range(n)]
c.sort(key=lambda item: item[3], reverse=True)
u = [0] * n
res = 1
for i in range(n):
    du = min(res / (c[i][2]), 1)
    u[i] = du
    res -= du * c[i][2]
    if res <=0:
        break
ans = 0
for i in range(n):
    ans += c[i][0] * u[i]

print ans


Fixed submission:
a = [int(i) for i in raw_input().split()]
b = [int(i) for i in raw_input().split()]
c = [(a[i]/100.0,b[i]/100.0,(a[i]+b[i])/100.0,a[i]*1.0/(a[i]+b[i])) for i in range(len(a)) if a[i]+b[i]>0]
n = len(c)
c.sort(key=lambda item: item[3], reverse=True)
u = [0] * n
res = 1
for i in range(n):
    du = min(res / (c[i][2]), 1)
    u[i] = du
    res -= du * c[i][2]
    if res <=0:
        break
ans = 0
for i in range(n):
    ans += c[i][0] * u[i]

print ans
Buggy python submission (verdict: Runtime Error):

c = t - a - b
d = t - a - g
f = t - d - e
i = t - g - h

print("{} {} {}".format(a,b,c))
print("{} {} {}".format(d,e,f))
print("{} {} {}".format(g,h,i))


Fixed submission:
# A B c
# d E f
# g h i

a = int(input())
b = int(input())
e = int(input())
g = a + b - e
h = a + e - g
t = b + e + h
c = t - a - b
d = t - a - g
f = t - d - e
i = t - g - h
print("{} {} {}".format(a,b,c))
print("{} {} {}".format(d,e,f))
print("{} {} {}".format(g,h,i))
Buggy python submission (verdict: Runtime Error):
H,W=map(int,input().split())
S=[input().split() for i in range(H)]
columns=["A","B","C","D","E","F","G","H","I","J"]
for h in range(H):
    for w in range(W):
        if S[h][w]=="snuke":
            print(columns[w]+str(h+1))

Fixed submission:
H,W=map(int,input().split())
S=[input().split() for i in range(H)]
columns="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for h in range(H):
    for w in range(W):
        if S[h][w]=="snuke":
            print(columns[w]+str(h+1))

Buggy python submission (verdict: Runtime Error):
H,W=map(int,input().split())
S=[input().split() for i in range(H)]
columns=["A","B","C","D","E","F","G","H"]
for h in range(H):
    for w in range(W):
        if S[h][w]=="snuke":
            print(columns[w]+str(h+1))

Fixed submission:
H,W=map(int,input().split())
S=[input().split() for i in range(H)]
columns="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for h in range(H):
    for w in range(W):
        if S[h][w]=="snuke":
            print(columns[w]+str(h+1))
Buggy python submission (verdict: Runtime Error):
from numpy import*;from scipy.sparse import*;(n,m),*p=[map(int,o.split())for o in open(0)];e,*f=array([(i,j+n-1,1)for i,q in enumerate(p)for j in list(q)[1:]]).T[:3];print("YNEOS"[1in csgraph.connected_components(csr_matrix(((f,e)),[n+m]*2))[1][:n]::2])

Fixed submission:
from numpy import*
from scipy.sparse import*
(n,m),*p=[map(int,o.split())for o in open(0)]
e=array([(i,j+n-1,1)for i,q in enumerate(p)for j in list(q)[1:]]).T
print("NO"if 1 in csgraph.connected_components(csr_matrix(((e[2],e[:2])),[n+m]*2))[1][:n]else"YES")
Buggy python submission (verdict: Runtime Error):
h,w = map(int, input().split())
s = [list(input().split()) for _ in range(h)]
al = list("ABCDEFGHIJ")
i = -1
for v in s:
  i+=1
  if "snuke" in v:
    print(al[s[i].index("snuke")]+str(i+1))
    exit()

Fixed submission:
h,w = map(int, input().split())
s = [list(input().split()) for _ in range(h)]
i = 0
65
for v in s:
  i+=1
  if "snuke" in v:
    print(chr(v.index("snuke")+65)+str(i))
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
n = round((N//2) ** 0.5)
a,b = n+2, n+3
if a*(a+1)//2 > abs(a*(a+1)//2 - N):
    number = abs(a*(a+1)//2 - N)
    n = a
elif b*(b+1)//2 >= abs(b*(b+1)//2 - N):
    number = abs(b*(b+1)//2 - N)
    n = b

for i in range(1, n+1):
    if i == number: continue
    print(i)

Fixed submission:
N = int(input())
cnt = 0
for i in range(1, N+1):
  if i * (1 + i) // 2 >= N:
    cnt = i
    break
for i in range(cnt, 0, -1):
  if i <= N:
    print(i)
    N -= i

Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
n = round((N//2) ** 0.5)
a,b = n+2, n+3
if a*(a+1)//2 > abs(a*(a+1)//2 - N):
    number = abs(a*(a+1)//2 - N)
    n = a
elif b*(b+1)//2 > abs(b*(b+1)//2 - N):
    number = abs(b*(b+1)//2 - N)
    n = b

for i in range(1, n+1):
    if i == number: continue
    print(i)

Fixed submission:
N = int(input())
cnt = 0
for i in range(1, N+1):
  if i * (1 + i) // 2 >= N:
    cnt = i
    break
for i in range(cnt, 0, -1):
  if i <= N:
    print(i)
    N -= i

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=0
l=[]
for i in　range(1,n+1):
 s+=i
 l.append(i)
 if s>=n:
  for j in l:
   if j!=s-n:
    print(j)
  break

Fixed submission:
n=int(input())
s=0
l=[]
for i in range(1,n+1):
 s+=i
 l.append(i)
 if s>=n:
  for j in l:
   if j!=s-n:
    print(j)
  break
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
a=[[i for i in input().split()] for j in range(h)]
p=[chr(i) for i in range(65,75)]
for r in range(h):
    for c in range(w):
        if a[r][c]=="snuke":
            print(p[c]+str(r+1))
            break

Fixed submission:
h,w=map(int,input().split())
a=[[i for i in input().split()] for j in range(h)]
p=[chr(i) for i in range(65,91)]
for r in range(h):
    for c in range(w):
        if a[r][c]=="snuke":
            print(p[c]+str(r+1))
            break

Buggy python submission (verdict: Runtime Error):
H, W = map(int, intput().split())
M = [input().split() for _ in range(H)]
for i, r in enumerate(M):
  for j, c in enumerate(r):
    if c == 'snuke':
      print("%s%d" %(chr(ord('A')+j), i))

Fixed submission:
H, W = map(int, input().split())
M = [input().split() for _ in range(H)]
for i, r in enumerate(M):
  for j, c in enumerate(r):
    if c == 'snuke':
      print("%s%d" %(chr(ord('A')+j), i+1))
Buggy python submission (verdict: Runtime Error):
H,W = map(int,input().split())
alp = 'ABCDEFGHIJ'
for i in range(H):
  for j,s in enumerate(input().split()):
    if s == 'snuke':
      print(alp[j]+str(i+1))
      exit()

Fixed submission:
H,W = map(int,input().split())
alp = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for i in range(H):
  for j,s in enumerate(input().split()):
    if s == 'snuke':
      print(alp[j]+str(i+1))
      exit()

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
ls = ["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
x = [list(input().split()) for i in range(a)]
for i in range(a):
  for j in range(b):
    if x[a][b] == "snuke":
      print(ls[a]+str(b+1))
      break

Fixed submission:
a,b=map(int,input().split())
ls = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
x = [list(input().split()) for i in range(a)]
for i in range(a):
  for j in range(b):
    if x[i][j] == "snuke":
      print(ls[j]+str(i+1))
      break
Buggy python submission (verdict: Runtime Error):
n = int(input())
for i in range(1,n):
  if i*(i+1)//2 > n:
    x = i
    y = i*(i+1)//2 - n
    break
for i in range(1,x+1):
  if i != y:
    print(i)

Fixed submission:
n = int(input())
for i in range(1,n+2):
  if i*(i+1)//2 > n:
    x = i
    y = i*(i+1)//2 - n
    break
for i in range(1,x+1):
  if i != y:
    print(i)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n,m = map(int, input().split())
a = list(map(int, input().split()))
c = [0]*100001
b = [a[i]%m for i in range(n)]
rem = [0]*m
for i in range(n):
    rem[b[i]] += 1
    c[a[i]] += 1
ans = 0
for i in range(m//2+1):
    if i == 0 or i*2 == m:
        ans += rem[i]//2
        rem[i] -= rem[i]//2*2
        continue
    less = min(rem[i],rem[m-i])
    ans += less
    rem[i] -= less
    rem[m-i] -= less
for j in range(n//m+1):
    for i in range(m):
        if rem[i] >= c[m*j+i]:
            ans += c[m*j+i]//2
            rem[i] -= c[m*j+i]//2
        else:
            ans += rem[i]//2
            rem[i] -= rem[i]//2
print(ans)

Fixed submission:
from collections import Counter
n,m = map(int, input().split())
a = list(map(int, input().split()))
amax = max(a)
c = [0]*(amax+1)
b = [a[i]%m for i in range(n)]
rem = [0]*m
for i in range(n):
    rem[b[i]] += 1
    c[a[i]] += 1
ans = 0
for i in range(m//2+1):
    if i == 0 or i*2 == m:
        ans += rem[i]//2
        rem[i] -= rem[i]//2*2
        continue
    less = min(rem[i],rem[m-i])
    ans += less
    rem[i] -= less
    rem[m-i] -= less
for j in range(amax//m+1):
    for i in range(m):
        if m*j+i<=amax:
            if rem[i] >= c[m*j+i]:
                ans += c[m*j+i]//2
                rem[i] -= c[m*j+i]//2*2
            else:
                ans += rem[i]//2
                rem[i] -= rem[i]//2*2
print(ans)
Buggy python submission (verdict: Runtime Error):
n,a = map(int,input().split())
if n == 1:
  print(1)
  exit()
l = -1
r = 10**12+1
#n <= x**(k-i)*(x-1)**iのk-iを返す
def border(x,k):
  if k >= 40:
    return (n-1).bit_length()
  else:
    L = 0
    R = k
    while L+1 < R:
      M = (L+R)//2
      if x**(k-M)*(x-1)**(M) < n:
        R = M
      else:
        L = M
    return k-L
def sec(k):
  if k >= 40:
    x = 2
  else:
    y = int(n**(1/k))+1
    if (y-1)**k < n <= y**k:
      x = y
    elif y**k < n <= (y+1)**k:
      x = y+1
    elif (y-2)**k < n <= (y-1)**k:
      x = y-1
  b = border(x,k)
  return (x+a)*k-(k-b)

while l+2 < r:
  ml = (l*2+r)//3
  mr = (l+r*2)//3
  if sec(ml) < sec(mr):
    r = mr
  else:
    l = ml
print(sec(l+1)-a)

Fixed submission:
n,a = map(int,input().split())
if n == 1:
  print(1)
  exit()
if n <= a:
  print(n)
  exit()
#n <= x**(k-i)*(x-1)**iのk-iを返す
def border(x,k):
  L = 0
  R = k
  while L+1 < R:
    M = (L+R)//2
    if x**(k-M)*(x-1)**(M) < n:
      R = M
    else:
      L = M
  return k-L
def sec(k):
  y = int(n**(1/k))+1
  if (y-1)**k < n <= y**k:
    x = y
  elif y**k < n <= (y+1)**k:
    x = y+1
  elif (y-2)**k < n <= (y-1)**k:
    x = y-1
  b = border(x,k)
  return (x+a)*k-(k-b)
ansls = []
for i in range(1,51):
  ansls.append(sec(i))
print(min(ansls)-a)
Buggy python submission (verdict: Runtime Error):
N, M = [int(i) for i in input().split()]
X = [0] * (10 ** 5)
# X = [0] * (10)
for i in map(int, input().split()):
    X[i] += 1
Y = [sum(X[i::M]) for i in range(M)]
ans = Y[0] // 2
Y[0] = 0
for i in range(1, M//2+M%2):
    j = M - i
    tmp = min(Y[i], Y[j])
    ans += tmp
    Y[i] -= tmp
    Y[j] -= tmp
for i, n in enumerate(X):
    j = i % M
    if Y[j] < 2 or n < 2:
        continue
    tmp = min(Y[j]-Y[j]%2, n-n%2)
    ans += tmp // 2
    Y[j] -= tmp
print(ans)    
        
    


Fixed submission:
from string import ascii_uppercase
H, W = [int(i) for i in input().split()]
S = [input().split() for _ in range(H)]
for h in range(H):
    for w in range(W):
        if S[h][w] == "snuke":
            print("{}{}".format(ascii_uppercase[w], h+1))

Buggy python submission (verdict: Runtime Error):
import bisect
N = int(input())
S = tuple(map(lambda x: (x**2+x)//2, range(5000)))
while N > 0:
    i = bisect.bisect_left(S, N)
    N -= i
    #print(i, N, S)
    print(i)


Fixed submission:
from string import ascii_uppercase
H, W = [int(i) for i in input().split()]
S = [input().split() for _ in range(H)]
for h in range(H):
    for w in range(W):
        if S[h][w] == "snuke":
            print("{}{}".format(ascii_uppercase[w], h+1))
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
S = tuple(map(lambda x: (x**2+x)//2, range(N)))
while N > 0:
    i = bisect.bisect_left(S, N)
    N -= i
    #print(i, N, S)
    print(i)


Fixed submission:
import bisect
N = int(input())
S = tuple(map(lambda x: (x**2+x)//2, range(int(N**(2/3))+100)))
while N > 0:
    i = bisect.bisect_left(S, N)
    N -= i
    #print(i, N, S)
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
S = tuple(map(lambda x: (x**2+x)//2, range(N)))
while N > 0:
    i = bisect.bisect_left(S, N)
    N -= i
    #print(i, N, S)
    print(i)


Fixed submission:
import bisect
N = int(input())
S = tuple(map(lambda x: (x**2+x)//2, range(int(N**(2/3))+100)))
while N > 0:
    i = bisect.bisect_left(S, N)
    N -= i
    #print(i, N, S)
    print(i)
Buggy python submission (verdict: Runtime Error):
MAX_X = 10 ** 5

def main():
    N, M = [int(i) for i in input().split()]
    X = [0] * (MAX_X + 1)
    for i in map(int, input().split()):
        X[i] += 1
    Y = [sum(X[i::M]) for i in range(min(M, N, MAX_X))]
    # Mの倍数
    ans = Y[0] // 2
    Y[0] = 0
    # M%2==0のM/2
    if M % 2 == 0:
        ans += Y[M//2] // 2
        Y[M//2] = 0    
    for i in range(1, M//2+1):
        j = M - i
        tmp = min(Y[i], Y[j])
        ans += tmp
        Y[i] -= tmp
        Y[j] -= tmp
    for i, n in enumerate(X):
        j = i % M
        if Y[j] < 2 or n < 2:
            continue
        tmp = min(Y[j]-Y[j]%2, n-n%2)
        ans += tmp // 2
        Y[j] -= tmp
    print(ans)

if __name__ == "__main__":
    main()
    



        
    


Fixed submission:
MAX_X = 10 ** 5 + 100

def main():
    N, M = [int(i) for i in input().split()]
    X = [0] * (MAX_X + 1)
    for i in map(int, input().split()):
        X[i] += 1
    Y = [sum(X[i::M]) for i in range(min(M, MAX_X))]
    # Mの倍数    
    ans = Y[0] // 2
    Y[0] = 0
    # M%2==0のM/2
    if M % 2 == 0:
        ans += Y[M//2] // 2
        Y[M//2] = 0    
    for i in range(1, M//2+1):
        j = M - i
        tmp = min(Y[i], Y[j])
        ans += tmp
        Y[i] -= tmp
        Y[j] -= tmp
    try:
        for i, n in enumerate(X):
            j = i % M
            if Y[j] < 2 or n < 2:
                continue
            tmp = min(Y[j]-Y[j]%2, n-n%2)
            ans += tmp // 2
            Y[j] -= tmp
    except IndexError:
        print(-1)
    print(ans)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

# from numba import njit
import sys
sys.setrecursionlimit(10**9)
# input = stdin.readline

INF = 10**9

# @njit
def solve(n):
  def dp(i,x,acc=[]):
    # i番目までで和をちょうどxにできるか
    if i == 0:
      if x == 0:
        return acc
      else:
        return [INF]
    else:
      return min(dp(i-1,x-i,[i]+acc),dp(i-1,x,acc),key=lambda x: x[-1])
  

  return dp(n,n)



def main():
  N = int(input())
  # N,M = map(int,input().split())
  # a = list(map(int,input().split()))
  print(*solve(N),sep="\n")
  return

if __name__ == '__main__':
  main()


Fixed submission:
#!/usr/bin/env python3

# from numba import njit
import sys
sys.setrecursionlimit(10**9)
# input = stdin.readline

INF = 10**9

# @njit
def solve(n):
  s = 0
  l = []
  for i in range(n):
    s += i+1
    l += [i+1]
    if s > n:
      l.remove(s-n)
      return l
    elif s == n:
      return l

  return -1



def main():
  N = int(input())
  # N,M = map(int,input().split())
  # a = list(map(int,input().split()))
  print(*solve(N),sep="\n")
  return

if __name__ == '__main__':
  main()

Buggy python submission (verdict: Runtime Error):
def f(x):
    return x * (x + 1) // 2


if __name__ == "__main__":
    N = int(input())
    sum_ = [(i, f(i)) for i in range(0, N + 1) if f(i) >= N]

    l = list(range(1, sum_[0][0] + 1))
    remove = sum_[0][1] - N
    l.remove(remove)
    print(*l, sep="\n")



Fixed submission:
def f(x):
    return x * (x + 1) // 2


if __name__ == "__main__":
    N = int(input())
    for i in range(0, N + 1):
        if f(i) >= N:
            x, sum_ = i, f(i)
            break

    r = sum_ - N
    for i in range(1, x + 1):
        if i != r:
            print(i)

Buggy python submission (verdict: Runtime Error):
import math
N=int(input())
for i in range(int(math.sqrt(N)) , int(math.sqrt(2*N))+1):
    if (i*(i+1))//2 >= N:
        ansmax=i
        dif=(i*(i+1))//2 - N

for j in range(1,ansmax+1):
    if j!=dif:
        print(j)

Fixed submission:
import math
N=int(input())
for i in range(int(math.sqrt(N)) , int(math.sqrt(2*N+1))+100):
    if (i*(i+1))//2 >= N:
        ansmax=i
        dif=(i*(i+1))//2 - N
        break

for j in range(1,ansmax+1):
    if j!=dif:
        print(j)
Buggy python submission (verdict: Runtime Error):
import sys
readline = sys.stdin.readline


def check(x):
    if x - 50*A >= 100:
        return N+1
    right = x//A
    left = 1
    while abs(right - left) > 2:
        med1 = (left*2+right)//3
        med2 = (left+right*2)//3
        if calc(med1, x-(med1-1)*A) < calc(med2, x-(med2-1)*A):
            left = med1
        else:
            right = med2
    
    res = 0
    for l in range(left, right+1):
        cl = calc(l, x-(l-1)*A)
        if res < cl:
            res = cl
    return res
    
    
def calc(k, c):
    return pow(c//k+1, c%k)*pow(c//k, k-c%k)

N, A = map(int, readline().split())

ok = N
ng = 0
while abs(ok-ng)>1:
    med = (ok+ng)//2
    if check(med) >= N:
        ok = med
    else:
        ng = med
print(ok)
    
    

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

def check(x):
    if x - 50*A >= 100:
        return N+1
    right = (x+A)//(1+A)
    left = 1
    res = 0
    for l in range(left, right+1):
        cl = calc(l, x-(l-1)*A)
        if res < cl:
            res = cl
    return res
    
    
def calc(k, c):
    return pow(c//k+1, c%k)*pow(c//k, k-c%k)

N, A = map(int, readline().split())


ok = N
ng = 0
while abs(ok-ng)>1:
    med = (ok+ng)//2
    if check(med) >= N:
        ok = med
    else:
        ng = med
    
print(ok)
Buggy python submission (verdict: Runtime Error):
[H, W] = raw_input().split(' ')
for i in range(H):
    for index, string in enumerate(raw_input.split(' ')):
        if string == 'snuke':
            print i, index

Fixed submission:
[H, W] = raw_input().split(' ')
for i in range(int(H)):
    for index, string in enumerate(raw_input().split(' ')):
        if string == 'snuke':
            print '%s%s' % (str(unichr(index + 65)), (i+1))
            exit()
Buggy python submission (verdict: Runtime Error):
import sys

f = open('input.txt')
# f = input()

N = int(f.readline())


out = []
sum = 0
for i in range(0, N+1):
    sum = sum + i
    out.append(i)
    if sum > N:
        r = sum - N
        out.remove(r)
        break
    
out.remove(0)

for n in out:
    print(n)

# print(' '.join(map(str, out)))

Fixed submission:
import sys

# f = open('input.txt')
f = input()

N = int(f)


out = []
sum = 0
for i in range(0, N+1):
    sum = sum + i
    out.append(i)
    if sum > N:
        r = sum - N
        out.remove(r)
        break
    
out.remove(0)

for n in out:
    print(n)

# print(' '.join(map(str, out)))
Buggy python submission (verdict: Runtime Error):
N = int(raw_input())
a = [int(x) for x in raw_input().split(' ')]

sorteda = sorted(a)

maxlen = sorteda[-1]
numpathsoflen = {}
if(sorteda[0] < (maxlen+1)/2):
    print 'Impossible'
elif(maxlen % 2 == 0 
     and sorteda[0] == maxlen/2 
     and sorteda[0] == sorteda[1]):
    print 'Impossible'
else:
    numnodes = maxlen + 1
    for i in range(N):
        if a[i] in numpathsoflen.keys():
            if numpathsoflen[a[i]] >= 2:
                numnodes += 1
            numpathsoflen[a[i]] += 1            
        else:
            numpathsoflen[a[i]] = 1
    if(numnodes != N):
        print 'Impossible'
    else:
        out= 'Possible'
        starti = (maxlen+1)/2 
        if maxlen % 2 == 0:
            starti += 1
        for i in range(starti, maxlen+1):
            if((not i in numpathsoflen.keys()) or numpathsoflen[i] < 2):
                out = 'Impossible'                
        print out

Fixed submission:
instring = raw_input()

finallen = len(instring)
num_open = 0
for char in instring:
    if (char == 'S'):
        num_open += 1
    elif(num_open > 0):
        num_open -= 1
        finallen -= 2
print finallen
Buggy python submission (verdict: Runtime Error):
N = int(raw_input())
a = [int(x) for x in raw_input().split(' ')]

sorteda = sorted(a)

maxlen = sorteda[-1]
numpathsoflen = {}
if(sorteda[0] < (maxlen+1)/2):
    print 'Impossible'
elif(maxlen % 2 == 0 
     and sorteda[0] == maxlen/2 
     and sorteda[0] == sorteda[1]):
    print 'Impossible'
else:
    numnodes = maxlen + 1
    for i in range(N):
        if a[i] in numpathsoflen.keys():
            if numpathsoflen[a[i]] >= 2:
                numnodes += 1
            numpathsoflen[a[i]] += 1            
        else:
            numpathsoflen[a[i]] = 1
    if(numnodes != N):
        print 'Impossible'
    else:
        out= 'Possible'
        starti = (maxlen+1)/2) 
        if maxlen % 2 == 0:
            starti++
        for i in range(starti, maxlen)
            if(not i in numpathsoflen.keys() or numpathsoflen[i] < 2):
                out = 'Impossible'                
        print out

Fixed submission:
N = int(raw_input())
a = [int(x) for x in raw_input().split(' ')]

sorteda = sorted(a)

maxlen = sorteda[-1]
numpathsoflen = [0 for x in range(maxlen+1)]
if(sorteda[0] < (maxlen+1)/2):
    print 'Impossible'
else:
    for x in sorteda:
        numpathsoflen[x] += 1            
    valid = True
    starti = (maxlen+1)/2
    if(maxlen % 2 == 0):
        if(numpathsoflen[starti] != 1):
            valid = False
    else:
        if(numpathsoflen[starti] != 2):
            valid = False
    starti += 1        
    for x in range(starti, maxlen+1):
        if(numpathsoflen[x] < 2):
            valid = False
    if(valid):
        print 'Possible'
    else:
        print 'Impossible'