Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n=int(input())
model=[]
for i in range(n):
  model.append(i+1)
p=list(map(int,input().split()))
cnt=0
for j in p:
  if j != model[j]:
    cnt+=1
if cnt=<2:
  print("YES")
else:
  print("NO")

Fixed submission:
n=int(input())
model=[]
for i in range(n):
  model.append(i+1)
#print(model)
p=list(map(int,input().split()))
cnt=0
for j in range(n):
  if p[j] != model[j]:
    cnt+=1
if cnt<=2:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(input()) for i in range(n)]
for _ in range(n):
  b=a[0:_]+a[_+1:n]
  print(max(b))


Fixed submission:
n=int(input())
a=[int(input()) for i in range(n)]
b=sorted(a)
f=b[-1]
s=b[-2]
for ans in a:
  if ans < f:
    print(f)
  else:
    print(s)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for i in range(n)]
for _ in range(n):
  #b=a[0:_]+a[_+1:n]
  #print(max(b))
  print(max(max(a[0:_]),max(a[_+1:n])))


Fixed submission:
n=int(input())
a=[int(input()) for i in range(n)]
b=sorted(a)
f=b[-1]
s=b[-2]
for ans in a:
  if ans < f:
    print(f)
  else:
    print(s)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for i in range(n)]
for _ in range(n):
  #b=a[0:_]+a[_+1:n]
  #print(max(b))
  print(max(a[0:_]),max(a[_+1:n]))


Fixed submission:
n=int(input())
a=[int(input()) for i in range(n)]
b=sorted(a)
f=b[-1]
s=b[-2]
for ans in a:
  if ans < f:
    print(f)
  else:
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(input()) for i in range(n)]
for _ in range(n):
  b=a[0:_]+a[_+1:n]
  print(max(b))


Fixed submission:
n=int(input())
a=[int(input()) for i in range(n)]
b=sorted(a)
f=b[-1]
s=b[-2]
for ans in a:
  if ans < f:
    print(f)
  else:
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[0]*n
for _ in range(n):
  x=int(input())
  a[_]=x

for _ in range(n):
  b=a[0:_]+a[_+1:n]
  print(max(b))

Fixed submission:
n=int(input())
a=[int(input()) for i in range(n)]
b=sorted(a)
f=b[-1]
s=b[-2]
for ans in a:
  if ans < f:
    print(f)
  else:
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[]
for _ in range(n):
  x=int(input())
  a.append(x)

for _ in range(n):
  b=a[0:_]+a[_+1:n]
  print(max(b))

Fixed submission:
n=int(input())
a=[int(input()) for i in range(n)]
b=sorted(a)
f=b[-1]
s=b[-2]
for ans in a:
  if ans < f:
    print(f)
  else:
    print(s)
Buggy python submission (verdict: Time Limit Exceeded):
l,r=map(int,input().split())
ans=10**15
for i in range(l,min(r,l+5000)):
  for j in range(i+1,min(r+1,l+5000+1)):
    ans=min(ans,(i*j)%2019)
    
print(ans)
    

Fixed submission:
MOD=2019
l,r=map(int,input().split()) #l<=i<i+1<=j<=r
res=[]

if r - l > 2019:
  print(0)
  
else:
  l=l%MOD
  r=r%MOD
  l,r=min(l,r),max(l,r)

  for i in range(l,r):
    for j in range(i+1,r+1):
      res += [(i*j)%MOD]

  print(min(res))
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!

def MI():return map(int,input().split())
def LI():return list(MI())

from collections import deque
n,m=MI()
G=[[] for i in range(n)]
# print(G)
for i in range(m):
    u,v=MI()
    G[u-1].append(v-1)

    
s,t=MI()
s=s-1
t=t-1


dq=deque([])

