Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03836 (python)

Fixed submission:
sx,sy,tx,ty=map(int,input().split())
ans=[[] for _ in range(4)]

x=sx
y=sy

while y!=ty or x!=tx:
    if y<ty:
        y+=1
        ans[0].append("U")
        ans[1].append("D")
    elif x<tx:
        x+=1
        ans[0].append("R")
        ans[1].append("L")
       
x=sx-1
y=sy
ans[2].append("L")
ans[3].append("R")

while 1:
    if y<ty+1:
        y+=1
        ans[2].append("U")
        ans[3].append("D")
    elif x<tx:
        x+=1
        ans[2].append("R")
        ans[3].append("L")
    else:
        ans[2].append("D")
        ans[3].append("U")
        break

li=[]

for i in range(4):
    for j in ans[i]:
        li.append(j)

print(''.join(li))

#print(*ans[0],*ans[1],*ans[2],*ans[3],sep="")

Buggy submission (verdict: Runtime Error):
sx,sy,tx,ty=map(int,input().split())
ans=[[] for _ in range(4)]

x=sx
y=sy

while y!=ty or x!=tx:
    if y<ty:
        y+=1
        ans[0].append("U")
        ans[1].append("D")
    elif x<tx:
        x+=1
        ans[0].append("R")
        ans[1].append("L")
       
x=sx-1
y=sy
ans[2].append("L")
ans[3].append("R")

while 1:
    if y<ty+1:
        y+=1
        ans[2].append("U")
        ans[3].append("D")
    elif x<tx:
        x+=1
        ans[2].append("R")
        ans[3].append("L")
    else:
        ans[2].append("D")
        ans[3].append("U")
        break


print(*ans[0],*ans[1],*ans[2],*ans[3],sep="")

Buggy submission (verdict: Runtime Error):
sx,sy,tx,ty=map(int,input().split())
ans=[[] for _ in range(4)]

x=sx
y=sy

while y!=ty or x!=tx:
    if y<ty:
        y+=1
        ans[0].append("U")
        ans[1].append("D")
    elif x<tx:
        x+=1
        ans[0].append("R")
        ans[1].append("L")
       
x=sx-1
y=sy
ans[2].append("L")
ans[3].append("R")

while 1:
    if y<ty+1:
        y+=1
        ans[2].append("U")
        ans[3].append("D")
    elif x<tx:
        x+=1
        ans[2].append("R")
        ans[3].append("L")
    else:
        ans[2].append("D")
        ans[3].append("U")
        break


print(*ans[0],*ans[1],*ans[2],*ans[3],sep="")
print()
Problem p02678 (python)

Fixed submission:
from collections import deque
 
N,M=map(int,input().split())
 
graph=[[]for _ in range(N+1)]
 
for _ in range(M):
    A,B=map(int,input().split())
    graph[A].append(B)
    graph[B].append(A)
 
dist=[-1]*(N+1)
dist[0]=0
dist[1]=0
 
D=deque()
D.append(1)
 
while D:
    V=D.popleft()
    for i in graph[V]:
        if dist[i]!=-1:
            continue
        dist[i]=V
        D.append(i)
 
print('Yes')
for j in dist[2:]:
    print(j)

Buggy submission (verdict: Runtime Error):
from collections import deque
INF = 10000000
N, M = map(int, input().split())
# 隣接リストを作成する
dist = [INF for _ in range(M)]
pre = [-1 for _ in range(M)]
to = [[] for _ in range(100005)] 

# 隣接リスト：to[v]の中にはvに隣接している要素が入っている
for i in range(M):
    a, b = map(int, input().split())
    a = a - 1
    b = b - 1
    to[a].append(b)
    to[b].append(a)

queue = deque()
dist[0] = 0
queue.append(0)
while(len(queue) != 0):
    v = queue.popleft()
    for u in to[v]:
        # もう値が設定されていれば更新しない
        if (dist[u] != INF):
            continue
        dist[u] = dist[v] + 1
        pre[u] = v
        queue.append(u)

print("Yes")
for i in range(N):
    if (i == 0):
        continue
    ans = pre[i]
    ans += 1
    print(ans)
Problem p02714 (python)

Fixed submission:
n=int(input())
s=input()
c=s.count
a=c('R')*c('G')*c('B')
for i in range(n):
  for j in range(i+2,n,2):
    if s[i]!=s[i+j>>1]!=s[j]!=s[i]:
      a-=1
print(a)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
R = [i+1 for i in range(N) if S[i] == 'R']
G = [i+1 for i in range(N) if S[i] == 'G']
B = [i+1 for i in range(N) if S[i] == 'B']

len_r = len(R)
len_g = len(G)
len_b = len(B)

if len_r > len_g and len_r > len_b:
    X = G
    Y = B
    Z = R
