Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
T = [1 for i in range(len(S))]


for i in range(10**(100)):
  U = [0 for k in range(len(S))]
  U[1]+=T[0]
  U[len(S)-2]+=T[len(S)-1]
  for j in range(1,len(S)-1):
    if S[j]=='R':
      U[j+1]+=T[j]
    else:
      U[j-1]+=T[j]
  T = U
  
for i in T:
  print(i, end=' ')

Fixed submission:
S=input()
#偶数回
#左右からfor
N=len(S)
odd=0
even=0
ans=[0]*N
for i in range(N-1):
    if i%2==0 and S[i]=="R":
        even+=1
    if i%2!=0 and S[i]=="R":
        odd+=1

    if S[i]=="R" and S[i+1]=="L":
        if i%2==0:
            ans[i]+=even
            ans[i+1]+=odd
        else:
            ans[i]+=odd
            ans[i+1]+=even
        odd=0
        even=0
odd=0
even=0
for i in range(N-1,0,-1):
    if i%2==0 and S[i]=="L":
        even+=1
    if i%2!=0 and S[i]=="L":
        odd+=1
    if S[i]=="L" and S[i-1]=="R":
        if i%2==0:
            ans[i]+=even
            ans[i-1]+=odd
        else:
            ans[i]+=odd
            ans[i-1]+=even
        odd=0
        even=0
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
T = [1 for i in range(len(S))]


for i in range(10**(5)):
  U = [0 for k in range(len(S))]
  U[1]+=T[0]
  U[len(S)-2]+=T[len(S)-1]
  for j in range(1,len(S)-1):
    if S[j]=='R':
      U[j+1]+=T[j]
    else:
      U[j-1]+=T[j]
  T = U
  
for i in T:
  print(i, end=' ')

Fixed submission:
S=input()
#偶数回
#左右からfor
N=len(S)
odd=0
even=0
ans=[0]*N
for i in range(N-1):
    if i%2==0 and S[i]=="R":
        even+=1
    if i%2!=0 and S[i]=="R":
        odd+=1

    if S[i]=="R" and S[i+1]=="L":
        if i%2==0:
            ans[i]+=even
            ans[i+1]+=odd
        else:
            ans[i]+=odd
            ans[i+1]+=even
        odd=0
        even=0
odd=0
even=0
for i in range(N-1,0,-1):
    if i%2==0 and S[i]=="L":
        even+=1
    if i%2!=0 and S[i]=="L":
        odd+=1
    if S[i]=="L" and S[i-1]=="R":
        if i%2==0:
            ans[i]+=even
            ans[i-1]+=odd
        else:
            ans[i]+=odd
            ans[i-1]+=even
        odd=0
        even=0
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N=int(input())

que=[-1]
for i in range(N):
    a=int(input())
    
    if que[0]<a:
        i=bisect.bisect_left(que, a)
        que[i-1]=a
    else:
        que=[a]+que

print(len(que))
#print(que)

Fixed submission:
import bisect
from collections import deque
N=int(input())

que=deque([-1])
for i in range(N):
    a=int(input())
    
    if que[0]<a:
        i=bisect.bisect_left(que, a)
        que[i-1]=a
    else:
        que.appendleft(a)

print(len(que))
#print(que)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N=int(input())

que=[-1]
for i in range(N):
    a=int(input())
    i=bisect.bisect_left(que, a)
    if i!=0:
        que[i-1]=a
    else:
        que=[a]+que

print(len(que))


Fixed submission:
import bisect
from collections import deque
N=int(input())

que=deque([-1])
for i in range(N):
    a=int(input())
    
    if que[0]<a:
        i=bisect.bisect_left(que, a)
        que[i-1]=a
    else:
        que.appendleft(a)

print(len(que))
#print(que)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N=int(input())

que=[-1]
for i in range(N):
    a=int(input())
    i=bisect.bisect_left(que, a)
    if i!=0:
        que[i-1]=a
    else:
        que=[a]+que

print(len(que))


Fixed submission:
import bisect
from collections import deque
N=int(input())

que=deque([-1])
for i in range(N):
    a=int(input())
    
    if que[0]<a:
        i=bisect.bisect_left(que, a)
        que[i-1]=a
    else:
        que.appendleft(a)