visited=[False]*n
dq.append(s)
depth=0
for i in range(1,10**6+1):
    par_list=[]
    while dq:
        try:
            p=dq.popleft()
            if visited[p]==True:
                continue
            else:
                visited[p]=True
                par_list.append(p)
        except:
            break
    depth+=1
    #print(depth)
    #print(par_list)
    if len(par_list)==0:
      break
    for par in par_list:
        for c1 in G[par]:
            for c2 in G[c1]:
                for c3 in G[c2]:
                    if c3==t:
                        #print(par,c1,c2,c3,"yay")
                        print(depth)
                        exit()
                    if visited[c3]==False:
                        dq.append(c3)
                        visited[c3]==True
    
                    #print(par,c1,c2,c3,end=" ")
                    #print()
    #print(i,len(dq),dq)
    
print(-1)


Fixed submission:
from collections import deque
import sys
input = sys.stdin.readline
def MI():return map(int,input().split())
def main():
  n,m=MI()
  G=[[] for _ in range(n)]
  for _ in range(m):
    u,v=MI()
    u-=1
    v-=1
    G[u].append(v)
  s,t=MI()
  s-=1
  t-=1
  
  fi=[True]*n
  se=[True]*n
  th=[True]*n
  th[s]=False
  
  dq=deque([])
  dq.append(s)
  depth=0
  
  while dq:
    depth+=1
    tank1=[]
    tank2=[]
    tank3=[]
    
    for p in dq:
      for c in G[p]:
        if fi[c]:
          fi[c]=False
          tank2.append(c)
    for p in tank2:
      for c in G[p]:
        if se[c]:
          se[c]=False
          tank3.append(c)
    for p in tank3:
      for c in G[p]:
        if th[c]:
          th[c]=False
          tank1.append(c)
        if c==t:
          print(depth)
          exit()
    dq=deque(tank1)
  print(-1)  
if __name__=='__main__':
  main()
Buggy python submission (verdict: Runtime Error):
n,x=map(int,input().split())
l=list(map(int,input().split()))+[0,0,0]
d=0
i=1
cnt=0
while d<=x:
  cnt+=1
  d+=l[i-1]
  i+=1
  
print(cnt)

Fixed submission:
n,x=map(int,input().split())
l=list(map(int,input().split()))+[0]
#i=1
d=0
cnt=0
for i in range(n+1):
  if d<=x:
    cnt+=1
    d+=l[i]

  
print(cnt)

Buggy python submission (verdict: Runtime Error):
n,x=map(int,input().split())
l=list(map(int,input().split()))
d=0
i=1
cnt=0
while d<=x:
  cnt+=1
  d+=l[i-1]
  i+=1
  
print(cnt)

