Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n=int(input().split())
l=list(map(int,input().split()))
cnt=0
for i in range(n-1):
  if (l[i] == i+1) and (l[i+1] == i+2):
    {l[i],l[i+1]}={l[i+1],l[i]}
    cnt+=1
print(cnt)


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

Buggy python submission (verdict: Runtime Error):
n=int(input().split())
l=list(map(int,input().split()))
cnt=0
for i in range(n-1):
  if l[i] == i+1 and l[i+1] == i+2:
    l[i]=change
    change=l[i+1]
    l[i+1]=l[i]
    cnt+=1
print(cnt)


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

Buggy python submission (verdict: Runtime Error):
n=int(input().split())
l=list(map(int,input().split()))
cnt=0
for i in range(n-1):
  if l[i] == i+1 and l[i+1] == i+2:
    {l[i],l[i+1]}={l[i+1],l[i]}
    cnt+=1
print(cnt)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
cnt=0
for i in range(n-1):
  if l[i] == i+1:
    l[i],l[i+1]=l[i+1],l[i]
    cnt+=1
if l[-1]==n:
  cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
a=input()
c=Counter(a)
if n==1:print(1)
else:
    ans=n*(n-1)//2
    for i in c.values():
        if i==1:continue
        else:ans-=i*(i-1)//2
    print(ans+1)


Fixed submission:
from collections import Counter
a=input()
c=Counter(a)
n=len(a)
if n==1:print(1)
else:
    ans=n*(n-1)//2
    for i in c.values():
        if i==1:continue
        else:ans-=i*(i-1)//2
    print(ans+1)

Buggy python submission (verdict: Runtime Error):
from collections import Counter
a=input()
c=Counter(a)
MOD = 10**9+7
n=len(a)
def inv_mod(a, p=MOD):
    def inv_mod_sub(a, p):
        if a == 1:
            return 1, 0
        else:
            d, r = p//a, p%a
            x, y = inv_mod_sub(r, a)
            return y-d*x, x
    if p < 0: p = -p
    a %= p
    return inv_mod_sub(a,p)[0] % p

def comb_mod(n, k):
    if k < 0 or k > n:
        return 0
    else:
        return f_mod[n]*f_mod_inverse[k]*f_mod_inverse[n-k] % MOD
f_mod=[1]*(n+1)
f_mod_inverse=[1]*(n+1)
for i in range(1,n+1):
  f_mod[i]=f_mod[i-1]*i%MOD
  f_mod_inverse[i]=f_mod_inverse[i-1]*inv_mod(i)%MOD
if n==1:print(1)
else:
    ans=comb_mod(n,2)
    for i in c.values():
        if i==1:continue
        else:ans-=comb_mod(i,2)
print(ans+1)


Fixed submission:
from collections import Counter
a=input()
c=Counter(a)
n=len(a)
if n==1:print(1)
else:
    ans=n*(n-1)//2
    for i in c.values():
        if i==1:continue
        else:ans-=i*(i-1)//2
    print(ans+1)
Buggy python submission (verdict: Runtime Error):
from collcections import Counter
n=int(input())
l=list(map(int,input().split()))
d=[]
L=Counter(l)
a=L.most_common()
for i in a:
  if a[i][1]>=4:
    d.append(a[i][1])
    d.append(a[i][1])
  elif a[i][1]>=2:
    d.append(a[i][1])
d.sort(reverse=True)
print(d[0]*d[1] if len(d)>=2 else 0)

Fixed submission:
from collections import Counter
n=int(input())
l=list(map(int,input().split()))
d=[]
L=Counter(l)
a=L.most_common()
for i in range(len(a)):
  if a[i][1]>=4:
    d.append(a[i][0])
    d.append(a[i][0])
  elif a[i][1]>=2:
    d.append(a[i][0])
d.sort(reverse=True)
print(d[0]*d[1] if len(d)>=2 else 0)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100002)
input=sys.stdin.readline
n=int(input())
graph=[{} for i in range(n)]
visited=[False]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    a-=1;b-=1
    graph[a][b]=c
    graph[b][a]=c
q,k=map(int,input().split())
dist=[0]*n
def dfs(chi,par,cost):
    dist[chi]=cost
    for i in graph[chi].keys():
        if visited[i]:continue
        if i==par:continue
        visited[i]=True
        dfs(i,chi,cost+graph[i][chi])
    return
dfs(k-1,-1,0)
for i in range(q):
    x,y=map(int,input().split())
    x-=1;y-=1
    print(dist[x]+dist[y])