print(len(que))
#print(que)
Buggy python submission (verdict: Time Limit Exceeded):
L,R=map(int, input().split())
#2019の倍数が入っていれば０→R-Lが２０１９以上
if L-R>=2019:
    print(0)
    exit()

ans=2019
for i in range(L,R):
    for j in range(i+1,R+1):
        ans=min(ans, (i*j)%2019)
print(ans)

Fixed submission:
L,R=map(int, input().split())
#2019の倍数が入っていれば０→R-Lが２０１９以上
if R-L>=2019:
    print(0)
    exit()

ans=2019
for i in range(L,R):
    for j in range(i+1,R+1):
        ans=min(ans, (i*j)%2019)
print(ans)

Buggy python submission (verdict: Runtime Error):
L, R=map(int, input().split())
mod=2019
A=[0]*(R-L+1)
for i in range(L, R+1):
  A[i-L]=i%mod
  
A=sorted(A)
print((A[0]*A[1])%mod)

Fixed submission:
L,R=map(int, input().split())
#2019の倍数が入っていれば０→R-Lが２０１９以上
if R-L>=2019:
    print(0)
    exit()

ans=2019
for i in range(L,R):
    for j in range(i+1,R+1):
        ans=min(ans, (i*j)%2019)
print(ans)

Buggy python submission (verdict: Runtime Error):
L, R=map(int, input().split())
mod=2019
A=[0]*(R-L+1)
for i in range(L, R+1):
  A[i]=i%mod
  
A=sorted(A)
print((A[0]*A[1])%mod)

Fixed submission:
L,R=map(int, input().split())
#2019の倍数が入っていれば０→R-Lが２０１９以上
if R-L>=2019:
    print(0)
    exit()

ans=2019
for i in range(L,R):
    for j in range(i+1,R+1):
        ans=min(ans, (i*j)%2019)
print(ans)

Buggy python submission (verdict: Runtime Error):
L, R=map(int, input().split())
mod=2019
A=[0]*(R-L+1)
for i in range(L. R+1):
  A[i]=i%mod
  
A=sorted(A)
print((A[0]*A[1])%mod)

Fixed submission:
L,R=map(int, input().split())
#2019の倍数が入っていれば０→R-Lが２０１９以上
if R-L>=2019:
    print(0)
    exit()

ans=2019
for i in range(L,R):
    for j in range(i+1,R+1):
        ans=min(ans, (i*j)%2019)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())
S=[]
for i in range(L, R):
  for j in range(i+1, R+1):
    s= (i*j) % 2019
    S.append(s)
    
print(min(S))



Fixed submission:
L,R=map(int, input().split())
#2019の倍数が入っていれば０→R-Lが２０１９以上
if R-L>=2019:
    print(0)
    exit()

ans=2019
for i in range(L,R):
    for j in range(i+1,R+1):
        ans=min(ans, (i*j)%2019)
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
L=[]
for i in range(N):
    x,y=map(int, input().split())
    L.append((x,y))

D={}
for i in range(N-1):
    t1=L[i]
    L2=L[i+1:]
    for t2 in L2:
        x1,y1=t1
        x2,y2=t2
        d1=(x2-x1,y2-y1)
        d2=(x1-x2,y1-y2)
        if d1 in D:
            D[(x2-x1,y2-y1)]+=1
        else:
            D[(x2-x1,y2-y1)]=1
        if d2 in D:
            D[(x1-x2,y1-y2)]+=1
        else:
            D[(x1-x2,y1-y2)]=1

print(max(N-max(D.values()),0))


Fixed submission:
N=int(input())
L=[]
if N==1:
    print(1)
    exit()
for i in range(N):
    x,y=map(int, input().split())
    L.append((x,y))

D={}
for i in range(N-1):
    t1=L[i]
    L2=L[i+1:]
    for t2 in L2:
        x1,y1=t1
        x2,y2=t2
        d1=(x2-x1,y2-y1)
        d2=(x1-x2,y1-y2)
        if d1 in D:
            D[(x2-x1,y2-y1)]+=1
        else:
            D[(x2-x1,y2-y1)]=1
        if d2 in D:
            D[(x1-x2,y1-y2)]+=1
        else:
            D[(x1-x2,y1-y2)]=1

print(max(N-max(D.values()),0))
Buggy python submission (verdict: Runtime Error):
N, M=map(int, input().split())
mod=10**9+7
pre=-1
hole=[]
for i in range(M):
  a=int(input())
  hole.append(a-1-pre)
  pre=a