Fixed submission:
n,x=map(int,input().split())
l=list(map(int,input().split()))+[0]
#i=1
d=0
cnt=0
for i in range(n+1):
  if d<=x:
    cnt+=1
    d+=l[i]

  
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N=map(int,input().split())
cnt=0
for r in range(0,N//R+1):
    for g in range(0,(N-r*R)//G+1):
        bunshi=N-r*R-g*G
        q,m=divmod(bunshi,B)
        # if q<0:continue
        if m==0:cnt+=1            
print(cnt)

Fixed submission:
def main():
  r,g,b,n=map(int,input().split())
  cnt=0
  for i in range(n//r+1):
    for j in range((n-i*r)//g+1):
      tmp=r*i+g*j
      q,mod=divmod(n-tmp,b)
      if (q>=0 and mod==0):
        cnt+=1
  print(cnt)
  
main()

Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N=map(int,input().split())
cnt=0
for r in range(0,N+1):#N//R+1):
    for g in range(0,N+1):#(N-r*R)//G+1):
        bunshi=N-r*R-g*G
        q,m=divmod(bunshi,B)
        if q<0:continue
        if m==0:cnt+=1
            
print(cnt)

Fixed submission:
def main():
  r,g,b,n=map(int,input().split())
  cnt=0
  for i in range(n//r+1):
    for j in range((n-i*r)//g+1):
      tmp=r*i+g*j
      q,mod=divmod(n-tmp,b)
      if (q>=0 and mod==0):
        cnt+=1
  print(cnt)
  
main()
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()

ans=float("inf")
for i in range(n+1):
    left=s[0:i]
    right=s[i:n]
    tmp=(left.count("#")+right.count("."))
    # print(left,right,tmp)
    ans=min(ans,tmp)
    
print(ans)

Fixed submission:
n=int(input())
s=input()
w_cnt=s.count(".")

ans=[w_cnt]
b=0
w=w_cnt

for i in range(n):
    if s[i]=="#":
        b+=1
    else:
        w-=1
    ans.append(b+w)

print(min(ans))
Buggy python submission (verdict: Time Limit Exceeded):
S=input()
l=len(S)
num=int(S)
# print(l,num,S)
count=0
for _ in reversed(range(l)):
    # print(_,(_%2==1)*1,num//(10**_))
    if num//(10**_)!=(_%2==1)*1:
        count+=1
    num=num%(10**_)
    # print(count)

print(min(count,l-count))
    

Fixed submission:
s=input()
l=len(s)

suuti=[]
for _ in s:
    suuti.append(int(_))

rei=[]
for _ in range(l):
    rei.append(_%2)

c=0
for _ in range(l):
    if rei[_]==suuti[_]:
        c+=1

print(min(c,l-c))
Buggy python submission (verdict: Runtime Error):
a,_,_,_,e,k=[int(input()) for i in range(6)]
print(":(" if e-a>ks else "Yay!")


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

m=e-a
if m>k:
  print(":(")
else:
  print("Yay!")

Buggy python submission (verdict: Runtime Error):
v=map(int,open(0).read().split())
if v[5]>=v[4]-v[0]:
  print("Yay")
else:
  print(":(")

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

m=e-a
if m>k:
  print(":(")
else:
  print("Yay!")
Buggy python submission (verdict: Runtime Error):
s=input()+"O"
tmp=""
ans=[]
for i in s:
  if i in ["A","T","G","C"]:
    tmp=tmp+i
  else:
    ans.append(tmp)
    tmp=""
res=0
for i in ans:
  if len(i)>len(res):
    res=len(i)
print(res)


Fixed submission:
s=input()
n=len(s)
ans=0
for i in range(n):
  for j in range(i,n):
    if all(["ACGT".count(c) == 1 for c in s[i:j+1]]):
      ans=max(ans,j+1-i)
print(ans)

Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)
ans=0
for i in range(n):
  for j in range(i,n):
    if all(["ACGT",count(c) == 1 for c in s[i:j+1]]):
      ans=max(ans,j+1-i)
print(ans)

Fixed submission:
s=input()
n=len(s)
ans=0
for i in range(n):
  for j in range(i,n):
    if all(["ACGT".count(c) == 1 for c in s[i:j+1]]):
      ans=max(ans,j+1-i)
print(ans)
Buggy python submission (verdict: Runtime Error):
H,W=map(int,input())
h,w=map(int,input())
print((H-h)*(W-w))

Fixed submission:
H,W=map(int,input().split())
h,w=map(int,input().split())
print((H-h)*(W-w))
Buggy python submission (verdict: Runtime Error):
rate=380000.0 #yen/btc

n=int(input())
otoshidama=0
for i in range(n):
  x,u=map(input().split())
  if u == "JPY":
    otoshidama+=float(x)
  else:
    otoshidama+=float(x)*rate
print(otoshidama)

Fixed submission:
rate=380000.0 #yen/btc

n=int(input())
otoshidama=0
for i in range(n):
  x,u=map(str,input().split())
  if u == "JPY":
    otoshidama+=float(x)
  else:
    otoshidama+=float(x)*rate
print(otoshidama)
Buggy python submission (verdict: Runtime Error):
def main():
  n,k=map(int,input().split())
  h=list(map(int,input().split()))+[0]*(k+10)
  dp=[(10**5) for i in range(n+k+10)]
  dp[0]=0
  for i in range(n-1):
    for j in range(k):
      dp[i+j+1]=min(dp[i]+abs(h[i]-h[i+j+1]),dp[i+j+1])
  print(dp[n-1])
main()


Fixed submission:
n=int(input())
h=list(map(int,input().split()))
inf=float("inf")
dp=[(inf) for i in range(n)]
dp[0]=0

for i in range(1,n):
    if i==1:
        dp[i]=dp[i-1]+abs(h[i]-h[i-1])
    else:
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])

Buggy python submission (verdict: Runtime Error):
int(input())
h=list(map(int,input().split()))
inf=float("inf")
dp=[(inf) for i in range(n)]
dp[0]=0

for i in range(1,n):
    if i==1:
        dp[i]=dp[i-1]+abs(h[i]-h[i-1])
    else:
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
inf=float("inf")
dp=[(inf) for i in range(n)]
dp[0]=0

for i in range(1,n):
    if i==1:
        dp[i]=dp[i-1]+abs(h[i]-h[i-1])
    else:
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])

Buggy python submission (verdict: Runtime Error):
int(input())
h=list(map(int,input().split()))
inf=float("inf")
dp=[(inf) for i in range(n)]
dp[0]=0

for i in range(1,n):
    if i==1:
        dp[i]=dp[i-1]+abs(h[i]-h[i-1])
    else:
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
inf=float("inf")
dp=[(inf) for i in range(n)]
dp[0]=0

for i in range(1,n):
    if i==1:
        dp[i]=dp[i-1]+abs(h[i]-h[i-1])
    else:
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())