elif len_g > len_r and len_g > len_b:
    X = R
    Y = B
    Z = G
elif len_b > len_g and len_b > len_r:
    X = G
    Y = R
    Z = B

ans = 0

for r in X:
    for g in Y:
        tmp = 0
        if r < g:
            a = r
            b = g
        else:
            a = g
            b = r
        i = b-a
        if a-i in Z:
            tmp+=1
        if b+i in Z:
            tmp+=1
        if a+(i/2) == b -(i/2) and a+(i/2) in Z:
            tmp += 1
        ans += len(Z) - tmp
print(ans)
Problem p02995 (python)

Fixed submission:
from fractions import gcd

"""

+ その範囲の6の倍数の数
  これはBまでの倍数の数からAまでの倍数の数を引く
+ その範囲の8の倍数の数
- その範囲の48の倍数の数
で答えが求まる

"""

def v_count(n, start, end):
  a = (start - 1) // n
  b = end // n
  return b - a

A, B, C, D = list(map(lambda x: int(x), input().split()))

all_count = B - A + 1

c_count = v_count(C, A, B)
d_count = v_count(D, A, B)
min_cd = (C * D) // gcd(C, D)
cd_count = v_count(min_cd, A, B)

print(all_count - c_count - d_count + cd_count)

Buggy submission (verdict: Runtime Error):
import numpy

"""

+ その範囲の6の倍数の数
+ その範囲の8の倍数の数
- その範囲の48の倍数の数
で答えが求まる

"""

def v_count(n, start, end):
  start_pop = start % n
  start = start + (n - start_pop)
  return int((end - start) / n) + 1

A, B, C, D = list(map(lambda x: int(x), input().split()))

all_count = B - A + 1

c_count = v_count(C, A, B)
d_count = v_count(D, A, B)
min_cd = numpy.lcm(C, D)
cd_count = v_count(min_cd, A, B)

print(all_count - c_count - d_count + cd_count)
Problem p03244 (python)

Fixed submission:
from collections import Counter

N = int(input())
items = list(map(int, input().split()))

# 偶数列と奇数列に分ける
even_num = items[::2]
odd_num = items[1::2]

# それらの配列で一番数が多いものを判定、それに合わせる
dev = Counter(even_num).most_common(2)
dod = Counter(odd_num).most_common(2)

