Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N,Q=map(int,input().split())
s=input()
commands=[input().split() for _ in range(Q)]

def move(i):
  k=i
  if k==-1 or k==N:
    return k
  for t,d in commands:
    if s[k]==t:
      if d=='R':
        k+=1
      else:
        k-=1
    if k==-1 or k==N:
      return k
  return k

#left search
low=0
high=N

##左にはみ出る一番右の位置→left
left=(low+high)//2

while(True):
  vanish=False
  if move(left)==-1:
    vanish=True
  if low==high:
    if vanish:
      left=low
    else:
      left=low-1
    break
  if vanish:
    low=left+1
  else:
    high=left-1
  left=(low+high)//2

#右にはみ出る一番左の位置
low=0
high=N
right=(low+high)//2
while(True):
  vanish=False
  if move(right)==N:
    vanish=True
  if low==high:
    if vanish:
      right=low
    else:
      right=low+1
    break
  if vanish:
    high=right-1
  else:
    low=right+1
  right=(low+high)//2
print(right-left-1)
'''
from collections import Counter

N,Q=map(int,input().split())
s=input()
moji={}
for i in range(Q):
  t,d=input().split()
  moji.setdefault(t,[0,0,0])
  if d=='L':
    moji[t][0]-=1
  else:
    moji[t][0]+=1
  #rightmax
  if moji[t][0]>moji[t][1]:
    moji[t][1]=moji[t][0]
  #leftmax
  if moji[t][0]<moji[t][2]:
    moji[t][2]=moji[t][0]

answer=0
for i in range(N):
  key=s[i]
  if moji[s[i]][1]+i>N-1 or i+moji[s[i]][2]<0:
    answer+=1
print(moji)
print(answer)
'''


Fixed submission:
N,Q=map(int,input().split())
s=input()
commands=[input().split() for _ in range(Q)]

def move(i):
  k=i
  if k==-1 or k==N:
    return k
  for t,d in commands:
    #print(t,d,k)
    if s[k]==t:
      if d=='R':
        k+=1
      else:
        k-=1
    if k==-1 or k==N:
      return k
  return k

#left search
low=0
high=N

##左にはみ出る一番右の位置→left
left=(low+high)//2

while(low<=high):
  vanish=False
  if move(left)==-1:
    vanish=True
  if low==high:
    if vanish:
      left=low
    else:
      left=low-1
    break
  if vanish:
    low=left+1
  else:
    high=left-1
  left=(low+high)//2
  if left>high:
    left=high
    break
#print(left)
#右にはみ出る一番左の位置
low=0
high=N
right=(low+high)//2
while(low<=high):
  vanish=False
  if move(right)==N:
    vanish=True
  if low==high:
    if vanish:
      right=low
    else:
      right=low+1
    break
  if vanish:
    high=right-1
  else:
    low=right+1
  right=(low+high)//2
  if right<low:
    right=low
    break
#print(right)
print(right-left-1)
'''
from collections import Counter

N,Q=map(int,input().split())
s=input()
moji={}
for i in range(Q):
  t,d=input().split()
  moji.setdefault(t,[0,0,0])
  if d=='L':
    moji[t][0]-=1
  else:
    moji[t][0]+=1
  #rightmax
  if moji[t][0]>moji[t][1]:
    moji[t][1]=moji[t][0]
  #leftmax
  if moji[t][0]<moji[t][2]:
    moji[t][2]=moji[t][0]

answer=0
for i in range(N):
  key=s[i]
  if moji[s[i]][1]+i>N-1 or i+moji[s[i]][2]<0:
    answer+=1
print(moji)
print(answer)
'''
Buggy python submission (verdict: Runtime Error):
import re
S=input()
match=re.findall(r'[AGCT]+',S)
print(max(len(s) for s in match))

Fixed submission:
import re
S=input()
match=re.findall(r'[AGCT]+',S)
if len(match)==0:
  print(0)
else:
  print(max(len(s) for s in match))
Buggy python submission (verdict: Runtime Error):
N,Q=map(int,input().split())

S=input()

ACDP=[0]*N
Aflag=0
ACcount=0
for i in range(len(S)):
  if S[i]=='A':
    Aflag=1
  else:
    Aflag=0
  if S[i]=='C' and Aflag==1:
    ACcount+=1
  ACDP[i]=ACcount