hole.append(N-pre)

  

dp=[0]*(N+1)
dp[1]=1
dp[2]=1
for i in range(3,N+1):
  dp[i]=(dp[i-1]+dp[i-2])%mod
if len(hole)==1:
  print(dp[N])
  
#print(dp)
#print(hole)
ans=1
for h in hole:
  ans*=dp[h]
  ans%=mod
  
print(ans)

Fixed submission:
N, M=map(int, input().split())
mod=10**9+7
pre=-1
hole=[]
for i in range(M):
  a=int(input())
  hole.append(a-1-pre)
  pre=a
hole.append(N-pre)

  

dp=[0]*(N+3)
dp[1]=1
dp[2]=1
for i in range(3,N+3):
  dp[i]=(dp[i-1]+dp[i-2])%mod

  
#print(dp)
#print(hole)
ans=1
for h in hole:
  ans*=dp[h]
  ans%=mod
  
print(ans)

Buggy python submission (verdict: Runtime Error):
N, M=map(int, input().split())
mod=10**9+7
pre=-1
hole=[]
for i in range(M):
  a=int(input())
  hole.append(a-1-pre)
  pre=a
hole.append(N-pre)

dp=[0]*(N+1)
dp[1]=1
dp[2]=1
for i in range(3,N+1):
  dp[i]=(dp[i-1]+dp[i-2])%mod
  
#print(dp)
#print(hole)
ans=1
for h in hole:
  ans*=dp[h]
  ans%=mod
  
print(ans)

Fixed submission:
N, M=map(int, input().split())
mod=10**9+7
pre=-1
hole=[]
for i in range(M):
  a=int(input())
  hole.append(a-1-pre)
  pre=a
hole.append(N-pre)

  

dp=[0]*(N+3)
dp[1]=1
dp[2]=1
for i in range(3,N+3):
  dp[i]=(dp[i-1]+dp[i-2])%mod

  
#print(dp)
#print(hole)
ans=1
for h in hole:
  ans*=dp[h]
  ans%=mod
  
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M=map(int, input().split())

for i in range(M):
  L,R=map(int, input().split())
  if i==0:
    LR=set(list(range(L,R+1)))
  else:
    LR=LR&set(list(range(L,R+1)))
print(len(LR))

Fixed submission:
N, M=map(int, input().split())

a=1
b=N
for i in range(M):
  L,R=map(int, input().split())
  a=max(a,L)
  b=min(b,R)
  
if b>=a:
  print(b-a+1)
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
from math import ceil
import numpy as np
N,K=map(int, input().split())
#サイコロを振る　１以上K未満→コイン　K以上ゲーム終了、す抜けのかち
#コイン　表なら２倍　裏なら０　０なったら負け
ans=max( (N-K+1),0) /N

#(K-1)/N
# M*(2**x)>=K M:サイコロの目
# x*log(2)>=log(K/M)
lim=min(K-1,N)
for i in range(1,lim+1):
    x=ceil(np.log(K/i)/np.log(2))
    ans+=(1/N)*((0.5)**x)
print(ans)

Fixed submission:
from math import ceil
import numpy as np
N,K=map(int, input().split())
#サイコロを振る　１以上K未満→コイン　K以上ゲーム終了、す抜けのかち
#コイン　表なら２倍　裏なら０　０なったら負け
ans=max( (N-K+1),0) /N

#(K-1)/N
# M*(2**x)>=K M:サイコロの目
# x*log(2)>=log(K/M)
lim=min(K-1,N)
for i in range(1,lim+1):
    x=ceil(np.log(K/i)/np.log(2))
    ans+=(1/N)*((0.5)**x)
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
import numpy as np
N, K=map(int, input().split())

p1=(N-K)/N
klist=list(range(1,K+1))

def calc(x, K):
  y=math.ceil((np.log(K)-np.log(x))/np.log(2))
  p=x*(0.5)**y
  
  return p

plist=map(calc, klist)
p2=sum(plist)
print(p1+p2)


Fixed submission:
from math import ceil
import numpy as np
N,K=map(int, input().split())
#サイコロを振る　１以上K未満→コイン　K以上ゲーム終了、す抜けのかち
#コイン　表なら２倍　裏なら０　０なったら負け
ans=max( (N-K+1),0) /N

