Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)
input=lambda : sys.stdin.readline().rstrip('\n')

n=int(input())
h=list(map(int,input().split()))

dp=[10**18 for i in range(n)]
def cost(n):
    if n==0:
        return 0
    if n<0:
        return 10**18
    if dp[n]!=10**18:
        return dp[n]
    dp[n] = min(cost(n-1)+abs(h[n]-h[n-1]),cost(n-2)+abs(h[n]-h[n-2]))
    return dp[n]

print(cost(n-1))


Fixed submission:
# coding: utf-8
n=int(input())
h=list(map(int,input().split()))
dp=[999999999 for i in range(n)]
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(100000)
input=lambda : sys.stdin.readline().rstrip('\n')

n=int(input())
h=list(map(int,input().split()))

dp=[10**18 for i in range(n)]
def cost(n):
    if n==0:
        return 0
    if n<0:
        return 10**18
    if dp[n]!=10**18:
        return dp[n]
    return min(cost(n-1)+abs(h[n]-h[n-1]),cost(n-2)+abs(h[n]-h[n-2]))

print(cost(n-1))


Fixed submission:
# coding: utf-8
n=int(input())
h=list(map(int,input().split()))
dp=[999999999 for i in range(n)]
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
import math
memo={}
def f(x,y,Y):
    if (x,y,Y) in memo:
        return memo[(x,y,Y)]
    ans=0
    if x==0:
        memo[(x,y,Y)]=1
        return 1
    for i in range(y,Y):
        tmp=f(x-1,i,Y)
        memo[(x-1,i,Y)] = tmp
        ans+=tmp
    memo[(x,y,Y)] = ans
    return ans
n,m=map(int,input().split())
s=2
d=[]
count=0
while s<=m:
    if m%s==0:
        m//=s
        count+=1
    else:
        if count:
            d.append(count)
        count=0
        s+=1
d.append(count)
ans=1
d=sorted(d)[::-1]
for x in d:
    ans = (ans*f(x,0,n))%(10**9+7)
print(ans)


Fixed submission:
n,m=map(int,input().split())
memo={}
def primes(n):
    primefac = []
    d = 2
    while d*d <= n:
        while (n % d) == 0:
            if d in memo:
                memo[d]+=1
            else:
                memo[d]=1
            n //= d
        d += 1
    if n > 1:
        if n in memo:
            memo[n]+=1
        else:
            memo[n]=1
primes(m)

def cmb(n,r,mod):
    if (r<0 or r>n):
        return 0
    r = min(r,n-r)
    return g1[n]*g2[r]*g2[n-r]%mod

mod = 10**9+7
N = 10**5*2
g1 = [1,1]
g2 = [1,1]
inverse = [0,1]