print(ACDP)

for _ in range(Q):
  start,end=map(int,input().split())
  print(ACDP[end-1]-ACDP[start-1]

Fixed submission:
N,Q=map(int,input().split())
 
S=input()
 
ACDP=[0]*N
Aflag=0
ACcount=0
for i in range(len(S)):
  if S[i]=='C' and Aflag==1:
    ACcount+=1
  if S[i]=='A':
    Aflag=1
  else:
    Aflag=0
  ACDP[i]=ACcount
#print(ACDP)
 
for _ in range(Q):
  start,end=map(int,input().split())
  print(ACDP[end-1]-ACDP[start-1])
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())

A=list(map(int,input().split()))
A.sort(reverse=True)
honsuu=[0,2,5,5,4,5,6,3,7,6]

def ketadp(N,M,A):
  dp=[0]*(N+1)
  for i in range(N):
    for j in A:
      if (i+1-honsuu[j])==0 or (i+1-honsuu[j]>0 and dp[i+1-honsuu[j]]!=0):
        dp[i+1]=max(dp[i+1],dp[i+1-honsuu[j]]+1)
  return dp
  

ans=""
keta=ketadp(N,M,A)
remain=keta[N]
match=N
#print(keta)

while(match>0):
  for i in A:
    #print(i,match,remain,keta[match-honsuu[i]])
    if(keta[match-honsuu[i]]==remain-1) and not (match-honsuu[i]!=0 and remain==1):
      ans+=str(i)
      remain-=1
      match-=honsuu[i]
      break;
print(ans)

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

A=list(map(int,input().split()))
A.sort(reverse=True)
honsuu=[0,2,5,5,4,5,6,3,7,6]

def ketadp(N,M,A):
  dp=[0]*(N+1)
  for i in range(N):
    for j in A:
      if (i+1-honsuu[j])==0 or (i+1-honsuu[j]>0 and dp[i+1-honsuu[j]]!=0):
        dp[i+1]=max(dp[i+1],dp[i+1-honsuu[j]]+1)
  return dp
  

ans=""
keta=ketadp(N,M,A)
remain=keta[N]
match=N
#print(keta)

while(match>0):
  for i in A:
    #print(i,match,remain,keta[match-honsuu[i]])
    if match-honsuu[i]<0:
      continue;
    if(keta[match-honsuu[i]]==remain-1) and not (match-honsuu[i]!=0 and remain==1):
      ans+=str(i)
      remain-=1
      match-=honsuu[i]
      break;
print(ans)

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())

A=list(map(int,input().split()))
A.sort(reverse=True)
honsuu=[0,2,5,5,4,5,6,3,7,6]

def ketadp(N,M,A):
  dp=[0]*(N+1)
  for i in range(N):
    for j in A:
      if (i+1-honsuu[j])==0 or (i+1-honsuu[j]>0 and dp[i+1-honsuu[j]]!=0):
        dp[i+1]=max(dp[i+1],dp[i+1-honsuu[j]]+1)
  return dp
  

ans=""
keta=ketadp(N,M,A)
remain=keta[N]
match=N
#print(A)

while(match>0):
  for i in A:
    #print(i,match,remain,keta[match-honsuu[i]])
    if(keta[match-honsuu[i]]==remain-1):
      ans+=str(i)
      remain-=1
      match-=honsuu[i]
      break;
print(ans)  

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

A=list(map(int,input().split()))
A.sort(reverse=True)
honsuu=[0,2,5,5,4,5,6,3,7,6]

def ketadp(N,M,A):
  dp=[0]*(N+1)
  for i in range(N):
    for j in A:
      if (i+1-honsuu[j])==0 or (i+1-honsuu[j]>0 and dp[i+1-honsuu[j]]!=0):
        dp[i+1]=max(dp[i+1],dp[i+1-honsuu[j]]+1)
  return dp
  

ans=""
keta=ketadp(N,M,A)
remain=keta[N]
match=N
#print(keta)

while(match>0):
  for i in A:
    #print(i,match,remain,keta[match-honsuu[i]])
    if match-honsuu[i]<0:
      continue;
    if(keta[match-honsuu[i]]==remain-1) and not (match-honsuu[i]!=0 and remain==1):
      ans+=str(i)
      remain-=1
      match-=honsuu[i]
      break;
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())