if a+b+1=>c:
    ans=b+c
else:
    ans=a+b+1+b
    
print(ans)

Fixed submission:
a,b,c=map(int,input().split())

if a+b+1>=c:
    ans=b+c
else:
    ans=a+b+1+b
    
print(ans)
Buggy python submission (verdict: Runtime Error):
    print("NO")

Fixed submission:
x=int(input())
iwai=[7,5,3]

if x in iwai:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
com=int(input())
if com==1:
  print("Hello World")
else:
  a,b=map(int,input().split())
  print(a+b)

Fixed submission:
n=int(input())

if n == 1:
  print("Hello World")
else:
  a=int(input())
  b=int(input())
  print(a+b)
Buggy python submission (verdict: Runtime Error):
n,T=map(int,input().split())
clist,tlist=[],[]
for i in range(n):
  c,t=map(int,input().split())
  clist.append(c)
  tlist.append(t)

ans=10100
flag=False
for d,e in zip(c,t):
  if e<=T:
    ans=min(ans,d)
    flag=True
if flag == False:
  print("TLE")
else:
  print(ans)

Fixed submission:
n,T=map(int,input().split())
clist,tlist=[],[]
for i in range(n):
  c,t=map(int,input().split())
  clist.append(c)
  tlist.append(t)

ans=10100
flag=False
for d,e in zip(clist,tlist):
  if e<=T:
    ans=min(ans,d)
    flag=True
if flag == False:
  print("TLE")
else:
  print(ans)

Buggy python submission (verdict: Runtime Error):
n,T=map(int,input().split())
clist,tlist=[],[]
for i in range(n):
  c,t=map(input().split())
  clist.append(c)
  tlist.append(t)

ans=10100
flag=False
for d,e in zip(c,t):
  if e<=T:
    ans=min(ans,d)
    flag=True
if flag == False:
  print("TLE")
else:
  print(ans)

Fixed submission:
n,T=map(int,input().split())
clist,tlist=[],[]
for i in range(n):
  c,t=map(int,input().split())
  clist.append(c)
  tlist.append(t)

ans=10100
flag=False
for d,e in zip(clist,tlist):
  if e<=T:
    ans=min(ans,d)
    flag=True
if flag == False:
  print("TLE")