if dev[0][0] == dod[0][0] :
    if len(dev) == len(dod) == 1 :
        print(N//2)
    elif len(dev) < len(dod) :
        print(N//2 - dod[1][1])
    elif len(dev) > len(dod) :
        print(N//2 - dev[1][1])
    else :
        print(N - max(dod[1][1] + dev[0][1], dod[0][1] + dev[1][1]))
else :
    print(N - dod[0][1]- dev[0][1])

Buggy submission (verdict: Runtime Error):
import collections

N = int(input())
items = list(map(int, input().split()))

# 偶数列と奇数列に分ける
even_num = items[::2]
odd_num = items[1::2]

# それらの配列で一番数が多いものを判定、それに合わせる
dev = Counter(even_num).most_common(2)
dod = Counter(odd_num).most_common(2)

if dev[0][0] == dod[0][0] :
    if len(dev) == len(dod) == 1 :
        print(N//2)
    elif len(dev) < len(dod) :
        print(N//2 - dod[1][1])
    elif len(dev) > len(dod) :
        print(N//2 - dev[1][1])
    else :
        print(N - max(dod[1][1] + dev[0][1], dod[0][1] + dev[1][1]))
else :
    print(N - dod[0][1]- dev[0][1])
Problem p03353 (python)

Fixed submission:
S=input()
K=int(input())
l = []
for alpha in [chr(i) for i in range(97, 97+26)]:
  indexs = [k for k, v in enumerate(list(S)) if v == alpha]
  for index in indexs:
    for j in range(index,min(index+6,len(S)+1)):
      sub_s = S[index:j]
      l.append(sub_s)
  l = sorted(list(set(l)))
  if '' in l:
    l.remove('')
  if len(l) >= K:
    break
print(l[K-1])

Buggy submission (verdict: Runtime Error):
S=input()
K=int(input())
l = []
for i in range(len(S)):
  for j in range(i,len(S)):
    sub_s = S[i:j]
    l.append(sub_s)
ans = sorted(list(set(l)))
ans.remove('')
print(ans[K-1])
Problem p03485 (python)

Fixed submission:
a, b = map(int, input().split())
print((a + b + 1) // 2)

Buggy submission (verdict: Runtime Error):
import math
import sys


def dudge_answer(a, b):
    ave = (a+b)/2
    return math.ceil(ave)


print(dudge_answer(a, b))

Buggy submission (verdict: Runtime Error):
import math
import sys


def dudge_answer(a, b):
    ave = (a+b)/2
    return math.ceil(ave)


print(dudge_answer(float(sys.argv[1]), float(sys.argv[2])))

Buggy submission (verdict: Runtime Error):
import math
import sys


def dudge_answer(a, b):
    ave = (a+b)/2
    return math.ceil(ave)


print(dudge_answer(sys.argv[1], sys.argv[2]))
Problem p03854 (python)

Fixed submission:
# dream = list(reversed('dream'))
# dreamer = list(reversed('dreamer'))
# erase = list(reversed('erase'))
# eraser = list(reversed('eraser'))

# def check(string):
#   l = len(string)

#   if l == 0:
#     return True
  
#   if l < 5:
#     return False

#   if string[0:5] == dream:
#     return check(string[5:])
#   if l >= 7 and string[0:7] == dreamer:
#     return check(string[7:])
#   if string[0:5] == erase:
#     return check(string[5:])
#   if l >= 6 and string[0:6] == eraser:
#     return check(string[6:])
      
#   return False

# S = input()
# S = list(reversed(S))
# if check(S):
#   print("YES")
# else:
#   print("NO")

s = input()
 
while len(s) > 4:
    if s[-5:] == 'dream':
        s = s[:-5]
    elif s[-7:] == 'dreamer':
        s = s[:-7]
    elif s[-5:] == 'erase':
        s = s[:-5]
    elif s[-6:] == 'eraser':
        s = s[:-6]
    else:
        break
 
print('NO' if len(s) > 0 else 'YES')

Buggy submission (verdict: Runtime Error):
def check(string):
  l = len(string)

  if l == 0:
    return True
  
  if l < 5:
    return False

  if string[-5:] == 'dream':
    return check(string[:-5])
  if l >= 7 and string[-7:] == 'dreamer':
    return check(string[:-7])
  if string[-5:] == 'erase':
    return check(string[:-5])
  if l >= 6 and string[-6:] == 'eraser':
    return check(string[:-6])
      
  return False

S = input()
if check(S):
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
def check(string):
  l = len(string)

  if l == 0:
    return True
  
  if l < 5:
    return False

  if string[0:5] == 'dream':
    if check(string[5:]):
      return True
    if l >= 7 and string[0:7] == 'dreamer':
      if check(string[7:]):
        return True
  elif string[0:5] == 'erase':
    if check(string[5:]):
      return True
    if l >= 6 and string[0:6] == 'eraser':
      if check(string[6:]):
        return True
  
  return False

S = input()
if check(S):
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
patterns = ['dream', 'dreamer' , 'erase', 'eraser'] 

def check(string):
  l = len(string)

  if l == 0:
    return True
  
  if l < 5:
    return False

  if string[0:5] == 'dream':
    if check(string[5:]):
      return True
    if l >= 7 and check(string[7:]):
      return True
  elif string[0:5] == 'erase':
    if check(string[5:]):
      return True
    if l >= 6 and check(string[6:]):
      return True
  else:
    return False
  
  return False

S = input()
if check(S):
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
patterns = ['dream', 'dreamer' , 'erase', 'eraser'] 

def check(string):
  if len(string) == 0:
    return True
  if string[0:5] == 'dream':
    if check(string[5:]):
      return True
    if check(string[7:]):
      return True
  elif string[0:5] == 'erase':
    if check(string[5:]):
      return True
    if check(string[6:]):
      return True
  else:
    return False
  
  return False

S = input()
if check(S):
  print("YES")
else:
  print("NO")
Problem p03086 (python)

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 submission (verdict: Runtime Error):
import re
S=input()
match=re.findall(r'[AGCT]+',S)
print(max(len(s) for s in match))
Problem p03087 (python)

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 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]
Problem p03128 (python)

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 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)

Buggy 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)
Problem p03141 (python)

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 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)
Problem p03148 (python)

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 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)
Problem p03157 (python)

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 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)
Problem p03213 (python)

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 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)
Problem p03215 (python)

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 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)
'''
Problem p03231 (python)

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 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)
Problem p03281 (python)

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 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)])
Problem p03285 (python)

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 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')
Problem p03304 (python)

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 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)
Problem p03337 (python)

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

h=int(data[0])
i=int(data[1])

c=h+i
if h-i>c: c=h-i
if h*i>c: c=h*i

print (c)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
cur=A[0]
ans=0
rp=1

for lp in range(N):
 while rp<N and cur & A[rp]==0:
  cur+=A[rp]
  rp+=1
 ans+=rp-lp
 cur-=A[lp]

print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
cur=A[0]
ans=0
rp=1

for lp in range(N):
 while rp<N and cur & A[rp]==0:
  cur+=A[rp]
  rp+=1
 ans+=rp-lp
 cur-=A[lp]

print(ans)