Takahashi=[]
Aoki=[]

for i in range(N):
  A,B=map(int,input().split())
  if A>B:
    symbol='p'
  else:
    symbol='m'
  Takahashi.append((abs(A-B),B,i,A))
  Aoki.append((abs(B-A),A,i,B))

Takahashi=sorted(Takahashi,key=lambda x: (x[0],x[1]),reverse=True)
Aoki=sorted(Aoki,key=lambda x: (x[0],x[1]),reverse=True)

#print(Takahashi)

turn=0
Asum=0
Bsum=0
while Takahashi:
  if turn%2==0:
    Asum+=Takahashi[0][3]
    index=Takahashi[0][2]
    Takahashi.pop(0)
    Aoki=[x for x in Aoki if x in Takahashi] 
  else:
    Bsum+=Aoki[0][3]
    index=Aoki[0][2]
    Aoki.pop(0)
    Takahashi=[x for x in Takahashi if x in Aoki]
    
    
  turn+=1
  #print(Takahashi)
  #print(Aoki)
print(Asum-Bsum) 

Fixed submission:
N=int(input())

goukei=[]

for i in range(N):
  A,B=map(int,input().split())
  goukei.append((A+B,A,B))

goukei.sort(key=lambda x:x[0],reverse=True)

Asum=0
Bsum=0
for i in range(N):
  if i%2==0:
    Asum+=goukei[i][1]
  else:
    Bsum+=goukei[i][2]
    
print(Asum-Bsum)
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())

td=sorted([tuple(map(int,input().split())) for _ in range(N)],key=lambda x:-x[1])
answer=0
#setを使うと参照や検索が早い
number=set()
afterpop=[]

for i in range(K):
  answer+=td[i][1]
  if td[i][0] not in number:
    number.append(td[i][0])
  else:
    afterpop.append(td[i][1])

answer+=(len(number))**2
    
index=K
tempanswer=answer
while index<N and afterpop:
  if td[i][0] not in number:
    number.append(td[i][0])
    tempanswer=tempanswer-afterpop.pop()-(len(number)-1)**2+(len(number))**2
    answer=max(tempanswer,answer)
  index+=1
                  
print(answer)


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

td=sorted([tuple(map(int,input().split())) for _ in range(N)],key=lambda x:-x[1])
answer=0
number=set()
afterpop=[]

for i in range(K):
  answer+=td[i][1]
  if td[i][0] not in number:
    number.add(td[i][0])
  else:
    afterpop.append(td[i][1])

answer+=(len(number))**2
    
index=K
tempanswer=answer
while index<N and afterpop:
  if td[index][0] not in number:
    number.add(td[index][0])
    tempanswer=tempanswer+td[index][1]-afterpop.pop()-(len(number)-1)**2+(len(number))**2
    answer=max(tempanswer,answer)
  index+=1
                  
print(answer)

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

td=sorted([tuple(map(int,input().split())) for _ in range(N)],key=lambda x:-x[1])
answer=0
number=[]
afterpop=[]

for i in range(K):
  answer+=td[i][1]
  if td[i][0] not in number:
    number.append(td[i][0])
  else:
    afterpop.append(td[i][1])

answer+=len(number)**2
    
index=K
tempanswer=answer
while index<N and afterpop:
  if td[index][0] not in number:
    number.append(td[index][0])
    tempanswer=tempanswer+td[index][1]-afterpop.pop()-(len(number)-1)**2+(len(number))**2
    answer=max(tempanswer,answer)
  index+=1
                  
print(answer)

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

td=sorted([tuple(map(int,input().split())) for _ in range(N)],key=lambda x:-x[1])
answer=0
number=set()
afterpop=[]

for i in range(K):
  answer+=td[i][1]
  if td[i][0] not in number:
    number.add(td[i][0])
  else:
    afterpop.append(td[i][1])

answer+=(len(number))**2
    
index=K
tempanswer=answer
while index<N and afterpop:
  if td[index][0] not in number:
    number.add(td[index][0])
    tempanswer=tempanswer+td[index][1]-afterpop.pop()-(len(number)-1)**2+(len(number))**2
    answer=max(tempanswer,answer)
  index+=1
                  
