Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
from heapq import heappush,heappop
qqq=[[10**15 for _ in range(n)]for _ in range(n)]
for i in range(n-1):
	x,y,z=map(int,input().split())
	qqq[x-1][y-1]=z
	qqq[y-1][x-1]=z
dis=[10**15 for _ in range(n)]
qq,k=map(int,input().split())
dis[k-1]=0
s=set()
for i in range(n):
	q=10**15
	for j in range(n):
		if (j not in s) and q>dis[j]:
			q=dis[j]
			lit=j
	s.add(lit)
	for j in range(n):
		if j not in s:
			if dis[j]>dis[lit]+qqq[lit][j]:
				dis[j]=dis[lit]+qqq[lit][j]
for i in range(qq):
	r,t=map(int,input().split())
	print(dis[r-1]+dis[t-1])



Fixed submission:
n=int(input())
cd=[[]for _ in range(n)]
for i in range(n-1):
	a,b,c=map(int,input().split())
	cd[a-1].append([b,c])
	cd[b-1].append([a,c])
q,k=map(int,input().split())
from collections import deque
dis=[-1]*n
dis[k-1]=0
stack=deque([k])
while stack:
	p=stack.popleft()
	for i in range(len(cd[p-1])):
		if dis[cd[p-1][i][0]-1]==-1:
			dis[cd[p-1][i][0]-1]=dis[p-1]+cd[p-1][i][1]
			stack.append(cd[p-1][i][0])
for i in range(q):
	x,y=map(int,input().split())
	print(dis[x-1]+dis[y-1])
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input())
if a%3==0 or b%3==0 or (a+b)%3==0:
 print("Possible")
else:
 print("Impossible")