Fixed submission:
n=input()
if n[0]==n[2]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n=int(input())
graph=[{} for i in range(n)]
visited=[False]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    a-=1;b-=1
    graph[a][b]=c
    graph[b][a]=c
q,k=map(int,input().split())
dist=[0]*n
def dfs(chi,par,cost):
    dist[chi]=cost
    for i in graph[chi].keys():
        if visited[i]:continue
        if i==par:continue
        visited[i]=True
        dfs(i,chi,cost+graph[i][chi])
    return
dfs(k-1,-1,0)
for i in range(q):
    x,y=map(int,input().split())
    x-=1;y-=1
    print(dist[x]+dist[y])


Fixed submission:
import sys
sys.setrecursionlimit(100002)
input=sys.stdin.readline
n=int(input())
graph=[{} for i in range(n)]
visited=[False]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    a-=1;b-=1
    graph[a][b]=c
    graph[b][a]=c
q,k=map(int,input().split())
dist=[0]*n
def dfs(chi,par,cost):
    dist[chi]=cost
    for i in graph[chi].keys():
        if visited[i]:continue
        if i==par:continue
        visited[i]=True
        dfs(i,chi,cost+graph[i][chi])
    return
dfs(k-1,-1,0)
for i in range(q):
    x,y=map(int,input().split())
    x-=1;y-=1
    print(dist[x]+dist[y])
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
n=int(input())
c=list(map(int,input().split()))
d=[]
for i in range(1,n+1):
  for j in c[i-1]:
    d.append(i)
ansl=[[0]*w for i in range(h)]
for i in range(h):
  if i%2==0:
    for j in range(w):
      ansl[i][j]=str(d[i*w+j])
  else:
    for j in range(w):
      ansl[i][w-j-1]=str(d[i*w+j])
for j in ansl:
  print(" ".join(j))


Fixed submission:
h,w=map(int,input().split())
n=int(input())
c=list(map(int,input().split()))
d=[]
for i in range(1,n+1):
  for j in range(c[i-1]):
    d.append(i)
ansl=[[0]*w for i in range(h)]
for i in range(h):
  if i%2==0:
    for j in range(w):
      ansl[i][j]=str(d[i*w+j])
  else:
    for j in range(w):
      ansl[i][w-j-1]=str(d[i*w+j])
for j in ansl:
  print(" ".join(j))

Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
n=int(input())
c=list(map(int,input().split()))
d=[]
for i in range(1,n+1):
  for j in c[i-1]:
    d.append(i)
ansl=[[0]*w for i in range(h)]
for i in range(h):
  if i%2==0:
    for j in range(w):
      ansl[i][j]=str(d[i*w+j])
  else:
    for j in range(w):
      ansl[i][w-j-1]=str(d[i*w+j])
for j in ansl:
  print(" ".join(j))

Fixed submission:
h,w=map(int,input().split())
n=int(input())
c=list(map(int,input().split()))
d=[]
for i in range(1,n+1):
  for j in range(c[i-1]):
    d.append(i)
ansl=[[0]*w for i in range(h)]
for i in range(h):
  if i%2==0:
    for j in range(w):
      ansl[i][j]=str(d[i*w+j])
  else:
    for j in range(w):
      ansl[i][w-j-1]=str(d[i*w+j])
for j in ansl:
  print(" ".join(j))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
ans=1
while ans<n:
  ans*=2
  if ans>n:
    ans//=2
print(ans)

Fixed submission:
n=int(input())
ans=1
while ans<n:
  ans*=2
  if ans>n:
    ans//=2
    break
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=list(map(int,input().split()))
l.sort(reverse=True)
ans=0
for i in range(m)
ans+=l[i]


Fixed submission:
n,m=map(int,input().split())
l=list(map(int,input().split()))
l.sort(reverse=True)
ans=0
for i in range(m):
  ans+=l[i]
print(ans)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=list(map(int,input().split()))
l.sort(reverse=True)
print(l[0]+l[1]+l[2])