print(answer)
Buggy python submission (verdict: Runtime Error):
H,W=map(int,input().split())

board=[]
check=[[None]*W for i in range(H)]
answer=0

for i in range(H):
  S=list(input())
  board.append(S)
  
def dfs(i,j,color):
  if not (0<=i<H and 0<=j<W):
    return 0,0
  if board[i][j]==color:
    return 0,0
  if check[i][j]:
    return 0,0
  
  check[i][j]=True
  black,white=0,0
  
  if board[i][j]=='#':
  	black+=1
  else:
    white+=1
 
  tempblack,tempwhite=dfs(i+1,j,board[i][j])
  black+=tempblack
  white+=tempwhite
  
  tempblack,tempwhite=dfs(i-1,j,board[i][j])
  black+=tempblack
  white+=tempwhite
  
  tempblack,tempwhite=dfs(i,j+1,board[i][j])
  black+=tempblack
  white+=tempwhite

  tempblack,tempwhite=dfs(i,j-1,board[i][j])
  black+=tempblack
  white+=tempwhite
  return black,white

for i in range(H):
  for j in range(W):
    black,white=dfs(i,j,"!")
    answer+=black*white
print(answer)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

H,W=map(int,input().split())

board=[]
check=[[None]*W for i in range(H)]
answer=0

for i in range(H):
  S=list(input())
  board.append(S)
  
def dfs(i,j,color):
  if not (0<=i<H and 0<=j<W):
    return 0,0
  if board[i][j]==color:
    return 0,0
  if check[i][j]:
    return 0,0
  
  check[i][j]=True
  black,white=0,0
  
  if board[i][j]=='#':
  	black+=1
  else:
    white+=1
 
  tempblack,tempwhite=dfs(i+1,j,board[i][j])
  black+=tempblack
  white+=tempwhite
  
  tempblack,tempwhite=dfs(i-1,j,board[i][j])
  black+=tempblack
  white+=tempwhite
  
  tempblack,tempwhite=dfs(i,j+1,board[i][j])
  black+=tempblack
  white+=tempwhite

  tempblack,tempwhite=dfs(i,j-1,board[i][j])
  black+=tempblack
  white+=tempwhite
  return black,white

for i in range(H):
  for j in range(W):
    black,white=dfs(i,j,"!")
    answer+=black*white
print(answer)
Buggy python submission (verdict: Runtime Error):
from collections import Counter

def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    if x!=1:
      retlist.append(x)
    return retlist

N=int(input())

cnt=Counter()
for i in range(N):
  a=get_factors(i+1)
  acounter=Counter(a)
  cnt=cnt+acounter
values,counts=zip(*cnt.most_common())
ans=0
five=0
three=0
sevfou=0
twofou=0
fourteen=0
for c in counts:
  if c>=74:
    sevfou+=1
  if c>=24:
    twofou+=1
  if c>=14:
    fourteen+=1
  if c>=4:
    five+=1
  if c>=2:
    three+=1
ans+=(five*(five-1)/2)*(three-2)
ans+=(fourteen*(five-1))
ans+=(twofou*(three-1))
ans+=(sevfou)
print(ans)

Fixed submission:
from collections import Counter

def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    if x!=1:
      retlist.append(x)
    return retlist

N=int(input())

if N==1:
  print(0)
  exit()

cnt=Counter()
for i in range(N):
  a=get_factors(i+1)
  acounter=Counter(a)
  cnt=cnt+acounter
values,counts=zip(*cnt.most_common())
ans=0
five=0
three=0
sevfou=0
twofou=0
fourteen=0
for c in counts:
  if c>=74:
    sevfou+=1
  if c>=24:
    twofou+=1
  if c>=14:
    fourteen+=1
  if c>=4:
    five+=1
  if c>=2:
    three+=1
ans+=(five*(five-1)/2)*(three-2)
ans+=(fourteen*(five-1))
ans+=(twofou*(three-1))
ans+=(sevfou)
print(int(ans))
Buggy python submission (verdict: Runtime Error):
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N,K=map(int,input().split())

a=list(map(int,input().split()))

ruisekia=[]
keta=[0]*30
for i in range(N):
  temp=0
  for j in range(i,N):
    temp+=a[j]
    ruisekia.append(temp)
ruisekia.sort(reverse=True)