else:
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
for i in range(n,m+1):
  if m%i==0:
    print(m//i)
    exit()
print(1)

Fixed submission:
n,m=map(int,input().split())
yakusuu=[]
for i in range(1,int(m**0.5)+1):
  if m%i==0:
    yakusuu.append(m//i)
    if m//i==i:continue
    yakusuu.append(i)
ans=0
for y in yakusuu:
  if y<n:continue
  if m%y==0:
    ans=max(ans,m//y)
print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
k=input();k=int(k)
l=min(len(s),k)
for i in range(l+1):
  if s[i] == "1":
    tmp=1
  else:
    tmp=int(s[i])
    break
print(tmp)
  

Fixed submission:
s=input()
k=int(input())

for i in s:
  if i == "1":
    k-=1
  else:
    print(i)
    exit()
  if k == 0:
    print(i)
    exit()

Buggy python submission (verdict: Runtime Error):
s=input()
k=input();k=int(k)
l=min(len(s),k)
for i in range(l+1):
  if s[i] == "1":
    pass
  else:
    tmp=s[i]
    break
print(tmp)
  

Fixed submission:
s=input()
k=int(input())

for i in s:
  if i == "1":
    k-=1
  else:
    print(i)
    exit()
  if k == 0:
    print(i)
    exit()
Buggy python submission (verdict: Runtime Error):
n,*a=map(int,open(0).read().split())
b=[q-i for i,q in enumerate(a,1)]
b.sort()

c=b[(n+1)//2]+b[::-1][(n+1)//2]
c//=2

ans=float("inf")
for i in range(-10+c,11+c):
  tmp=sum(map(abs,[q-i for q in b]))
  ans=min(ans,tmp)
print(ans)

Fixed submission:
import statistics
n,*a=map(int,open(0).read().split())
b=[q-i for i,q in enumerate(a,1)]
c=statistics.median(b)
ans=sum(map(abs,[p-c for p in b]))
print(int(ans))
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
print(max(a+b,a-b,a*b))

Fixed submission:
a,b=map(int,input().split())
c=a+b
d=a-b
e=a*b
ans=max(c,d,e)
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
AB=abs(a-b)
BC=abs(b-c)
AC=abs(a-c)

if AC=<d or (AC>d and AB<d and BC<d):
  print("Yes")
else:
  print("No")

Fixed submission:
a,b,c,d=map(int,input().split())
AB=abs(a-b)
BC=abs(b-c)
AC=abs(a-c)

if AC<=d or (AC>d and AB<=d and BC<=d):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
lll=[list("."*(w+2))]
G=[list("."+input()+".") for _ in range(h)]
G=lll+G+lll
print(G)
for i in range(1,w+1):
  for j in range(1,h+1):
    if G[i][j]=="#" and G[i-1][j]==G[i+1][j]==G[i][j-1]==G[i][j+1]==".":
      print("No")
      exit()
print("Yes")  


Fixed submission:
h,w=map(int,input().split())
lll=[list("."*(w+2))]
G=[list("."+input()+".") for _ in range(h)]
G=lll+G+lll
#print(G)
for i in range(1,h+1):
  for j in range(1,w+1):
    if G[i][j]=="#" and G[i-1][j]==G[i+1][j]==G[i][j-1]==G[i][j+1]==".":
      print("No")
      exit()
print("Yes")

Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
lll=["."*(w+2)]
G=[list("."+input()+".") for _ in range(h)]
G=lll+G+lll
for i in range(1,w+1):
  for j in range(1,h+1):
    if G[i][j]=="#" and G[i-1][j]==G[i+1][j]==G[i][j-1]==G[i][j+1]==".":
      print("No")
      exit()
print("Yes")  

Fixed submission:
h,w=map(int,input().split())
lll=[list("."*(w+2))]
G=[list("."+input()+".") for _ in range(h)]
G=lll+G+lll
#print(G)
for i in range(1,h+1):
  for j in range(1,w+1):
    if G[i][j]=="#" and G[i-1][j]==G[i+1][j]==G[i][j-1]==G[i][j+1]==".":
      print("No")
      exit()
print("Yes")
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=sorted(a)
p,q=b[n//2-1],b[n//2+1]
for i in a:print(p if i>=q else q)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=sorted(a)
p,q=b[n//2-1:n//2+1]
for i in a:print(p if i>=q else q)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
p,q=sorted(a)[n//2-1:n//2+1]
for i in a:print(p if a>=q else q)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=sorted(a)
p,q=b[n//2-1:n//2+1]
for i in a:print(p if i>=q else q)
Buggy python submission (verdict: Runtime Error):
m=0
a=0
r=0
c=0
h=0
n=int(input())
for i in range(n):
  s=input()
  if s[0]=="M":m+=1
  elif s[0]=="A":a+=1
  elif s[0]=="R":r+=1
  elif s[0]=="C":c+=1
  elif s[0]=="H":h+=1
  else:pass

li=[m,a,r,c,h]
ans=0
for ai in range(n):
  for bi in range(n):
    for ci in range(n):
      if ci>bi>ai:
        ans+=li[ai]*li[bi]*li[ci]
print(ans)

Fixed submission:
m=0
a=0
r=0
c=0
h=0
n=int(input())
for i in range(n):
  s=input()
  if s[0]=="M":m+=1
  elif s[0]=="A":a+=1
  elif s[0]=="R":r+=1
  elif s[0]=="C":c+=1
  elif s[0]=="H":h+=1
  else:pass

li=[m,a,r,c,h]
ans=0
for ai in range(5):
  for bi in range(5):
    for ci in range(5):
      if ci>bi>ai:
        ans+=li[ai]*li[bi]*li[ci]
print(ans)
Buggy python submission (verdict: Runtime Error):
n,a,t=map(int,input().split())
print(min(a*n,b))

Fixed submission:
n,a,b=map(int,input().split())
print(min(a*n,b))

Buggy python submission (verdict: Runtime Error):
n,a,t=map(int,input().split())
print(min(a*t,b))

Fixed submission:
n,a,b=map(int,input().split())
print(min(a*n,b))
Buggy python submission (verdict: Time Limit Exceeded):


n=int(input())

a=sorted(list(map(int,input().split())),reverse=True)

s=[]
t=[]
for i in a:
    if i not in s:
        s.append(i)
    else:
        t.append(i)
        s=[]
    if len(t)==2:
        break


try:
    print(t[0]*t[1])
except:
    print(0)

Fixed submission:
n=int(input())

a=sorted(list(map(int,input().split())),reverse=True)

stack=-1
t=[]
for i in a:
    if stack==i:
        t.append(i)
        stack=-1
    else:
        stack=i
    
    if len(t)>=2:
        break
try:
    print(t[0]*t[1])
except:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
ab=[]
for i in range(m):
  a,b=map(int,input().split())
  ab.append((a,b))
#print(ab)
     
mid=[]
for (i,j) in ab:
  if i==1:
    mid.append(j)

for (i,j) in ab:
  if i in mid and j==n:
    print("POSSIBLE");exit()
    
print("IMPOSSIBLE")

    

Fixed submission:
n,m=map(int,input().split())
c=[]
d=[]
for i in range(m):
  a,b=map(int,input().split())
  if a==1:
    c.append(b)
  if b==n:
    d.append(a)
#O(m)
if len(set(c)&set(d))!=0:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
ab=[]
for i in range(m):
  a,b=map(int,input().split())
  ab.append((a,b))
#print(ab)
     
mid=[]
for (i,j) in ab:
  if i==1:
    mid.append(j)

for (i,j) in ab:
  if i in mi and j==n:
    print("POSSIBLE");exit()
    
print("IMPOSSIBLE")

    

Fixed submission:
n,m=map(int,input().split())
c=[]
d=[]
for i in range(m):
  a,b=map(int,input().split())
  if a==1:
    c.append(b)
  if b==n:
    d.append(a)
#O(m)
if len(set(c)&set(d))!=0:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")
Buggy python submission (verdict: Time Limit Exceeded):
n,k,*a=map(int,open(0).read().split())

from fractions import gcd


G=a[0]
for i in a:
    G=gcd(G,i)
    
A=max(a)
if k>A:
    print("IMPOSSIBLE")
    exit()
    
while A>0:
    if k==A:
        print("POSSIBLE")
        exit()
    A-=G
print("IMPOSSIBLE")

Fixed submission:
n,k,*a=map(int,open(0).read().split())

from fractions import gcd


G=a[0]
for i in a:
    G=gcd(G,i)
    
A=max(a)
if k>A:
    print("IMPOSSIBLE")
    exit()
    
while A>0:
    if k==A:
        print("POSSIBLE")
        exit()
    A-=G
print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
n,k,*a=map(int,open(0).read().split())

from fractions import gcd


G=a[0]
for i in a:
    G=gcd(G,i)
    
A=max(a)

while A>0:
    if k==A:
        print("POSSIBLE")
        exit()
    A-=G
print("IMPOSSIBLE")

Fixed submission:
n,k,*a=map(int,open(0).read().split())

from fractions import gcd


G=a[0]
for i in a:
    G=gcd(G,i)
    
A=max(a)
if k>A:
    print("IMPOSSIBLE")
    exit()
    
while A>0:
    if k==A:
        print("POSSIBLE")
        exit()
    A-=G
print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
li=[0]*8
o=0
n,*a=map(int,open(0).read().split())
for i in a:
  if i>=3200:
    o+=1  
  else:
    li[i//400]=1

#全員3200以上==(sum(li)==0)> 1,min(o,8)
#全員3200未満==(o==0)> sum(li),min(sum(li)+o,8)
#それ以外>sum(li)
if sum(li)==0:
  print(1,min(o,8))
else:
  print(sum(li),min(sum(li)+o,8)

Fixed submission:
li=[0]*8
o=0
n,*a=map(int,open(0).read().split())
for i in a:
  if i>=3200:
    o+=1  
  else:
    li[i//400]=1

#全員3200以上==(sum(li)==0)> 1,min(o,8)
#全員3200未満==(o==0)> sum(li),min(sum(li)+o,8)
#それ以外>sum(li)
if sum(li)==0:
  print(1,min(o,8))
else:
  print(sum(li),(sum(li)+o))

Buggy python submission (verdict: Runtime Error):
n,*a=map(int,open(0).read().split())
""" 
1 399：灰色 
400 799：茶色
800 1199：緑色
1200 1599：水色 
1600 1999：青色 
2000 2399：黄色 
2400 2799：橙色
2800 3199：赤色
"""
if n=1:
  print(1,1)
  exit()

li=[False]*8
over3200=0
for i in a:
  if i>=3200:
    over3200+=1
  else:
    li[(i//400)]=True
    
k=sum(li)
print(k,k+over3200)
    

Fixed submission:
li=[0]*8
o=0
n,*a=map(int,open(0).read().split())
for i in a:
  if i>=3200:
    o+=1  
  else:
    li[i//400]=1

#全員3200以上==(sum(li)==0)> 1,min(o,8)
#全員3200未満==(o==0)> sum(li),min(sum(li)+o,8)
#それ以外>sum(li)
if sum(li)==0:
  print(1,min(o,8))
else:
  print(sum(li),(sum(li)+o))
Buggy python submission (verdict: Runtime Error):
a={1,3,5,7,8,10,12}
b={4,6,9,11}
c={2}
xy=map(set,input().split())
if xy.issubset(a) or xy.issubset(b) or xy.issubset(c):
  print("No")
else:
  print("Yes")

Fixed submission:
a={1,3,5,7,8,10,12}
b={4,6,9,11}
c={2}
xy=set(map(int,input().split()))
if xy.issubset(a) or xy.issubset(b) or xy.issubset(c):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
for i in range(10**5):
  s=s.replace("ST","")

print(len(s))

Fixed submission:
s=input()

from collections import deque

stack=deque()

for i in s:
  if i=="S":
    stack.append(i)
  if i=="T":
    if len(stack)>0 and stack[-1]=="S":
      stack.pop()
    else:
      stack.append(i)
      
  #print(stack)
print(len(stack))