Fixed submission:
n,m=map(int,input().split())
l=list(map(int,input().split()))
l.sort(reverse=True)
ans=0
for i in range(m):
  ans+=l[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
ans=len(s)
def check(m):
  a=len(m)
  if a%2==1:
    return False
  else:
    if s[0:m//2]==s[m//2:m]:
      return True
    else:
      return False
for i in range(1,len(s),-1):
  ans-=1
  if check(s[0:i])==True:
    print(ans)
  


Fixed submission:
s=input()
ans=len(s)
def check(m):
  a=len(m)
  if a%2==1:
    return False
  else:
    if s[0:a//2]==s[a//2:a]:
      return True
    else:
      return False
for i in range(len(s)-1,0,-1):
  ans-=1
  if check(s[0:i])==True:
    print(ans)
    break
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
if n%2==1:
  l=l[n-1::-2]+l[1::2]
  for i in range(5):
    print(l[i],end=" ")
else:
  l=l[n-1::-2]+l[::2]
  for i in range(5):
    print(l[i],end=" ")

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
if n%2==1:
  l=l[n-1::-2]+l[1::2]
  for i in range(n):
    print(l[i],end=" ")
else:
  l=l[n-1::-2]+l[::2]
  for i in range(n):
    print(l[i],end=" ")
Buggy python submission (verdict: Runtime Error):
n=int(input())
button=[int(input()) for i in range(n)]
temp=1
ans=1
while button[temp-1] not in check:
  temp=button[temp-1]
  ans+=1
  if button[temp-1]==2:
    print(ans)
    break
  elif ans>=n:
    print(-1)
    break


Fixed submission:
n=int(input())
button=[int(input()) for i in range(n)]
temp=1
ans=0
while True:
  temp=button[temp-1]
  ans+=1
  if temp==2:
    print(ans)
    break
  elif ans>=n:
    print(-1)
    break

Buggy python submission (verdict: Runtime Error):
n=int(input())
button=[int(input()) for i in range(n)]
temp=1
ans=1
while button[temp-1] not in check:
  temp=button[temp-1]
  ans+=1
  if button[temp-1]==2:
    print(ans)
    break
  elif ans>=n+1:
    print(-1)
    break


Fixed submission:
n=int(input())
button=[int(input()) for i in range(n)]
temp=1
ans=0
while True:
  temp=button[temp-1]
  ans+=1
  if temp==2:
    print(ans)
    break
  elif ans>=n:
    print(-1)
    break
Buggy python submission (verdict: Runtime Error):
m,d=map(int,input().split())
def fac(n):
  a=1
  if n==1:
    return a
  else:
    a=n*fac(n-1)
    return a%(10**9+7)
if abs(m-d)>=2:
  print(0)
elif abs(m-d)==1:
  print((fac(m)*fac(d))%(10**9+7))
else:
  print(2*(fac(m)**2)%(10**9+7))

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
m,d=map(int,input().split())
def fac(n):
  a=1
  if n==1:
    return a
  else:
    a=n*fac(n-1)
    return a%(10**9+7)
if abs(m-d)>=2:
  print(0)
elif abs(m-d)==1:
  print((fac(m)*fac(d))%(10**9+7))
else:
  print(2*(fac(m)**2)%(10**9+7))
Buggy python submission (verdict: Runtime Error):
n=int(input())
points=[list(map(int,input().split()))+[i] for i in range(n)]
points.sort(key = lambda x:x[1])
edge=[]
for i in range(n-1):
    edge.append((points[i][2],points[i+1][2],points[i+1][1]-points[i][1]))
points.sort()
for i in range(n-1):
    edge.append((points[i][2],points[i+1][2],points[i+1][0]-points[i][0]))
class UnionFind(object):
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.size = [1 for i in range(N)]
    
    def merge(self, a, b):
        if self.issame(a,b):
            return
        pa = self.root(a)
        pb = self.root(b)
        self.parent[pa] = pb
        self.size[pb] += self.size[pa]
    def root(self, x):
        p = self.parent[x]
        if p == x:
            return x
        else:
            r = self.root(p)
            self.parent[x] = r
            return r
    
    def issame(self, x, y):
        return self.root(x) == self.root(y)
    
    def getsize(self, x):
        return self.size[self.root(x)]
edge.sort(key=lambda x:x[2])
uf=UnionFind(n)
ans=0
for ed in edge:
    if uf.issame(ed[0],ed[1]):continue
    ans+=ed[2]
    uf.merge(ed[0],ed[1])
print(ans)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
input=sys.stdin.readline
n=int(input())
points=[list(map(int,input().split()))+[i] for i in range(n)]
points.sort(key = lambda x:x[1])
edge=[]
for i in range(n-1):
    edge.append((points[i][2],points[i+1][2],points[i+1][1]-points[i][1]))
points.sort()
for i in range(n-1):
    edge.append((points[i][2],points[i+1][2],points[i+1][0]-points[i][0]))
class UnionFind(object):
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.size = [1 for i in range(N)]
    
    def merge(self, a, b):
        if self.issame(a,b):
            return
        pa = self.root(a)
        pb = self.root(b)
        self.parent[pa] = pb
        self.size[pb] += self.size[pa]
    def root(self, x):
        p = self.parent[x]
        if p == x:
            return x
        else:
            r = self.root(p)
            self.parent[x] = r
            return r
    
    def issame(self, x, y):
        return self.root(x) == self.root(y)
    
    def getsize(self, x):
        return self.size[self.root(x)]
edge.sort(key=lambda x:x[2])
uf=UnionFind(n)
ans=0
for ed in edge:
    if uf.issame(ed[0],ed[1]):continue
    ans+=ed[2]
    uf.merge(ed[0],ed[1])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
ans=1000
for i in range(26):
  if chr(97+i) not in s:continue
  S=s
  cnt=0
  while(len(set(S)))!=1:
    cnt+=1
    t=""
    for j in range(len(S)-1):
      if S[j] == chr(97+i) or S[j+1] == chr(97+i):
        t+=chr(97+i)
      else:
        t+=S[j]
  ans=min(cnt,ans)
print(ans)

Fixed submission:
s=input()
ans=1000
for i in range(26):
  if chr(97+i) not in s:continue
  S=s
  cnt=0
  while(len(set(S)))!=1:
    cnt+=1
    t=""
    for j in range(len(S)-1):
      if S[j] == chr(97+i) or S[j+1] == chr(97+i):
        t+=chr(97+i)
      else:
        t+=S[j]
    S=t
  ans=min(cnt,ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
a=input().strip()
if int(a)%4==0:
  print("YES")
else:
  print("NO")

Fixed submission:
a=input().replace(" ","")
if int(a)%4==0:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
n=int(input())
rates=list(map(int,input().split()))
over3200=sum(1 for i in rates if i>=3200)
fixed=set()
for i in rates:
  if i//<=7:
    fixed.add(i)
f=len(fixed)
if f==0:
  print(1,over3200)
else:
  print(f,f+over3200)

Fixed submission:
n=int(input())
rates=list(map(int,input().split()))
over3200=sum(1 for i in rates if i>=3200)
fixed=set()
for i in rates:
  if i//400<=7:
    fixed.add(i//400)
f=len(fixed)
if f==0:
  print(1,over3200)
else:
  print(f,f+over3200)
Buggy python submission (verdict: Runtime Error):
n=int(input())
q=[]
for i in range(n):
  q.append(int(input()))
s=sum(q)
check=s%10
if check!=0:
  print(s)
else:
  r=max(q)
  cnt=0
  for i in q:
    if i%10!=0 and i<r:
      r=i
      cnt+=1
  if cnt=0:
    print(0)
  else:
    print(q-r)

Fixed submission:
n=int(input())
q=[]
for i in range(n):
  q.append(int(input()))
q.sort()
s=sum(q)
check=s%10
if check!=0:
  print(s)
else:
  r=max(q)
  cnt=0
  for i in q:
    if i%10!=0 and i<=r:
      r=i
      cnt+=1
  if cnt==0:
    print(0)
  else:
    print(s-r)
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b=map(int,input().split())
HP=[int(input()) for i in range(n)]
ng=0
ok=10**10
for i in range(40):
    check=(ok+ng)//2
    c=a-b
    cnt=0
    d=list(map(lambda x: x-check*b,HP))
    for j in d:
        cnt+=max(0,(j+c-1)//c)
    if check < cnt:
        ng=check
    else:
        ok=check
print(ok)

Fixed submission:
n,a,b=map(int,input().split())
HP=[int(input()) for i in range(n)]
ng=0
ok=10**10
for i in range(40):
    check=(ok+ng)//2
    c=a-b
    cnt=0
    d=list(map(lambda x: x-check*b,HP))
    for j in d:
        cnt+=max(0,(j+c-1)//c)
    if check < cnt:
        ng=check
    else:
        ok=check
print(ok)
Buggy python submission (verdict: Runtime Error):
h,w = map(int,input().split())
for i in range(h+2):
  if i ==0 or i == h+1:
    for d in range(w+2):
      print("#",end="")
      continue
  print("#"+input()+"#")


Fixed submission:
h,w = map(int,input().split())
for i in range(h+2):
  if i ==0 or i == h+1:
    for d in range(w+1):
      print("#",end="")
    print("#")
    continue
  print("#"+input()+"#")

Buggy python submission (verdict: Runtime Error):
h,w = map(int,input().split())
for i in range(h+2):
  if i ==0 or i == h+1:
    for d in range(w+2):
      print("#",end="")
  print("#"+input()+"#")

Fixed submission:
h,w = map(int,input().split())
for i in range(h+2):
  if i ==0 or i == h+1:
    for d in range(w+1):
      print("#",end="")
    print("#")
    continue
  print("#"+input()+"#")
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
arr=[]
for i in range(n):
  a,b=map(int,input().split())
  for j in range(b):
    arr.append(a)
arr.sort()
print(arr[k-1])

Fixed submission:
n,k=map(int,input().split())
nums=[]
for i in range(n):
  nums.append(list(map(int,input().split())))
nums.sort(key=lambda x:x[0])
cnt=0
i=0
while cnt<k:
  cnt+=nums[i][1]
  if cnt>=k:
    print(nums[i][0])
    break
  i+=1
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
num=[0]*n
for i in range(n):
  a,b=map(int,input().split())
  a-=1;b-=1
  num[a]+=1;num[b]+=1
flag=0
for i in num:
  if i%2==1:
    flag=1
    break
if bool(flag):print("NO")
else:print("YES")

Fixed submission:
n,m=map(int,input().split())
num=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  a-=1;b-=1
  num[a]+=1;num[b]+=1
flag=0
for i in num:
  if i%2==1:
    flag=1
    break
if bool(flag):print("NO")
else:print("YES")
Buggy python submission (verdict: Runtime Error):
n,t=map(int,input().split())
oyu=list(map(int,input.split()))
inl=[]
ans=n*t
for i in range(n-1):
  inl.append(oyu[i+1]-oyu[i])
for i in range(n-1):
  if inl[i]<t:
    ans-=t-inl[i]
print(ans)

Fixed submission:
n,t=map(int,input().split())
oyu=list(map(int,input().split()))
inl=[]
ans=n*t
for i in range(n-1):
  inl.append(oyu[i+1]-oyu[i])
for i in range(n-1):
  if inl[i]<t:
    ans-=t-inl[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(str,input().split())
print(a[0].upper+b[0].upper+c[0].upper)

Fixed submission:
a,b,c=map(str,input().split())
print(a[0].upper()+b[0].upper()+c[0].upper())
Buggy python submission (verdict: Runtime Error):
a=input()
b=input()
c=len(a)
d=len(b)
if c>d:
  print("GREATER")
elif c<d:
  print("LESS")
else:
  flag=0
  for i in range(c):
    if int(a[i])>int(b[i]):
      print("GREATER")
      flag=1
      break
    elif int(a[i])<int(b[i]):
      print("LESS")
      flag=1
    else:
      continue
if flag==0:
  print("EQUAL")

Fixed submission:
a=input()
b=input()
c=len(a)
d=len(b)
if c>d:
  print("GREATER")
elif c<d:
  print("LESS")
else:
  flag=0
  for i in range(c):
    if int(a[i])>int(b[i]):
      print("GREATER")
      flag=1
      break
    elif int(a[i])<int(b[i]):
      print("LESS")
      flag=1
      break
    else:
      continue
  if flag==0:
    print("EQUAL")
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
X=0;Y=0
mod=10**9+7
for i in range(n-1):
  X+=(a[i+1]-a[i])*(i+1)*(n-i-1)
  X%=mod
for i in range(n-1):
  Y+=(b[i+1]-b[i])*(i+1)*(n-i-1)
  Y%=mod
print(X*Y%mod)

Fixed submission:
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
X=0;Y=0
mod=10**9+7
for i in range(n-1):
  X+=(a[i+1]-a[i])*(i+1)*(n-i-1)
  X%=mod
for i in range(m-1):
  Y+=(b[i+1]-b[i])*(i+1)*(m-i-1)
  Y%=mod
print((X*Y)%mod)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
students=[]
checks=[]
def mdistance([a,b],[c,d]):
  return abs(a-c)+abs(b-d)
for i in range(n):
  a=list(map(int,input().split()))
  students.append(a)
for i in range(m):
  checks.append(list(map(int,input().split())))
for i in range(n):
  anspoint=0
  for j in range(m):
    if mdistance(students[i],checks[j])<mdistance(students[i],checks[anspoint]):
      anspoint=j
  print(j)

Fixed submission:
n,m=map(int,input().split())
s=[]
c=[]
def mdistance(a,b,c,d):
  return abs(a-c)+abs(b-d)
for i in range(n):
  a=list(map(int,input().split()))
  s.append(a)
for i in range(m):
  c.append(list(map(int,input().split())))
for i in range(n):
  anspoint=0
  for j in range(m):
    if mdistance(s[i][0],s[i][1],c[j][0],c[j][1])<mdistance(s[i][0],s[i][1],c[anspoint][0],c[anspoint][1]):
      anspoint=j
  print(anspoint+1)
Buggy python submission (verdict: Runtime Error):
n,c,k=map(int,input().split())
ans=1
l=[]
for i in range(n):
  l.append(int(input()))
l.sort()
ride=[]
while l:
  a=l.pop(0)
  rode=a
  ride.append(a)
  while len(ride)<c:
    if l==[]:
      break
    b=l[0]
    if b>ride[0]+k:
      ride.clear()
      ans+=1
      break
    l.pop(0)
    ride.append(b)
    if len(ride)==c:
      ans+=1
      ride.clear()
      break
print(ans)

Fixed submission:
n,c,k=map(int,input().split())
ans=0
if c==1:
  print(n)
  exit()
l=[]
for i in range(n):
  l.append(int(input()))
l.sort()
ride=[]
while l:
  a=l.pop(0)
  rode=a
  ride.append(a)
  while len(ride)<c:
    if l==[]:
      ans+=1
      break
    b=l[0]
    if b>ride[0]+k:
      ride.clear()
      ans+=1
      break
    l.pop(0)
    ride.append(b)
    if len(ride)==c:
      ans+=1
      ride.clear()
      break
print(ans)
Buggy python submission (verdict: Runtime Error):
x=int(input())
def factorial(n):
  a=1
  if n==1:
    return a
  else:
    a= n*factorial(n-1)
    return a%(10**9+7)
print(factorial(x))

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
x=int(input())
def factorial(n):
  a=1
  if n==1:
    return a
  else:
    a= n*factorial(n-1)
    return a%(10**9+7)
print(factorial(x))

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)
x=int(input())
def factorial(n):
  a=1
  if n==1:
    return a
  else:
    a= n*factorial(n-1)
    return a
print(factorial(x)%(10**9+7))

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
x=int(input())
def factorial(n):
  a=1
  if n==1:
    return a
  else:
    a= n*factorial(n-1)
    return a%(10**9+7)
print(factorial(x))

Buggy python submission (verdict: Runtime Error):
x=int(input())
def factorial(n):
  a=1
  if n==1:
    return a
  else:
    a= n*factorial(n-1)
    return a
print(factorial(x)%(10**9+7))


Fixed submission:
import sys
sys.setrecursionlimit(10**6)
x=int(input())
def factorial(n):
  a=1
  if n==1:
    return a
  else:
    a= n*factorial(n-1)
    return a%(10**9+7)
print(factorial(x))

Buggy python submission (verdict: Runtime Error):
def factorial(n):
  a=1
  if n==1:
    return a
  else:
    a*= factorial(n-1)
  return a
print(a/(10**9+7))

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
x=int(input())
def factorial(n):
  a=1
  if n==1:
    return a
  else:
    a= n*factorial(n-1)
    return a%(10**9+7)
print(factorial(x))
Buggy python submission (verdict: Runtime Error):
n=int(input())
odd=0
even=0
a=list(map(int,input().split()))
for i in range(n):
  if a[i]%2=1:
    odd+=1
  else:
    even+=1
if odd%2==1:
  print("NO")
else:
  print("YES")

Fixed submission:
n=int(input())
odd=0
even=0
a=list(map(int,input().split()))
for i in range(n):
  if a[i]%2==1:
    odd+=1
  else:
    even+=1
if odd%2==1:
  print("NO")
else:
  print("YES")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[0]*n;b=a[:]
for i in range(n):
  c,d=map(int,input().split())
  a[i]=c;b[i]=d
ans=0
for i in range(n)[::-1]:
  a[i]+=ans
  while a[i]%b[i]!=0:
    a[i]+=1
    ans+=1
print(ans)


Fixed submission:
n=int(input())
a=[0]*n;b=a[:]
for i in range(n):
  c,d=map(int,input().split())
  a[i]=c;b[i]=d
ans=0
for i in range(n)[::-1]:
  a[i]+=ans
  if a[i]%b[i]==0:continue
  ans+=b[i]-(a[i]%b[i])
print(ans)