#(K-1)/N
# M*(2**x)>=K M:サイコロの目
# x*log(2)>=log(K/M)
lim=min(K-1,N)
for i in range(1,lim+1):
    x=ceil(np.log(K/i)/np.log(2))
    ans+=(1/N)*((0.5)**x)
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
import numpy as np
N, K=map(int, input().split())

p1=(N-K)/N
klist=list(range(1,K+1))

def calc(x, K):
  y=math.floor((np.log(K)-np.log(x))/np.log(2))
  p=x*(0.5)**y
  
  return p

plist=map(calc, klist)
p2=sum(plist)
print(p1+p2)


Fixed submission:
from math import ceil
import numpy as np
N,K=map(int, input().split())
#サイコロを振る　１以上K未満→コイン　K以上ゲーム終了、す抜けのかち
#コイン　表なら２倍　裏なら０　０なったら負け
ans=max( (N-K+1),0) /N

#(K-1)/N
# M*(2**x)>=K M:サイコロの目
# x*log(2)>=log(K/M)
lim=min(K-1,N)
for i in range(1,lim+1):
    x=ceil(np.log(K/i)/np.log(2))
    ans+=(1/N)*((0.5)**x)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N=map(int, input().split())
rmax=N//R
gmax=N//G
ans=0
for r in range(rmax+1):
  for g in range(gmax+1):
    if N-(r*R+g*G)>=0 and (N-(r*R+g*G))%B==0:
      ans+=1
print(ans)

Fixed submission:
R,G,B,N=map(int, input().split())
rmax=N//R
gmax=N//G
ans=0
for r in range(rmax+1):
  for g in range(gmax+1):
    if N-(r*R+g*G)>=0 and (N-(r*R+g*G))%B==0:
      ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
A, B=map(int, input().split())

if B - A<=1000:
    ans=A
    for i in range(A+1, B+1):
        ans=ans^i
    print(ans)
else:
    lis=[]
    for i in range(A, B+1):
        if i%4==0:
            break
        else:
            lis.append(i)
    for j in range(B, A-1, -1):
        if j%4==0:
            break
        else:
            lis.append(j)
    for i in range(len(lis)):
        if i==0:
            ans=lis[i]
        else:
            ans=ans^i
    print(ans)


Fixed submission:
#40桁
A,B=map(int, input().split())
#print(bin(A),bin(B))
if A==B:
  print(A)
  exit()