for i in range(2,N+1):
    g1.append((g1[-1]*i)%mod)
    inverse.append((-inverse[mod%i]*(mod//i))%mod)
    g2.append((g2[-1]*inverse[-1])%mod)

ans=1
for x in memo.items():
    ans*=cmb(x[1]+n-1,x[1],mod)
    ans%=mod

print(ans)
Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
A=list(map(int,input().split()))
ans=1
for x in A:
    ans=ans*x//math.gcd(ans,x)
ans-=1
t=0
for x in A:
    t+=ans%x
print(t)

Fixed submission:
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
 
n=int(input())
A=list(map(int,input().split()))
ans=1
for x in A:
    ans=ans*x//gcd(ans,x)
ans-=1
t=0
for x in A:
    t+=ans%x
print(t)
Buggy python submission (verdict: Runtime Error):
data=[]
for i in range(1,30001):
    if i%2==0 or i%3==0:
        data.append(i)
k=int(input())
if k==3:
    print(*[2,5,63])
elif k==4:
    print(*[2,5,20,63])
elif k==5:
    print(*[2,5,20,63,6])
ans=data[:k]
sm=sum(ans)
if sm%6==2:
    ans[4]=30000
elif sm%6==3:
    ans[5]=30000
elif sm%6==5:
    ans[5]=29998
print(*ans)

Fixed submission:
data=[]
for i in range(1,30001):
    if i%2==0 or i%3==0:
        data.append(i)
k=int(input())
if k==3:
    print(*[2,5,63])
elif k==4:
    print(*[2,5,20,63])
elif k==5:
    print(*[2,5,20,63,30])
else:
    ans=data[:k]
    sm=sum(ans)
    if sm%6==2:
        ans[4]=30000
    elif sm%6==3:
        ans[5]=30000
    elif sm%6==5:
        ans[5]=29998
    print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
table=[]
a=[9999,9999,9999]
b=[9999,9999,9999]
for i in range(3):
    table.append(list(map(int,input().split())))
    a[i]=min(table[-1])
    for j in range(3):
        b[j]=min(b[j],table[-1][j])
for q in range(a[0]+1):
    for w in range(a[1]+1):
        for e in range(a[2]+1):
            for r in range(b[0]+1):
                for t in range(b[1]+1):
                    for y in range(b[2]+1):
                        #print(q,w,e,r,t,y)
                        if q+r==table[0][0] and \
                        q+t==table[0][1] and \
                        q+y==table[0][2] and \
                        w+r==table[1][0] and \
                        w+t==table[1][1] and \
                        w+y==table[1][2] and \
                        e+r==table[2][0] and \
                        e+t==table[2][1] and \
                        e+y==table[2][2]:
                            print('Yes')
                            exit()
print('No')

Fixed submission:
# coding: utf-8
data=[list(map(int,input().split())) for i in range(3)]
for i in range(101):
    for j in range(101):
        for k in range(101):
            for w in range(3):
                if not (data[0][w]-i==data[1][w]-j==data[2][w]-k):
                    break
            else:
                print('Yes')
                exit()
print('No')
Buggy python submission (verdict: Runtime Error):
print(''.join((lambda s:s[3]='8')(list(input()))))

Fixed submission:
# coding: utf-8
#map(int,input().split())
print('2018'+input()[4:])
Buggy python submission (verdict: Runtime Error):
n,h=map(int,input().split())
d=[]
mx=-1
sm=0
for i in range(n):
    a,b=map(int,input().split())
    mx=max(mx,a)
    d.append([b,a])
da=[]
for i in range(n):
    if d[i][0]>mx:
        da.append(d[i])
da=sorted(da,reverse=True)
i=0
for x in da:
    i+=1
    sm+=x[0]
    if sm>=h:
        print(i)
        exit()
da=sorted(da,key= lambda x:-x[1])
print(i+int((h-sm)/da[0][1]+0.5))



Fixed submission:
import heapq
import math
n,h=map(int,input().split())
used=[0 for i in range(n)]
que=[]
for i in range(n):
    a,b=map(int,input().split())
    heapq.heappush(que,(-b,-a,i))
count=0
while h>0:
    b,a,i=heapq.heappop(que)
    if used[i]:
        b=-b
        count+=math.ceil(h/b)
        break
    else:
        used[i]=1
        h+=b
        count+=1
        heapq.heappush(que,(a,b,i))
print(count)
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate
# Eratosthenes
def eratosthenes(n):
    prime_table = [False,False,True]+[False if i%2!=0 else True for i in range(n-2)]
    i=3
    while i*i<=n:
        if prime_table[i]:
            j=i*i
            while j<=n:
                prime_table[j]=False
                j+=i
        i+=2
    return prime_table

pt=eratosthenes(10001)
ok=[0 for i in range(10001)]
i=1
while i<10001:
    if pt[i] and pt[(i+1)//2]:
        ok[i]=1
    i+=2
ok=list(accumulate(ok))

q=int(input())
for i in range(q):
    l,r=map(int,input().split())
    print(ok[r]-ok[l-1])
    


Fixed submission:
from itertools import accumulate
# Eratosthenes
def eratosthenes(n):
    prime_table = [False,False,True]+[False if i%2!=0 else True for i in range(n-2)]
    i=3
    while i*i<=n:
        if prime_table[i]:
            j=i*i
            while j<=n:
                prime_table[j]=False
                j+=i
        i+=2
    return prime_table

pt=eratosthenes(100000)
ok=[0 for i in range(100000)]
i=1
while i<100000:
    if pt[i] and pt[(i+1)//2]:
        ok[i]=1
    i+=2
ok=list(accumulate(ok))

q=int(input())
for i in range(q):
    l,r=map(int,input().split())
    print(ok[r]-ok[l-1])
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
s=input()
d=[]
for c in s:
    if s.count(c)>=3:
        d.append(c)
if d[0]*3 in s:
    print('Yes')
else:
    print('No')

Fixed submission:
# coding: utf-8
a,b,c,d=input()
print('Yes' if a==b==c or b==c==d else 'No')
Buggy python submission (verdict: Runtime Error):
dic={}
for i in range(10001):
    dic[i]=0
input()
for n in map(int,input().split()):
    dic[n]+=1
m=0
for i in range(1,9999):
    m=max(m,dic[i]+dic[i+1]+dic[i+2])
print(m)


Fixed submission:
dic={}
for i in range(100002):
    dic[i]=0
input()
for n in map(int,input().split()):
    dic[n]+=1
m=0
for i in range(0,100000):
    m=max(m,dic[i]+dic[i+1]+dic[i+2])
print(m)
Buggy python submission (verdict: Runtime Error):
input()
data=list(map(int,input().split()))
count=0
for i in range(len(data)):
    if data[i]==i+1:
        data[i],data[i+1]=data[i+1],data[i]
        count+=1
print(count)

Fixed submission:
input()
data=list(map(int,input().split()))
count=0
for i in range(len(data)-1):
    if data[i]==i+1:
        data[i],data[i+1]=data[i+1],data[i]
        count+=1
if data[-1]==len(data):
    count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
from functools import reduce
n=int(input())
data=[]
for i in range(n):
    data.append(int(input()))
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
print(reduce(lcm,data))

Fixed submission:
def func(a,b):
    return a if b==0 else func(b,a%b)
n = int(input())
num = int(input())
for i in range(n-1):
    d = int(input())
    num = num*d//func(num,d)
print(num)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

n,k=map(int,input().split())
a=list(map(int,input().split()))
g=gcd(a[0],a[1])
mx=max(a)
for i in range(2,n):
    g=gcd(g,a[i])
if k%g==0 and k<=mx:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Fixed submission:
# coding: utf-8
# Your code here!
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

n,k=map(int,input().split())
a=list(map(int,input().split()))
if n==1:
    if k==a[0]:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
    exit()
g=gcd(a[0],a[1])
mx=max(a)
for i in range(2,n):
    g=gcd(g,a[i])
if k%g==0 and k<=mx:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
from heapq import heappush, heappop, heapify

n=int(input())
a,b=map(int,input().split())
G=[(a,b)]
que = []
for i in range(n-1):
    x,y=map(int,input().split())
    G.append((x,y))
    heappush(que,(min(abs(a-x),abs(b-y)),i+1))
used = [0 for i in range(n)]
used[0] = 1

ans = 0
while que:
    cv, v = heappop(que)
    if used[v]:
        continue
    used[v] = 1
    ans += cv
    for i in range(n):
        if used[i]:
            continue
        heappush(que, (min(abs(G[i][0]-G[v][0]),abs(G[i][1]-G[v][1])), i))
print(ans)

Fixed submission:
# coding: utf-8
# Your code here!
from heapq import heappush, heappop, heapify
n=int(input())
G=[[]for i in range(n)]
d=[]
for i in range(n):
    a,b=map(int,input().split())
    d.append((a,b,i))
d=sorted(d,key=lambda x:x[0])
for i in range(n-1):
    G[d[i][2]].append((d[i+1][0]-d[i][0],d[i+1][2]))
    G[d[i+1][2]].append((d[i+1][0]-d[i][0],d[i][2]))
d=sorted(d,key=lambda x:x[1])
for i in range(n-1):
    G[d[i][2]].append((d[i+1][1]-d[i][1],d[i+1][2]))
    G[d[i+1][2]].append((d[i+1][1]-d[i][1],d[i][2]))
used = [0 for i in range(n)]
que = [(c, w) for c, w in G[0]]
used[0] = 1
heapify(que)

ans = 0
while que:
    cv, v = heappop(que)
    if used[v]:
        continue
    used[v] = 1
    ans += cv
    for c, w in G[v]:
        if used[w]:
            continue
        heappush(que, (c, w))
print(ans)
Buggy python submission (verdict: Runtime Error):
data=[]
for i in range(int(input())):
    data.append(int(input()))
un=[num for num in data if num%10==0]
data=[num for num in data if num%10!=0]
if len(data)==0:
    print(0)
else:
    if sum(un+data)%10!=0:
        print(sum(un+data))
    else:
        print(sum(un+data)-min(data))

Fixed submission:
a,b=map(int,input().split())
print(a+b if a+b<10 else 'error')
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n=int(input())
d=[]
for i in range(n):
    d.append(int(input()))
r=0
for i in range(1,n+1):
    for j in list(itertools.combinations(d,i)):
        x=sum(j)
        if r<x and x%10!=0:
            r=x
print(r)

Fixed submission:
data=[]
for i in range(int(input())):
    data.append(int(input()))
un=[num for num in data if num%10==0]
data=[num for num in data if num%10!=0]
if len(data)==0:
    print(0)
else:
    if sum(un+data)%10!=0:
        print(sum(un+data))
    else:
        print(sum(un+data)-min(data))

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n=int(input())
d=[]
for i in range(n):
    d.append(int(input()))
r=[0]
for i in range(1,n+1):
    for j in list(itertools.combinations(d,i)):
        r.append(sum(j))
print(sorted([i for i in r if i%10!=0]+[0])[-1])

Fixed submission:
data=[]
for i in range(int(input())):
    data.append(int(input()))
un=[num for num in data if num%10==0]
data=[num for num in data if num%10!=0]
if len(data)==0:
    print(0)
else:
    if sum(un+data)%10!=0:
        print(sum(un+data))
    else:
        print(sum(un+data)-min(data))
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
n=int(input())
data=list(map(int,input().split()))
ans=1
def check(index,v=0):
    global data
    global ans
    if index+1<len(data):
        if data[index]==data[index+1]:
            check(index+1,v)
        elif data[index]<data[index+1]:
            if v==1 or v==0:
                check(index+1,1)
            else:
                ans+=1
                check(index+1,0)
        else:
            if v==-1 or v==0:
                check(index+1,-1)
            else:
                ans+=1
                check(index+1,0)
check(0)
print(ans)

Fixed submission:
# coding: utf-8
n=int(input())
data=list(map(int,input().split()))
index=0
ans=1
v=0
while index<len(data):
    if index+1<len(data):
        if data[index]==data[index+1]:
            pass
        elif data[index]<data[index+1]:
            if v==1 or v==0:
                v=1
            else:
                ans+=1
                v=0
        else:
            if v==-1 or v==0:
                v=-1
            else:
                ans+=1
                v=0
    index+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
n,m=map(int,input().split())
v=[[0 for i in range(n)] for i in range(n)]
used=[[0 for i in range(n)] for i in range(n)]
cost_table=[[99999999 for i in range(n)] for i in range(n)]
for i in range(m):
    a,b,c=map(int,input().split())
    v[a-1][b-1]=1
    v[b-1][a-1]=1
    cost_table[a-1][b-1]=c
    cost_table[b-1][a-1]=c

init_cost_table=[]
for i in range(n):
    init_cost_table.append(cost_table[i][:])

for i in range(n):
    for j in range(n):
        for k in range(n):
            if cost_table[i][k]>cost_table[i][j]+cost_table[j][k]:
                cost_table[i][k]=cost_table[i][j]+cost_table[j][k]
    cost_table[i][i]=0

def Path(start,goal):
    cur = start;
    while cur != goal:
        for i in range(n):
            if (i != cur and init_cost_table[cur][i] + cost_table[i][goal] == cost_table[cur][goal]):
                used[cur][i]=1
                cur = i
                break

for i in range(n):
    for j in range(n):
        if i==j:
            continue
        Path(i,j)
ans=0
for i in range(n):
    ans+=sum(v[i])
for i in range(n):
    ans-=sum(used[i])
print(ans//2)



Fixed submission:
import sys

sys.setrecursionlimit(100000)
input=lambda : sys.stdin.readline().rstrip('\n')

n,m=map(int,input().split())
g=[[]for i in range(n)]
s=set()
for i in range(m):
    a,b,c=map(int,input().split())
    g[a-1].append((c,b-1))
    g[b-1].append((c,a-1))
    if a>b:
        a,b=b,a
    s.add((a-1,b-1))

def dijkstra(g,st,s):
    from heapq import heappush, heappop, heapify
    inf=10**18
    dist=[inf for i in range(len(g))]
    visited=[False for i in range(len(g))]
    dist[st]=0
    que=[]
    heappush(que,(0,st,-1))
    while que:
        c,v,past=heappop(que)
        if visited[v]:
            continue
        visited[v]=True
        try:
            s.remove((v,past) if v<past else (past,v))
        except:
            pass
        for x in g[v]:
            tmp=x[0]+c
            if tmp<dist[x[1]] and not visited[x[1]]:
                dist[x[1]]=tmp
                heappush(que,(tmp,x[1],v))

for i in range(n):
    dijkstra(g,i,s)
print(len(s))
Buggy python submission (verdict: Time Limit Exceeded):
# coding : utf-8
n=int(input())
p=1 #a/b
x,y=1,1
for i in range(n):
    a,b=map(int,input().split())
    while p != a/b:
        if p < a/b:
            x+=1
        else:
            y+=1
        p=x/y
print(x+y)



Fixed submission:
from decimal import *
n=int(input())
log=[]
H=[]
for i in range(n):
    log.append(tuple(map(int,input().split())))
t,a=1,1
for x,y in log:
    nxt=max(t//x + (1 if t%x else 0),a//y + (1 if a%y else 0))
    t=x*nxt
    a=y*nxt
print(t+a)
Buggy python submission (verdict: Runtime Error):
# coding : utf-8
s=list(map(lambda c:ord(c)-ord('a'),input()))
k=int(input())
for i in range(len(s)):
    if 26-s[i]<=k:
        k-=(26-s[i])
        s[i]=0
s[-1]+=k
for n in s:
    print(chr(ord('a')+n),end='')
print()


Fixed submission:
# coding : utf-8
s=list(map(lambda c:ord(c)-ord('a'),input()))
k=int(input())
for i in range(len(s)):
    if 26-s[i]<=k and s[i]!=0:
        k-=(26-s[i])
        s[i]=0
s[-1]=(s[-1]+k)%26
for n in s:
    print(chr(ord('a')+n),end='')
print()
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
n=int(input().split())
a=0
for i in range(1,n+1):
    a+=i
print(a)

Fixed submission:
# coding: utf-8
n=int(input())
a=0
for i in range(1,n+1):
    a+=i
print(a)
Buggy python submission (verdict: Runtime Error):
N = int(input())

for i in range(1, 10):
    if N % i == 0 and N / i <= 9:
        print('Yes')
        exit(0)
print('No')


Fixed submission:
A, B = map(int, input().split())

if 1 <= A <= 9 and 1 <= B <= 9:
    print(A*B)
else:
    print('-1')
Buggy python submission (verdict: Runtime Error):
N = int(input())

for i in range(1, 10):
    if N % i == 0 and N / i <= 9:
        print('Yes')
        exit(1)
print('No')


Fixed submission:
N = int(input())

for i in range(1, 10):
    if N % i == 0 and N / i <= 9:
        print('Yes')
        exit()
print('No')
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = list(map(int, input().split()))
A = np.array(A)
B = np.array([1]*N)
indices = [*range(len(A))]
sorted_indices = sorted(indices, key=lambda i: A[i])
#for i in range(1, N+1):
#    B.append(A.index(i)+1)
#print(B)
sorted_indices = sorted_indices + B

print(*sorted_indices)

Fixed submission:
#import numpy as np
N = int(input())
A = list(map(int, input().split()))
#A = np.array(A)
B = [0]*N
#indices = [*range(len(A))]
#sorted_indices = sorted(indices, key=lambda i: A[i])
#for i in range(1, N+1):
#    B.append(A.index(i)+1)
#print(B)
#sorted_indices = sorted_indices + B
for i in range(N):
    B[A[i]-1] = i + 1
print(*B)
#print(*sorted_indices)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
B = []
for i in range(1, N+1):
    B.append(A.index(i)+1)
#print(B)
print(*B)

Fixed submission:
#import numpy as np
N = int(input())
A = list(map(int, input().split()))
#A = np.array(A)
B = [0]*N
#indices = [*range(len(A))]
#sorted_indices = sorted(indices, key=lambda i: A[i])
#for i in range(1, N+1):
#    B.append(A.index(i)+1)
#print(B)
#sorted_indices = sorted_indices + B
for i in range(N):
    B[A[i]-1] = i + 1
print(*B)
#print(*sorted_indices)
Buggy python submission (verdict: Runtime Error):
S = input()
S.split()

N = len(S)

for i in range(N//2):
    if (S[i*2] == 'R' or S[i*2] == 'U' or S[i*2] == 'D') and \
            (S[i*2 + 1] == 'L' or S[i*2 + 1] == 'U' or S[i*2 + 1] == 'D'):
        continue
    else:
        print('No')
        exit(1)
if N%2 != 0:
    if S[N-1] == 'R' or S[N-1] == 'U' or S[N-1] == 'D':
        print('Yes')
    else:
        print('No')
        exit(1)
else:
    print('Yes')


Fixed submission:
S = input()
S.split()

N = len(S)

for i in range(N//2):
    if (S[i*2] == 'R' or S[i*2] == 'U' or S[i*2] == 'D') and \
            (S[i*2 + 1] == 'L' or S[i*2 + 1] == 'U' or S[i*2 + 1] == 'D'):
        continue
    else:
        print('No')
        exit(0)
if N%2 != 0:
    if S[N-1] == 'R' or S[N-1] == 'U' or S[N-1] == 'D':
        print('Yes')
    else:
        print('No')
        exit(0)
else:
    print('Yes')

Buggy python submission (verdict: Runtime Error):
S = input()
S.split()

N = len(S)

for i in range(N//2):
    if (S[i*2] == 'R' or S[i*2] == 'U' or S[i*2] == 'D') and \
            (S[i*2 + 1] == 'L' or S[i*2 + 1] == 'U' or S[i*2 + 1] == 'D'):
        continue
    else:
        print('No')
        exit(1)
if N%2 != 0:
    if S[N-1] == 'R' or S[N-1] == 'U' or S[N-1] == 'D':
        print('Yes')
    else:
        print('No')
        exit(1)
else:
    print('Yes')


Fixed submission:
S = input()
S.split()

N = len(S)

for i in range(N//2):
    if (S[i*2] == 'R' or S[i*2] == 'U' or S[i*2] == 'D') and \
            (S[i*2 + 1] == 'L' or S[i*2 + 1] == 'U' or S[i*2 + 1] == 'D'):
        continue
    else:
        print('No')
        exit(0)
if N%2 != 0:
    if S[N-1] == 'R' or S[N-1] == 'U' or S[N-1] == 'D':
        print('Yes')
    else:
        print('No')
        exit(0)
else:
    print('Yes')

Buggy python submission (verdict: Runtime Error):
S = input()
S.split()

N = len(S)
cnt = 0
#odd_S = S[1::2]
#even_S = S[0::2]
for i in range(N//2):
    if (S[i*2] == 'R' or S[i*2] == 'U' or S[i*2] == 'D') and \
            (S[i*2 + 1] == 'L' or S[i*2 + 1] == 'U' or S[i*2 + 1] == 'D'):
        continue
    else:
        print('No')
        exit(1)
if N%2 != 0:
    if S[N-1] == 'R' or S[N-1] == 'U' or S[N-1] == 'D':
        print('Yes')
    else:
        print('No')
        exit(1)
else:
    print('Yes')


Fixed submission:
S = input()
S.split()

N = len(S)

for i in range(N//2):
    if (S[i*2] == 'R' or S[i*2] == 'U' or S[i*2] == 'D') and \
            (S[i*2 + 1] == 'L' or S[i*2 + 1] == 'U' or S[i*2 + 1] == 'D'):
        continue
    else:
        print('No')
        exit(0)
if N%2 != 0:
    if S[N-1] == 'R' or S[N-1] == 'U' or S[N-1] == 'D':
        print('Yes')
    else:
        print('No')
        exit(0)
else:
    print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(1, Q+1)]
for i in range(1,N+1):
    if A.count(i) > (Q-K):
        print('Yes')
    else:
        print('No')


Fixed submission:
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
Point = [K-Q] * N
for c in A:
    Point[c-1] += 1
for p in Point:
    if p > 0:
        print('Yes')
    else:
        print('No')
    #if A.count(i) > (Q-K):
    #    print('Yes')
    #else:
    #    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]
B = []
for i in range(N):
    temp = A[i]
    A[i] = -999
    print(max(A))
    A[i] = temp


Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
B = sorted(A)

for i in range(N):
    if B[-1] == A[i]:
        print(B[-2])
    else:
        print(B[-1])
Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())
temp = 2019

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

print(temp)

Fixed submission:
L, R = map(int, input().split())
temp = 2019

for i in range(L, R):
    for j in range(i+1, R+1):
        temp = min(temp, (i*j) % 2019)
        if (i*j) % 2019 == 0:
            print(temp)
            exit(0)
print(temp)