print(ruisekia)
for i in range(combinations_count(N,K)):
  for j in range(K):
    if ruisekia[i]==1:
      x=5

'''
for i in range(len(ruisekia)):
  tempo=ruisekia[i]
  while(tempo!=0):
    x=1
    count=0
    while(tempo>=x*2):
      x*=2
      count+=1
    keta[count]+=1
    tempo-=x
print(keta)
'''

Fixed submission:
N,K=map(int,input().split())
 
a=list(map(int,input().split()))
 
ruisekia=[]
keta=[0]*30
for i in range(N):
  temp=0
  for j in range(i,N):
    temp+=a[j]
    ruisekia.append(temp)
ruisekia.sort(reverse=True)
 
#print(ruisekia)
answer=0
for i in range(40,-1,-1):
  count=0
  ruiseki=[]
  for j in ruisekia:
    if j&(1<<i)==1<<i:
      count+=1
      ruiseki.append(j)
  if count>=K:
    answer+=2**i
    ruisekia=ruiseki

print(answer)
'''
for i in range(len(ruisekia)):
  tempo=ruisekia[i]
  while(tempo!=0):
    x=1
    count=0
    while(tempo>=x*2):
      x*=2
      count+=1
    keta[count]+=1
    tempo-=x
print(keta)
'''
Buggy python submission (verdict: Runtime Error):
import fractions

N,M=map(int,input().split())

S=list(input())
T=list(input())

def lcm(a,b):
  return (a*b)//fractions.gcd(a,b)

NM=lcm(N,M)

array=[0]*NM