#１が奇数個なら１　偶数こなら０
#2**0 偶奇一致　（A-B）%2==0
#010101010101
#2**1 110011001100...
#2**2 11110000111100001111
ans=0
for i in range(40):
  now=0
  aone=False
  bone=False
  if A>>i&1==1:
    aone=True
  if B>>i&1==1:
    bone=True
  amod=(A)%(2**i)
  bmod=(B)%(2**i)
  #print("amod,bmod",amod, bmod)
  left=(A//(2**i))*(2**i)+amod+1
  right=(B//(2**i))*(2**i)+bmod+1
  base=right-left+1
  #print("left, right", left, right)
  if aone:
    now+=2**i-amod
    base-=2**i-amod
  if bone:
    now+=bmod+1
    base-=bmod+1
  if amod!=bmod:
    now+=(base//(2**i))*2
  now+=((base//(2**i))//2)*2**i
  if now%2==1:
    ans+=2**i
  #print(now)
  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
A, B=map(int, input().split())

ans=A
for i in range(A, B+1):
  if i==A:
    continue
  ans=ans^i
  
print(ans)

Fixed submission:
#40桁
A,B=map(int, input().split())
#print(bin(A),bin(B))
if A==B:
  print(A)
  exit()
#１が奇数個なら１　偶数こなら０
#2**0 偶奇一致　（A-B）%2==0
#010101010101
#2**1 110011001100...
#2**2 11110000111100001111
ans=0
for i in range(40):
  now=0
  aone=False
  bone=False
  if A>>i&1==1:
    aone=True
  if B>>i&1==1:
    bone=True
  amod=(A)%(2**i)
  bmod=(B)%(2**i)
  #print("amod,bmod",amod, bmod)
  left=(A//(2**i))*(2**i)+amod+1
  right=(B//(2**i))*(2**i)+bmod+1
  base=right-left+1
  #print("left, right", left, right)
  if aone:
    now+=2**i-amod
    base-=2**i-amod
  if bone:
    now+=bmod+1
    base-=bmod+1
  if amod!=bmod:
    now+=(base//(2**i))*2
  now+=((base//(2**i))//2)*2**i
  if now%2==1:
    ans+=2**i
  #print(now)
  
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S=input()
N=len(S)
L=N
for i in range(L):
  S=S.replace("01","")
  S=S.replace("10","")
  #print(S)
  if L==len(S):
    break
  L=len(S)
  
#print(S)
print(N-L)

Fixed submission:
S=input()
N=len(S)
ones=S.count("1")
zeros=S.count("0")
print(N-abs(ones-zeros))

Buggy python submission (verdict: Time Limit Exceeded):
S=input()
N=len(S)
L=N
for i in range(L):
  S=S.replace("01","")
  S=S.replace("10","")
  #print(S)
  if L==len(S):
    break
  L=len(S)
  
#print(S)
print(N-L)

Fixed submission:
S=input()
N=len(S)
ones=S.count("1")
zeros=S.count("0")
print(N-abs(ones-zeros))

Buggy python submission (verdict: Time Limit Exceeded):
S=input()
N=len(S)
L=N
for i in range(L):
  S="".join(S.split("01"))
  S="".join(S.split("10"))
  #print(S)
  if L==len(S):
    break
  L=len(S)
  
#print(S)
print(N-L)

Fixed submission:
S=input()
N=len(S)
ones=S.count("1")
zeros=S.count("0")
print(N-abs(ones-zeros))
Buggy python submission (verdict: Time Limit Exceeded):
A,B,Q=map(int, input().split())
from bisect import bisect_left

S=[]
for i in range(A):
    s=int(input())
    S.append(s)
T=[]
for i in range(B):
    t=int(input())
    T.append(t)

for i in range(Q):
    x=int(input())
    sidx=bisect_left(S, x)
    tidx=bisect_left(T, x)
    if 0<=sidx<A and 0<=tidx<B:
        a1=max(S[sidx], T[tidx])-x
    else:
        a1=float("INF")
    if 0<=sidx-1<A and 0<=tidx-1<B:
        a2=max(x-S[sidx-1], x-T[tidx-1])
    else:
        a2=float("INF")
    if 0<=sidx<A and 0<=tidx-1<B:
        a3=S[sidx]-T[tidx-1]+min(S[sidx]-x, x-T[tidx-1])
    else:
        a3=float("INF")
    if 0<=sidx-1<A and 0<=tidx<B:
        a4=T[tidx]-S[sidx-1]+min(T[tidx]-x, x-S[sidx-1])
    else:
        a4=float("INF")
    #print(a1,a2,a3,a4)
    ans=min(a1,a2,a3,a4)
    print(ans)


Fixed submission:
A,B,Q=map(int, input().split())
from bisect import bisect_left

S=[]
for i in range(A):
    s=int(input())
    S.append(s)
T=[]
for i in range(B):
    t=int(input())
    T.append(t)

for i in range(Q):
    x=int(input())
    sidx=bisect_left(S, x)
    tidx=bisect_left(T, x)
    if 0<=sidx<A and 0<=tidx<B:
        a1=max(S[sidx], T[tidx])-x
    else:
        a1=float("INF")
    if 0<=sidx-1<A and 0<=tidx-1<B:
        a2=max(x-S[sidx-1], x-T[tidx-1])
    else:
        a2=float("INF")
    if 0<=sidx<A and 0<=tidx-1<B:
        a3=S[sidx]-T[tidx-1]+min(S[sidx]-x, x-T[tidx-1])
    else:
        a3=float("INF")
    if 0<=sidx-1<A and 0<=tidx<B:
        a4=T[tidx]-S[sidx-1]+min(T[tidx]-x, x-S[sidx-1])
    else:
        a4=float("INF")
    #print(a1,a2,a3,a4)
    ans=min(a1,a2,a3,a4)
    print(ans)
Buggy python submission (verdict: Runtime Error):
from math import gcd
N=int(input())
A=list(map(int, input().split()))

for i in range(N-1):
    if i==0:
        G=gcd(A[0],A[1])
    else:
        G=gcd(G,A[i+1])

print(G)
    
        


Fixed submission:
from fractions import gcd
N=int(input())
A=list(map(int, input().split()))
if len(set(A))==1:
  print(A[0])
  exit()
  
#A=sorted(A, reverse=True)
alleven=True


for i in range(1,N):
  if i==1:
    now=gcd(A[i-1],A[i])
  else:
    now=gcd(now,A[i])

print(now)
Buggy python submission (verdict: Runtime Error):
S=input()
key="keyence"

exclude=0
now=False
count=0
for i in range(len(S)):
    s=S[i]
    if s==key[count] and count<7:
        if now:
            now=False
        count+=1
    else:
        if (not now) and exclude>0:
            print("NO")
            exit()
        if not now:
            exclude+=1
            now=True
if count!=7:
    print("NO")
else:
    print("YES")
#print(count)

Fixed submission:
S=input()
key="keyence"

if S.find(key)!=-1:
    print("YES")
    exit()


count=0
for i in range(7):
    s=S[i]
    if s==key[count]:
        count+=1
    else:
        break

for i in range(-1,-8,-1):
    s=S[i]
    if s==key[i]:
        count+=1
    else:
        break
if count>=7:
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
S=input()
key="keyence"

exclude=0
now=False
count=0
for i in range(len(S)):
    s=S[i]
    if s==key[count]:
        if now:
            now=False
        count+=1
    else:
        if (not now) and exclude>0:
            print("NO")
            exit()
        if not now:
            exclude+=1
            now=True
if count!=len(S)-1:
    print("NO")
else:
    print("YES")


Fixed submission:
S=input()
key="keyence"

if S.find(key)!=-1:
    print("YES")
    exit()


count=0
for i in range(7):
    s=S[i]
    if s==key[count]:
        count+=1
    else:
        break

for i in range(-1,-8,-1):
    s=S[i]
    if s==key[i]:
        count+=1
    else:
        break
if count>=7:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
from collections import deque

d = deque()
N=int(input())
A=[]
for i in range(N):
    a=int(input())
    A.append(a)
A=sorted(A)
A2=A.copy()
#61823
#351914
#419153
B=deque()
#最初に大きい方
B.append(A.pop(-1))
while len(A)>0:
    if len(A)>0:
        B.appendleft(A.pop(0))
    if len(A)>0:
        B.append(A.pop(0))
    if len(A)>0:
        B.appendleft(A.pop(-1))
    if len(A)>0:
        B.append(A.pop(-1))
B=list(B)
C=deque()
#最初に小さい方
C.append(A2.pop(0))
while len(A2)>0:
    if len(A2)>0:
        C.appendleft(A2.pop(-1))
    if len(A2)>0:
        C.append(A2.pop(-1))
    if len(A2)>0:
        C.appendleft(A2.pop(0))
    if len(A2)>0:
        C.append(A2.pop(0))
C=list(C)
countb=0
countc=0
for i in range(1,N):
    countb+=abs(B[i]-B[i-1])
    countc+=abs(C[i]-C[i-1])
print(max(countb, countc))


Fixed submission:
from collections import deque

d = deque()
N=int(input())
A=[]
for i in range(N):
    a=int(input())
    A.append(a)
A=sorted(A)
A2=A.copy()
#61823
#351914
#419153
B=deque()
#最初に大きい方
B.append(A.pop(-1))
while len(A)>0:
    if len(A)>0:
        B.appendleft(A.pop(0))
    if len(A)>0:
        B.append(A.pop(0))
    if len(A)>0:
        B.appendleft(A.pop(-1))
    if len(A)>0:
        B.append(A.pop(-1))
B=list(B)
C=deque()
#最初に小さい方
C.append(A2.pop(0))
while len(A2)>0:
    if len(A2)>0:
        C.appendleft(A2.pop(-1))
    if len(A2)>0:
        C.append(A2.pop(-1))
    if len(A2)>0:
        C.appendleft(A2.pop(0))
    if len(A2)>0:
        C.append(A2.pop(0))
C=list(C)
countb=0
countc=0
for i in range(1,N):
    countb+=abs(B[i]-B[i-1])
    countc+=abs(C[i]-C[i-1])
print(max(countb, countc))
Buggy python submission (verdict: Runtime Error):
N,T=map(int, input().split())
ans=10**9
for i in range(N):
  c,t=map(int, input().split())
  if t<=T:
    ans=min(ans,c)
if ans=10**9:
  print("TLE")
else:
  print(ans)

Fixed submission:
N,T=map(int, input().split())
ans=10**9
for i in range(N):
  c,t=map(int, input().split())
  if t<=T:
    ans=min(ans,c)
if ans==10**9:
  print("TLE")
else:
  print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())

#h=max(H-|X-Cx|-|Y-Cy|,0)
#h=H-|X-Cx|-|Y-Cy|    h=0
#H=h+|X-Cx|+|Y-Cy|
S=[]
for i in range(N):
  x,y,h=map(int, input().split())
  S.append((x,y,h))

for cx in range(100+1):
  for cy in range(100+1):
    isans=True
    preH=0
    late=[]
    for i in range(N):
      x,y,h=S[i]
      if h==0:
        late.append((x,y,z))
      else:
        H=h+abs(x-cx)+abs(y-cy)
        #print(H)
        if preH==0:
          preH=H
        elif preH!=H:
          isans=False
        preH=H
    for i in range(len(late)):
      x,y,h=late[i]
      if preH!=0 and preH>abs(x-cx)+abs(y-cy):
          isans=False
    if isans:
      print(cx, cy, H)



Fixed submission:
N=int(input())

#h=max(H-|X-Cx|-|Y-Cy|,0)
#h=H-|X-Cx|-|Y-Cy|    h=0
#H=h+|X-Cx|+|Y-Cy|
S=[]
for i in range(N):
  x,y,h=map(int, input().split())
  S.append((x,y,h))

for cx in range(100+1):
  for cy in range(100+1):
    isans=True
    preH=0
    late=[]
    for i in range(N):
      x,y,h=S[i]
      if h==0:
        late.append((x,y,h))
      else:
        H=h+abs(x-cx)+abs(y-cy)
        #print(H)
        if preH==0:
          preH=H
        elif preH!=H:
          isans=False
        preH=H
    for i in range(len(late)):
      x,y,h=late[i]
      if preH!=0 and preH>abs(x-cx)+abs(y-cy):
          isans=False
    if isans:
      print(cx, cy, H)

Buggy python submission (verdict: Runtime Error):
N=int(input())

#h=max(H-|X-Cx|-|Y-Cy|,0)
#h=H-|X-Cx|-|Y-Cy|    h=0
#H=h+|X-Cx|+|Y-Cy|
S=[]
for i in range(N):
  x,y,h=map(int, input().split())
  S.append((x,y,h))

for cx in range(100+1):
  for cy in range(100+1):
    isans=True
    preH=0
    late=[]
    for i in range(N):
      x,y,h=S[i]
      if h==0:
        late.append((x,y,z))
      else:
        H=h+abs(x-cx)+abs(y-cy)
        #print(H)
        if preH==0:
          preH=H
        elif preH!=H:
          isans=False
        preH=H
    for x,y,h in late:
      if preH!=0 and preH>abs(x-cx)+abs(y-cy):
          isans=False
    if isans:
      print(cx, cy, H)



Fixed submission:
N=int(input())

#h=max(H-|X-Cx|-|Y-Cy|,0)
#h=H-|X-Cx|-|Y-Cy|    h=0
#H=h+|X-Cx|+|Y-Cy|
S=[]
for i in range(N):
  x,y,h=map(int, input().split())
  S.append((x,y,h))

for cx in range(100+1):
  for cy in range(100+1):
    isans=True
    preH=0
    late=[]
    for i in range(N):
      x,y,h=S[i]
      if h==0:
        late.append((x,y,h))
      else:
        H=h+abs(x-cx)+abs(y-cy)
        #print(H)
        if preH==0:
          preH=H
        elif preH!=H:
          isans=False
        preH=H
    for i in range(len(late)):
      x,y,h=late[i]
      if preH!=0 and preH>abs(x-cx)+abs(y-cy):
          isans=False
    if isans:
      print(cx, cy, H)
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int, input().split())

if M%N==0:
  print(M//N)
else:
  a=M//N
  while a>0:
    if (M-a*N)%a==0:
      print(a)
      break
    else:
      a-=1

Fixed submission:
N,M=map(int, input().split())

if M%N==0:
  print(M//N)
else:
  a=M//N
  while a>0:
    if (M-a*N)%a==0:
      print(a)
      break
    else:
      a-=1