Fixed submission:
a,b=map(int,input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:
 print("Possible")
else:
 print("Impossible")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
b=[]
a=list(map(int,input().split()))
k=a[0]
for i in range(n-1):
	b.append(abs(sum(a)-k*2))
	k+=a[i+1]
print(min(b))


Fixed submission:
n=int(input())
b=[]
a=list(map(int,input().split()))
k=a[0]
s=sum(a)
for i in range(n-1):
	b.append(abs(s-k*2))
	k+=a[i+1]
print(min(b))
Buggy python submission (verdict: Runtime Error):
a=int(input())
if a%4==0:
 print("YES")
else:
 print("NO")

Fixed submission:
a,b,c=map(int,input().split())
if (10*b+c)%4==0:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
n=int(input)
a=list(map(int,input().split()))
print(max(a)-min(a))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
print(max(a)-min(a))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
	a[i]//=400
free=0
b=set()
for i in range(n):
	if a[i]>=8:
		free+=1
	else:
		b.add(a[i])
cnt=len(b)
x=max(cnt,1)
y=min(cnt+free)
print(x,y)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
	a[i]//=400
free=0
b=set()
for i in range(n):
	if a[i]>=8:
		free+=1
	else:
		b.add(a[i])
cnt=len(b)
x=max(cnt,1)
y=(cnt+free)
print(x,y)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a==2:
 A==2
elif a==4 or a==6 or a==9 or a==11:
 A==1
else:
 A==3
if b==2:
 B==2
elif B==4 or B==6 or B==9 or B==11:
 B==1
else:
 B==3
if A==b:
 print("Yes")
else:
 print("No")

Fixed submission:
a,b=map(int,input().split())
if a==2:
 A=2
elif a==4 or a==6 or a==9 or a==11:
 A=1
else:
 A=3
if b==2:
 B=2
elif b==4 or b==6 or b==9 or b==11:
 B=1
else:
 B=3
if A==B:
 print("Yes")
else:
 print("No")
Buggy python submission (verdict: Runtime Error):
a=input()
b=input()
s=""
for i in range(min(len(b))):
	s+=a[i]+b[i]
if len(a)!=len(b):
	s+=a[-1]
print(s)

Fixed submission:
a=input()
b=input()
s=""
for i in range(len(b)):
	s+=a[i]+b[i]
if len(a)!=len(b):
	s+=a[-1]
print(s)
Buggy python submission (verdict: Runtime Error):
a,b=mp(int,input().split())
if a+b>24:
 print(a+b-24)
else:
 print(a+b)

Fixed submission:
a,b=map(int,input().split())
if a+b>23:
 print(a+b-24)
else:
 print(a+b)
Buggy python submission (verdict: Runtime Error):
a.b=input().split()
if a=="H" and b=="H":
	print("H")
elif a=="H" and b=="D":
	print("D")
elif a=="D" and b=="D":
	print("H")
else:
	print("D")

Fixed submission:
a,b=input().split()
if a=="H" and b=="H":
	print("H")
elif a=="H" and b=="D":
	print("D")
elif a=="D" and b=="D":
	print("H")
else:
	print("D")
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
a=[1]
for i in range(1,n+1):
	if s[i]=="I":
		a.append(a[i-1]+1)
	else:
		a.append(a[i-1]-1)
print(max(a))

Fixed submission:
n=int(input())
s=input()
a=[0]
for i in range(1,n+1):
	if s[i-1]=="I":
		a.append(a[i-1]+1)
	else:
		a.append(a[i-1]-1)
print(max(a))
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
inf=10**15
dis=[[inf for _ in range(n)]for _ in range(n)]
for i in range(n):
	dis[i][i]=0
node=[]
for i in range(m):
	a,b,c=map(int,input().split())
	dis[a-1][b-1]=c
	dis[b-1][a-1]=c
	node.append((a-1,b-1,c))
for i in range(n):
	for j in range(n):
		for k in range(n):
			dis[j][k]=min(dis[j][k],dis[j][i]+dis[i][k])
ans=0
for x in node:
	f=0
	for i in range(n-1):
		if f:
			break
		for j in range(i+1,n):
			if dis[i][j]==dis[i][x[0]]+x[2]+dis[x[1]][j]:
				f=1
				break
			elif dis[i][j]==dis[i][x[1]]+x[2]+dis[x[0]][j]:
				f=1
				break
	if f==0:
		ans+=1
print(ans)

Fixed submission:
def main():
	n,m=map(int,input().split())
	inf=10**15
	dis=[[inf for _ in range(n)]for _ in range(n)]
	for i in range(n):
		dis[i][i]=0
	node=[]
	for i in range(m):
		a,b,c=map(int,input().split())
		dis[a-1][b-1]=c
		dis[b-1][a-1]=c
		node.append((a-1,b-1,c))
	for i in range(n):
		for j in range(n):
			for k in range(n):
				dis[j][k]=min(dis[j][k],dis[j][i]+dis[i][k])
	ans=0
	for x in node:
		f=0
		for i in range(n-1):
			if f:
				break
			for j in range(i+1,n):
				if dis[i][j]==dis[i][x[0]]+x[2]+dis[x[1]][j]:
					f=1
					break
				elif dis[i][j]==dis[i][x[1]]+x[2]+dis[x[0]][j]:
					f=1
					break
		if f==0:
			ans+=1
	print(ans)
if __name__ == '__main__':
	main()
Buggy python submission (verdict: Runtime Error):
n=int(input())
for i in range(n):
	if i**2+i>=2*n:
		p=i
		break
total=(p*(p+1))//2
for i in range(1,p+1):
	if total-n!=i:
		print(i)

Fixed submission:
n=int(input())
for i in range(n+1):
	if i**2+i>=2*n:
		p=i
		break
total=(p*(p+1))//2
for i in range(1,p+1):
	if total-n!=i:
		print(i)

Buggy python submission (verdict: Runtime Error):
n=int(input())
for i in range(int(n**0.5)+3):
	if i**2+i>=2*n:
		p=i
		break
total=(p*(p+1))//2
for i in range(1,p+1):
	if total-n!=i:
		print(i)

Fixed submission:
n=int(input())
for i in range(n+1):
	if i**2+i>=2*n:
		p=i
		break
total=(p*(p+1))//2
for i in range(1,p+1):
	if total-n!=i:
		print(i)
Buggy python submission (verdict: Runtime Error):
n,k-map(int,input().split())
ans=k
for i in range(n):
	ans*=k-1
print(ans)

Fixed submission:
a,b,c=input().split()
if a!=b and b!=c and c!=a:
	print(3)
elif a!=b or b!=c or c!=a:
	print(2)
else:
	print(1)
Buggy python submission (verdict: Runtime Error):
n,k-map(int,input().split())
ans=k
for i in range(n):
	ans*=k-1

Fixed submission:
n,k=map(int,input().split())
ans=k
for i in range(n-1):
	ans*=k-1
print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
ans="CODEFESTIVAL2016"
ans=0
for i in range(16):
	if s[i]!=ans[i]:
		ans+=1
print(ans)

Fixed submission:
s=input()
ans="CODEFESTIVAL2016"
anss=0
for i in range(16):
	if s[i]!=ans[i]:
		anss+=1
print(anss)
Buggy python submission (verdict: Runtime Error):
s=input()
k=int(input())
ss=[]
for i in range(len(s)):
	ss.append(ord(s[i])-ord("a"))
i=0
while k>0:
	if i==len(s)-1:
		ss[i]=(k+ss[i])%26
		break
	elif k>=26-ss[i] and ss[i]!="a":
		k-=(26-ss[i])
		ss[i]=0
	i+=1
ans=""
for i in range(len(s)):
	ans+=chr(ord("a")+ss[i])
print(ans)


Fixed submission:
s=input()
print(s[:4]+" "+s[4:])
Buggy python submission (verdict: Runtime Error):
s=input()
k=int(input())
ss=[]
for i in range(len(s)):
	ss.append(ord(s[i])-ord("a"))
i=0
while k>0:
	if i==len(s)-1:
		ss[i]=(k+ss[i])%26
		break
	elif k>=26-ss[i]:
		k-=(26-ss[i])
		ss[i]=0
	i+=1
ans=""
for i in range(len(s)):
	ans+=chr(ord("a")+ss[i])
print(ans)


if len(ans)==1:
	print(2/0)
elif len(ans)<=3:
	for i in range(10**12):
		ans+="a"

Fixed submission:
s=input()
k=int(input())
ss=[]
for i in range(len(s)):
	ss.append(ord(s[i])-ord("a"))
i=0
while k>0:
	if i==len(s)-1:
		ss[i]=(k+ss[i])%26
		break
	elif k>=26-ss[i] and ss[i]!=0:
		k-=(26-ss[i])
		ss[i]=0
	i+=1
ans=""
for i in range(len(s)):
	ans+=chr(ord("a")+ss[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
sa=input()
sb=input()
sc=input()
pointa=len(sa)
sua=0
pointb=len(sb)
sub=0
pointc=len(sc)
suc=0
turn="a"
for i in range(500):
 if pointa==-1:
  print("A")
  break
 elif pointb==0:
  print("B")
  break
 elif pointc==0:
  print("C")
  break
 elif turn=="a":
  turn=sa[sua]
  pointa-=1
  sua+=1
 elif turn=="b":
  turn=sb[sub]
  pointb-=1
  sub+=1
 else:
  turn=sc[suc]
  pointc-=1
  suc+=1

Fixed submission:
sa=input()
sb=input()
sc=input()
pta=0
ptb=0
ptc=0
turn="a"
for i in range(300):
 if pta==len(sa) and turn=="a":
  print("A")
  break
 elif ptb==len(sb) and turn=="b":
  print("B")
  break
 elif ptc==len(sc) and turn=="c":
  print("C")
  break
 elif turn=="a":
  turn=sa[pta]
  pta+=1
 elif turn=="b":
  turn=sb[ptb]
  ptb+=1
 else:
  turn=sc[ptc]
  ptc+=1
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
h,w,n=map(int,input().split())
ans=[0]*10
p=set()
q=set()
for i in range(n):
	a,b=map(int,input().split())
	for j in range(-1,2):
		for k in range(-1,2):
			if 2<=a+j<=h-1 and 2<=b+k<=w-1:
				r=(a+j)*(10**10)+b+k
				p.add(r)
	q.add(a*(10**10)+b)
p=list(p)
for x in p:
	cnt=0
	for j in range(-1,2):
		for k in range(-1,2):
			if x+j*(10**10)+k in q:
				cnt+=1
	ans[cnt]+=1
print((h-2)*(w-2)-sum(ans[1:]))
for i in range(1,10):
	print(ans[i])

Fixed submission:
def main():
	import sys
	input=sys.stdin.readline
	h,w,n=map(int,input().split())
	ans=[0]*10
	p=set()
	q=set()
	for i in range(n):
		a,b=map(int,input().split())
		for j in range(-1,2):
			for k in range(-1,2):
				if 2<=a+j<=h-1 and 2<=b+k<=w-1:
					r=(a+j)*(10**10)+b+k
					p.add(r)
		q.add(a*(10**10)+b)
	p=list(p)
	for x in p:
		cnt=0
		for j in range(-1,2):
			for k in range(-1,2):
				if x+j*(10**10)+k in q:
					cnt+=1
		ans[cnt]+=1
	print((h-2)*(w-2)-sum(ans[1:]))
	for i in range(1,10):
		print(ans[i])
if __name__ == '__main__':
	main()
Buggy python submission (verdict: Time Limit Exceeded):
n,a=map(int,input().split())
x=list(map(int,input().split()))
p=min(a*n,sum(x))
dp=[[[0]*(n+1)for _ in range(p+1)]for _ in range(n+1)]
dp[0][0][0]=1
for i in range(1,n+1):
	for j in range(p+1):
		for k in range(n+1):
			dp[i][j][k]+=dp[i-1][j][k]
			if j-x[i-1]>=0 and k>=1:
				dp[i][j][k]+=dp[i-1][j-x[i-1]][k-1]
ans=0
for i in range(1,n+1):
	if i*a>p:
		break
	ans+=dp[-1][i*a][i]
print(ans)

Fixed submission:
n,a=map(int,input().split())
x=list(map(int,input().split()))
p=min(a*n,sum(x))
dp=[[[0]*(n+1)for _ in range(p+1)]for _ in range(n+1)]
dp[0][0][0]=1
for i in range(1,n+1):
	for j in range(p+1):
		for k in range(n+1):
			dp[i][j][k]+=dp[i-1][j][k]
			if j-x[i-1]>=0 and k>=1:
				dp[i][j][k]+=dp[i-1][j-x[i-1]][k-1]
ans=0
for i in range(1,n+1):
	if i*a>p:
		break
	ans+=dp[-1][i*a][i]
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[]
for i in range(n):
	x=int(input())
	a.append(x)
ans=0
for i in range(n-1):
	if a[i]>0:
		ans+=(a[i]//2)
		a[i]-=(a[i]//2)*2
	if a[i]>0:
		a[i+1]-=min(a[i],a[i+1])
		ans+=min(a[i],a[i+1])
if a[-1]>0:
	ans+=a[-1]//2
print(ans)


Fixed submission:
s=input()
S=s.count("S")
E=s.count("E")
N=s.count("N")
W=s.count("W")
a=0
b=0
if S>0 and N>0:
	a+=1
elif S==N==0:
	a+=1
if E>0 and W>0:
	b+=1
elif E==W==0:
	b+=1
if a==b==1:
	print("Yes")
else:
	print("No")

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[]
for i in range(n):
	x=int(input())
	a.append(x)
ans=0
for i in range(n-1):
	if a[i]>0:
		ans+=(a[i]//2)
		a[i]-=(a[i]//2)*2
	if a[i]>0:
		a[i+1]-=min(a[i],a[i+1])
		ans+=min(a[i],a[i+1])
if a[-1]>0:
	ans+=a[-1]//2
print(ans

Fixed submission:
s=input()
S=s.count("S")
E=s.count("E")
N=s.count("N")
W=s.count("W")
a=0
b=0
if S>0 and N>0:
	a+=1
elif S==N==0:
	a+=1
if E>0 and W>0:
	b+=1
elif E==W==0:
	b+=1
if a==b==1:
	print("Yes")
else:
	print("No")

Buggy python submission (verdict: Runtime Error):
=int(input())
a=[]
for i in range(n):
	x=int(input())
	a.append(x)
ans=0
for i in range(n-1):
	if a[i]>0:
		ans+=(a[i]//2)
		a[i]-=(a[i]//2)*2
	if a[i]>0:
		a[i+1]-=min(a[i],a[i+1])
		ans+=min(a[i],a[i+1])
if a[-1]>0:
	ans+=a[-1]//2
print(ans)


Fixed submission:
s=input()
S=s.count("S")
E=s.count("E")
N=s.count("N")
W=s.count("W")
a=0
b=0
if S>0 and N>0:
	a+=1
elif S==N==0:
	a+=1
if E>0 and W>0:
	b+=1
elif E==W==0:
	b+=1
if a==b==1:
	print("Yes")
else:
	print("No")
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(a*b9)

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

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

Fixed submission:
a,b=map(int,input().split())
print(a*b)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
for i in range(100):
  if int(i*1.08)==a and int(i*1.1)==b:
    print(i)
    exit(0)
print(-1)

Fixed submission:
a,b=map(int,input().split())
for i in range(10010):
  if i*8//100==a and i//10==b:
    print(i)
    exit(0)
print(-1)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
s=[[]]*m
for i in range(m):
  s[i]=list(map(int,input().split()))
  del s[0]
p=list(map(int,input().split()))

ans=0
for bit in range(1<<n):
  x=0
  for i in range(m):
    y=0
    for j in s[i]:
      if bit&(1<<(j-1)):
        y+=1
    if y%2==p[i]%2:
      x+=1
  if x==m:
    ans+=1

print(ans)

Fixed submission:
n,m=map(int,input().split())
s=[[]]*m
for i in range(m):
  s[i]=list(map(int,input().split()))
  del s[i][0]
p=list(map(int,input().split()))

ans=0
for bit in range(1<<n):
  x=0
  for i in range(m):
    y=0
    for j in s[i]:
      if bit&(1<<(j-1)):
        y+=1
    if y%2==p[i]%2:
      x+=1
  if x==m:
    ans+=1

print(ans)
Buggy python submission (verdict: Runtime Error):
n,p=map(int,input().split())

d={}
x=p
for i in range(2,p):
  while x%i==0:
    if i in d:
      d[i]+=1
    else:
      d[i]=1
    x//=i
  if i*i>=p:
    break

ans=1
for k,v in d:
  for i in range(v//n):
    ans*=k

print(ans)

Fixed submission:
n,p=map(int,input().split())

d={}
x=p
for i in range(2,p):
  while x%i==0:
    if i in d:
      d[i]+=1
    else:
      d[i]=1
    x//=i
  if i*i>=p:
    break
if x>1:
  d[x]=1

ans=1
for k,v in d.items():
  for i in range(v//n):
    ans*=k

print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
print(s.count('+')-s.sount('-'))

Fixed submission:
s=input()
print(s.count('+')-s.count('-'))
Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
ans=False
if abs(a-c)<=d:
  ans=True
if abs(a-b)<=d&&abs(b-c)<=d:
  ans=True
if ans:
  print("Yes")
else:
  print("No")

Fixed submission:
a,b,c,d=map(int,input().split())
ans=False
if abs(a-c)<=d:
  ans=True
if abs(a-b)<=d and abs(b-c)<=d:
  ans=True
if ans:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
x=int(input())

ans=0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i+100*j+50*k==x
      ans+=1
      
print(ans)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
x=int(input())

ans=0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i+100*j+50*k==x:
        ans+=1
      
print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
s[3]='8'
print(s)

Fixed submission:
s=input()
print(s[:3]+'8'+s[4:])
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    int m; cin >> m;
    print(24 - m + 24);

    return 0;
}

Fixed submission:
m=int(input())
print(48-m)
Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,input().split())

ans=0
for i in ranpe(1,n+1):
  s=0
  x=i
  while 0<x:
    s+=x%10
    x=x//10
  if a<=s and s<=b:
    ans+=i
print(ans)


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

ans=0
for i in range(1,n+1):
  s=0
  x=i
  while 0<x:
    s+=x%10
    x//=10
  if a<=s and s<=b:
    ans+=i
print(ans)

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

ans=0
for i in ranpe(1,n+1):
  s=0
  x=i
  while 0<x:
    s+=x%10
    x//=10
  if a<=s and s<=b:
    ans+=i
print(ans)

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

ans=0
for i in range(1,n+1):
  s=0
  x=i
  while 0<x:
    s+=x%10
    x//=10
  if a<=s and s<=b:
    ans+=i
print(ans)
Buggy python submission (verdict: Runtime Error):
s=''.join(sorted(input()))
t=''.joinsorted(input(),reverse=True))
print('YNeos'[s>=t::2])

Fixed submission:
s=''.join(sorted(input()))
t=''.join(sorted(input(),reverse=True))
print('YNeos'[s>=t::2])
Buggy python submission (verdict: Runtime Error):
a=map(int,input().split())
a.sort()
print(a[0]+a[1])

Fixed submission:
a=list(map(int,input().split()))
a.sort()
print(a[0]+a[1])
Buggy python submission (verdict: Runtime Error):
s=input()
for i in range(len(s)/2-1,0,-1):
  if s[0:i]==s[i:i+i]:
    print(i)
    exit(0)

Fixed submission:
s=input()
n=len(s)
for i in range(n//2,0,-1):
  if i*2==n:
    continue
  if s[0:i]==s[i:i+i]:
    print(i+i)
    break

Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)
for i in range(1,n+1):
  if s[0:i]==s[i:i+i]:
    print(i)
    break:

Fixed submission:
s=input()
n=len(s)
for i in range(n//2,0,-1):
  if i*2==n:
    continue
  if s[0:i]==s[i:i+i]:
    print(i+i)
    break
Buggy python submission (verdict: Runtime Error):
x,y=map(int,input.split())
if abs(x-y)<=1:
  print('Blown')
else:
  print('Alice')

Fixed submission:
x,y=map(int,input().split())
if abs(x-y)<=1:
  print('Brown')
else:
  print('Alice')
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
from collections import deque
from collections import Counter
import math
import itertools

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1] * n

	def find(self, x):
		if self.parents[x] < 0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)

		if x == y:
			return

		if self.parents[x] > self.parents[y]:
			x, y = y, x

		self.parents[x] += self.parents[y]
		self.parents[y] = x

	def size(self, x):
		return -self.parents[self.find(x)]

	def same(self, x, y):
		return self.find(x) == self.find(y)

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def roots(self):
		return [i for i, x in enumerate(self.parents) if x < 0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()}

	def __str__(self):
		return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m = readInts()
u = UnionFind(n-1)
for i in range(m):
	a,b = readInts()
	u.union(a-1,b-1)

print(u.group_count())

Fixed submission:
from collections import defaultdict
from collections import deque
from collections import Counter
import math
import itertools

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1] * n

	def find(self, x):
		if self.parents[x] < 0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)

		if x == y:
			return

		if self.parents[x] > self.parents[y]:
			x, y = y, x

		self.parents[x] += self.parents[y]
		self.parents[y] = x

	def size(self, x):
		return -self.parents[self.find(x)]

	def same(self, x, y):
		return self.find(x) == self.find(y)

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def roots(self):
		return [i for i, x in enumerate(self.parents) if x < 0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()}

	def __str__(self):
		return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m = readInts()
u = UnionFind(n)
for i in range(m):
	a,b = readInts()
	u.union(a-1,b-1)

print(u.group_count()-1)