Scount=0
for i in range(0,NM,NM//N):
  array[i]=S[Scount]
  Scount+=1
  #print(array)

Tcount=0

for j in range(0,NM,NM//M):
  
  if array[j]!=0 and array[j]!=T[Tcount]:
    print(-1)
    exit()
  else:
    array[j]=T[Tcount]
    Tcount+=1
  #print(array)
  
print(NM)

Fixed submission:
import fractions

N,M=map(int,input().split())

S=list(input())
T=list(input())

def lcm(a,b):
  return (a*b)//fractions.gcd(a,b)

NM=lcm(N,M)

#array=[0]*NM

battingS=[]
battingT=[]
#Scount=0
for i in range(0,N,NM//M):
  battingS.append(S[i])
  #Scount+=1
  #print(array)

Tcount=0

for j in range(0,M,NM//N):
  battingT.append(T[j])
  #Scount+=1
  '''
  if array[j]!=0 and array[j]!=T[Tcount]:
    print(-1)
    exit()
  else:
    array[j]=T[Tcount]
    Tcount+=1
  #print(array)
  '''

for i in range(len(battingS)):
  if battingS[i]!=battingT[i]:
    print(-1)
    exit()
#print(battingS,battingT)
print(NM)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
MOD=(10**9)+7
def trial_division(n):
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    tmp = int(n**0.5) + 2
    for num in range(2,tmp):
        count=0
        while n % num == 0:
            n //= num
            count+=1
        if count>0:
          factor.append(count)
    #リストが空ならそれは素数
    if not factor:
        return [1]
    elif n!=1:
        factor.append(1)
        return factor
    else:
        return factor
      
def combinations_count(n, r):
    if n==r:
      return 1
    re = combinations_count(n - 1, r) * n // (n - r)
    return re


factor=trial_division(M)

ans=1
for a in factor:
  ans*=combinations_count(a+N-1,a)
  ans%=MOD
print(ans)

Fixed submission:
from math import factorial

N,M=map(int,input().split())

if M==1:
  print(1)
  exit()
MOD=(10**9)+7
def trial_division(n):
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    tmp = int(n**0.5) + 2
    for num in range(2,tmp):
        count=0
        while n % num == 0:
            n //= num
            count+=1
        if count>0:
          factor.append(count)
    #リストが空ならそれは素数
    if not factor:
        return [1]
    elif n!=1:
        factor.append(1)
        return factor
    else:
        return factor


factor=trial_division(M)

ans=1
for a in factor:
  for i in range(a):
    ans*=N+i
  ans //= factorial(a)
  ans%=MOD

print(ans)
Buggy python submission (verdict: Runtime Error):
d=[0]*100

for i in range(3,200,2):
  count=0
  for j in range(1,i+1):
    if i%j==0:
      #print(i,j)
      count+=1
  d[int(i//2)]=d[int(i//2)-1]
  if count>=8:
    d[int(i//2)]+=1
    
N=int(input())
print(d[int(N//2)])

Fixed submission:
A=int(input())

answer=0
if A<=104:
  print(0)
  exit()
else:
  for i in range(105,A+1,2):
    count=0
    for j in range(1,i+1):
      if i%j==0:
        count+=1
    if count==8:
      answer+=1
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
N,M,Q=map(int,input().split())


Query=[]
answer=[[0]*N for i in range(N)]
for i in range(M):
  L,R=map(int,input().split())
  for j in range(1,L+1):
    for k in range(R,N+1):
      answer[j-1][k-1]+=1

for i in range(Q):
  p,q=map(int,input().split())
  print(answer[p-1][q-1])

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


Query=[]
answer=[[0]*N for i in range(N)]
for i in range(M):
  L,R=map(int,input().split())
  answer[N-L][R-1]+=1

for i in range(1,N):
  answer[0][i]+=answer[0][i-1]
  answer[i][0]+=answer[i-1][0]
  
for i in range(1,N):
  for j in range(1,N):
    answer[i][j]+=answer[i-1][j]
    answer[i][j]+=answer[i][j-1]
    answer[i][j]-=answer[i-1][j-1]
for i in range(Q):
  p,q=map(int,input().split())
  print(answer[N-p][q-1])
'''
for i in range(Q):
  answer=0
  Query=list(map(int,input().split()))
  for j in range(M):
    if train[j][0]>=Query[0] and train[j][1]<=Query[1]:
      answer+=1
  print(answer)
'''

Buggy python submission (verdict: Time Limit Exceeded):
N,M,Q=map(int,input().split())

train=[]
Query=[]
for i in range(M):
  train.append(list(map(int,input().split())))
for i in range(Q):
  answer=0
  Query=list(map(int,input().split()))
  for j in range(M):
    if train[j][0]>=Query[0] and train[j][1]<=Query[1]:
      answer+=1
  print(answer)
  

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


Query=[]
answer=[[0]*N for i in range(N)]
for i in range(M):
  L,R=map(int,input().split())
  answer[N-L][R-1]+=1

for i in range(1,N):
  answer[0][i]+=answer[0][i-1]
  answer[i][0]+=answer[i-1][0]
  
for i in range(1,N):
  for j in range(1,N):
    answer[i][j]+=answer[i-1][j]
    answer[i][j]+=answer[i][j-1]
    answer[i][j]-=answer[i-1][j-1]
for i in range(Q):
  p,q=map(int,input().split())
  print(answer[N-p][q-1])
'''
for i in range(Q):
  answer=0
  Query=list(map(int,input().split()))
  for j in range(M):
    if train[j][0]>=Query[0] and train[j][1]<=Query[1]:
      answer+=1
  print(answer)
'''
Buggy python submission (verdict: Runtime Error):
N=int(input())

if N%7==0 or N%4==0 or N%7==4 or N%4==7 N%11==0 or N%11==4 or N%11==7:
  print('Yes')
else:
  print('No')

Fixed submission:
N=int(input())

N4=N
N7=N
while(N4>=0):
  if N4%7==0:
    print('Yes')
    exit()
  N4-=4
while(N7>=0):
  if N7%4==0:
    print('Yes')
    exit()
  N7-=7
print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())

A=list(map(int,input().split()))

AmodM=[]
answer=0

for i in range(N):
  AmodM.append(A[i]%M)

for i in range(N):
  modlist=A[i]
  if modlist%M==0:
    answer+=1
  for j in range(i+1,N):
    modlist+=A[j]
    if modlist%M==0:
      answer+=1
print(answer)  

Fixed submission:
import collections
import math

N,M=map(int,input().split())

A=list(map(int,input().split()))

AmodM=[]
leftsummodM=[]
#rightsummodM=[]
#summodM=0
answer=0

for i in range(N):
  AmodM.append(A[i]%M)



leftmodcount=0
#rightmodcount=0
for i in range(N):
  leftmodcount+=AmodM[i]
  #rightmodcount+=AmodM[N-i-1]
  leftsummodM.append((leftmodcount)%M)
  #rightsummodM.append(rightmodcount)
  '''
  if leftmodcount%M==0:
    answer+=1
  if i!=N-1 and rightmodcount%M==0:
    answer+=1
  '''
count=collections.Counter(leftsummodM)

#print(count)

#0に関しては1個でも選べるので1個分多くカウントする
for k,v in count.items():
  if k==0:
    answer+=v*(v+1)//2
  else:
    answer+=(v-1)*v//2

print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
T=int(input())
 
Query=[]
for i in range(T):
  Query.append(list(map(int,input().split())))
 
for i in range(T):
  appear=[]
  appear.append(Query[i][0])
  while(True):
    if Query[i][0]%Query[i][1]>Query[i][2] or Query[i][0]<Query[i][1]:
      print('No')
      break;
    Query[i][0]=Query[i][0]%Query[i][1] #昼
    if Query[i][0] in appear:
      print('Yes')
      break;
    else:
      appear.append(Query[i][0])
    if Query[i][0]<=Query[i][2]: #夜
      Query[i][0]+=Query[i][3]

Fixed submission:
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
T=int(input())
 
Query=[]
for i in range(T):
  Query.append(list(map(int,input().split())))
 
for i in range(T):
  while(True):
    if Query[i][0]%Query[i][1]>Query[i][2] or Query[i][0]<Query[i][1] or Query[i][1]>Query[i][3]:
      print('No')
      break;
    G=gcd(Query[i][1],Query[i][3]) #この倍数分の増減のみ考えれば良い
    '''
    A,B,C,DがQuery[i]の0,1,2,3に対応
    BmodG,DmodGは0(GはB,Dの約数であるため)よりmodGの世界で個数の増減はない。昼の購入で0個減少。夜の仕入れで0個増加。
    つまり、初期個数をAmodGとすると、個数は一定
    出現する可能性のあるBは買う個数であり、B-Gを考えると、買いきれない個数で出現しうる最大の個数が求まる。
    但し、初期個数を考える必要がある。
    初期個数によってループする幅が一緒でも取りうる値は異なる。
    
    例：
    B=24,C=19,D=36 この時,G=12
    
    A=31の場合 AmodG(本来の個数)
    7(31)→7(7)→7(43)→7(19)→7(31)→...
    A=30の場合 AmodG(本来の個数)
    6(30)→6(6)→6(42)→6(18)→6(30)→...
    
    Bを超えない最大数について、初期個数を考慮すると、B-G+AmodGとなる。
    G>AmodGであるため、この数が購入数Bを超えることはない
    つまり、B-G+AmodG>CならばNo,そうでなければYes
    '''
    if Query[i][1]-G+Query[i][0]%G>Query[i][2]:
      print('No')
      break;
    else:
      print('Yes')
      break;
Buggy python submission (verdict: Runtime Error):
n,m,d=map(int,input().split())

#全パターンの平均を求める＝期待値を求めれば良い
#ある隣り合う数(a,b)の組について、全パターンはn^2

#d=0の時、隣り合う数の組は(a,a)でなければならない
if d=0:
  C=n

#d≠0の時、隣り合う組のパターンは(1,1+d),(2,2+d)...(n-d,n)のn-d通り
#逆に(d+1,1)....の時も成り立つ
if d!=0:
  C=2*(n-d)
  
#上の組のパターンがm-1個の組について成り立つ
print((m-1)*C//n**2)

Fixed submission:
n,m,d=map(int,input().split())
 
#全パターンの平均を求める＝期待値を求めれば良い
#ある隣り合う数(a,b)の組について、全パターンはn^2
 
#d=0の時、隣り合う数の組は(a,a)でなければならない
if d==0:
  C=n
 
#d≠0の時、隣り合う組のパターンは(1,1+d),(2,2+d)...(n-d,n)のn-d通り
#逆に(d+1,1)....の時も成り立つ
if d!=0:
  C=2*(n-d)
  
#上の組のパターンがm-1個の組について成り立つ
print((m-1)*C/(n**2))
Buggy python submission (verdict: Runtime Error):
N=int(input())

if N%==0:
  print(N)
else:
  print(2*N)

Fixed submission:
N=int(input())

if N%2==0:
  print(N)
else:
  print(2*N)