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

Fixed submission:
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

poi=[]
pon=[]
s=input().rstrip("\n")
for i in range(len(s)-1):
    if s[i:i+2] == "RL":
        poi.append(i)
    if s[i:i+2] == "LR":
        pon.append(i)

r=[]
l=[]
k=0
ans=[0]*len(s)
if pon!=[]:
    for i in range(pon[-1]+1):
        if (poi[k]-i)%2==0:#L
            ans[poi[k]]+=1
        else:
            ans[poi[k]+1]+=1
        #print(ans)
        if i==pon[k]:
            k+=1
    for i in range(pon[-1]+1,len(s)):
        if (poi[k]-i) % 2 == 0:  # L
            ans[poi[k]] += 1
        else:
            ans[poi[k]+1] += 1
else:
    for i in range(len(s)):
        if (poi[k]-i) % 2 == 0:  # L
            ans[poi[k]] += 1
        else:
            ans[poi[k]+1] += 1      
print(*ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

poi=[]
pon=[]
s=input().rstrip("\n")
for i in range(len(s)-1):
    if s[i:i+2] == "RL":
        poi.append(i)
    if s[i:i+2] == "LR":
        pon.append(i)

r=[]
l=[]
k=0
ans=[0]*len(s)
for i in range(pon[-1]+1):
    if (poi[k]-i)%2==0:#L
        ans[poi[k]]+=1
    else:
        ans[poi[k]+1]+=1
    #print(ans)
    if i==pon[k]:
        k+=1
for i in range(pon[-1]+1,len(s)):
    if (poi[k]-i) % 2 == 0:  # L
        ans[poi[k]] += 1
    else:
        ans[poi[k]+1] += 1

print(*ans)
Problem p02959 (python)

Fixed submission:
#n = int(input())
#L = list(map(int, input().split()))
import math
import sys
import heapq
import fractions
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0

for i in range(N):
    if B[i]>A[i]:
        if B[i] >= A[i+1]+A[i]:
            ans += A[i]+A[i+1]
            A[i+1] = 0
        else:
            A[i+1] -= B[i]-A[i]
            ans += B[i]
    else:
        ans += B[i]

print(ans)

Buggy submission (verdict: Runtime Error):
#n = int(input())
#L = list(map(int, input().split()))
import math
import sys
import heapq
import fractions
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0

for i in range(N):
    if A[i]>B[i]:
        if A[i] >= B[i+1]+B[i]:
            ans += B[i]+B[i+1]
            B[i+1] = 0
        else:
            B[i+1] -= A[i]-B[i]
            ans += A[i]
    else:
        ans += A[i]

print(ans)

Buggy submission (verdict: Runtime Error):
#n = int(input())
#L = list(map(int, input().split()))
import math
import sys
import heapq
import fractions
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0

for i in range(1,N):
    if A[i]>B[i]:
        if A[i] >= B[i+1]+B[i]:
            ans += B[i]+B[i+1]
            B[i+1] = 0
        else:
            B[i+1] -= A[i]-B[i]
            ans += A[i]
    else:
        ans += A[i]

print(ans)

Buggy submission (verdict: Runtime Error):

N = int(input())
A = input().split()
B = input().split()
for i in range(N+1):
    A[i] = int(A[i])
for i in range(N):
    B[i] = int(B[i])

Ans = 0

if (B[0]-A[0] > 0):
    if (B[0]-A[0] < A[1]):
        yojo = B[0]-A[0]
        Ans += A[0]
        chinpo = True
    else:
        yojo = B[1]
        Ans += A[0]
        chinpo = False
        #A[0]+for以下
else:
    yojo = 0
    Ans += B[0]
    chinpo = True
    #B[0]+for以下

for i in range(1,N-1):
    if chinpo:
        yoB = yojo + B[i]
        if yoB >= A[i]:
            yojo = yoB - A[i]
            Ans += A[i]
            if yojo >= A[i+1]:
                chinpo = False
        else:
            Ans += B[i]
            yojo = 0
    else:
        Ans += A[i]
        yojo = B[i]
        chinpo = True

if yojo > A[N]:
    Ans += A[N]
else:
    if yojo + B[N-1] > A[N]:
        Ans += A[N]
    else:
        Ans += yojo + B[N-1]

print(Ans)
Problem p03013 (python)

Fixed submission:
#import collections
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

fibo = [1, 1]
for i in range(1, 10**5+2):
    fibo.append(fibo[i]+fibo[i-1])

n,m=map(int, input().split())

a=[]
for i in range(m):
    a.append(int(input()))

flg=True
for i in range(m-1):
    if a[i]+1==a[i+1]:
        flg=False
        break

if not flg:
    print(0)

else:
    ans=1
    if m==1:
        print(fibo[a[0]-1]*fibo[n-a[0]-1] % (10**9+7))

    elif m==0:
        print((fibo[n]) % (10**9+7))

    else:
        for i in range(1,m):
            ans*=fibo[a[i]-a[i-1]-2]   
        print(ans*fibo[a[0]-1]*fibo[n-a[m-1]-1]%(10**9+7))

Buggy submission (verdict: Runtime Error):
#import collections
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''


n,m=map(int, input().split())
fibo = [1, 1]
for i in range(1, 10**5+1):
    fibo.append(fibo[i]+fibo[i-1])
#print(fibo)
a=[]
for i in range(m):
    a.append(int(input()))

flg=True
for i in range(m-1):
    if a[i]+1==a[i+1]:
        flg=False
        break
#print(a[0]==a[1],flg)
if not flg:
    print(0)
else:
    ans=1
    if m==1:
        #print(fibo[a[0]-1],fibo[n-a[0]-1])
        print(fibo[a[0]-1]*fibo[n-a[0]-1] % (10**9+7))
    else:
        for i in range(1,m):
            #print(a[i],a[i-1])
            #print(fibo[21])
            #print(fibo[a[i]-a[i-1]-1])
            ans*=fibo[a[i]-a[i-1]-2]
            print(ans % (10**9+7))

        #print(fibo[a[0]-1],fibo[n-a[m-1]-1],fibo[10])
        print(ans*fibo[a[0]-1]*fibo[n-a[m-1]-1]%(10**9+7))

Buggy submission (verdict: Runtime Error):
#import collections
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''


n,m=map(int, input().split())
fibo = [1, 1]
for i in range(1, 10**5+1):
    fibo.append(fibo[i]+fibo[i-1])
#print(fibo)
a=[]
for i in range(m):
    a.append(int(input()))

flg=True
for i in range(m-1):
    if a[i]+1==a[i+1]:
        flg=False
        break
#print(a[0]==a[1],flg)
if not flg:
    print(0)
else:
    ans=1
    if m==1:
        #print(fibo[a[0]-1],fibo[n-a[0]-1])
        print(fibo[a[0]-1]*fibo[n-a[0]-1] % (10**9+7))
    else:
        for i in range(1,m):
            #print(a[i],a[i-1])
            #print(fibo[21])
            #print(fibo[a[i]-a[i-1]-1])
            ans*=fibo[a[i]-a[i-1]-1]
            print(ans % (10**9+7))

        #print(fibo[a[0]-1],fibo[n-a[m-1]-1],fibo[10])
        print(ans*fibo[a[0]-1]*fibo[n-a[m-1]-1]%(10**9+7))
Problem p03127 (python)

Fixed submission:
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

import fractions
n=int(input())
a=list(map(int,input().split()))
for i in range(n-1):
    a[i+1]=fractions.gcd(a[i],a[i+1])
print(min(a))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

import math
n=int(input())
a=list(map(int,input().split()))
for i in range(n-1):
    a[i+1]=math.gcd(a[i],a[i+1])
print(min(a))
Problem p02580 (python)

Fixed submission:
def main():
    H, W, M = map(int, input().split())
    # H, W, M = (3 * 10 ** 5, 3 * 10 ** 5, 3 * 10 ** 5)

    row = [0] * (H + 1)
    row_set = [set() for _ in range(H+1)]
    column = [0] * (W + 1)
    column_set = [set() for _ in range(W+1)]
    # import random
    ms = []
    positions = set()
    for m in range(M):
        h, w = map(int, input().split())

        positions.add((h, w))
        # h, w = (random.randrange(3*10**5), random.randrange(3*10**5))
        row[h] += 1
        row_set[h].add(w)

        column[w] += 1
        column_set[w].add(h)



    max_rows = set()
    maxR = -1
    for i, v in enumerate(row[1:]):
        if v > maxR:
            max_rows = set()
            max_rows.add(i+1)
            maxR = v
        elif v == maxR:
            max_rows.add(i+1)


    max_cols = set()
    maxC = -1
    for i, v in enumerate(column[1:]):
        if v > maxC:
            max_cols = set()
            max_cols.add(i+1)
            maxC = v
        elif v == maxC:
            max_cols.add(i + 1)


    for y in max_rows:
        for x in max_cols:
            if not (y, x) in positions:
                print(maxR + maxC)
                exit()
    print(maxR + maxC - 1)
main()

Buggy submission (verdict: Runtime Error):
def main():
    H, W, M = map(int, input().split())
    # H, W, M = (3 * 10 ** 5, 3 * 10 ** 5, 3 * 10 ** 5)

    row = [0] * (H + 1)
    row_set = dict()
    column = [0] * (W + 1)
    column_set = dict()
    # import random

    for m in range(M):
        h, w = map(int, input().split())

        # h, w = (random.randrange(3*10**5), random.randrange(3*10**5))
        row[h] += 1
        if h in row_set:
            row_set[h].add(w)
        else:
            row_set.update({h: set({w})})

        column[w] += 1
        if w in column_set:
            column_set[w].add(h)
        else:
            column_set.update({w: set({h})})

    flatten_max_rows = []
    maxR = -1
    for i, v in enumerate(row[1:]):
        if v > maxR:
            flatten_max_rows = []
            if v != 0:
                flatten_max_rows += list(row_set[i+1])
            maxR = v
        elif v == maxR:
            flatten_max_rows += list(row_set[i+1])
    flatten_max_rows_set = set(flatten_max_rows)

    maxC = max(column)
    for i, v in enumerate(column[1:]):
        if v == maxC:
            if i+1 not in flatten_max_rows_set:
                print(maxR + maxC)
                exit()

    print(maxR + maxC - 1)
main()
Problem p02661 (python)

Fixed submission:
n = int(input())

aList = []
bList = []
for i in range(n):
    a, b = map(int, input().split())
    aList.append(a)
    bList.append(b)

aList.sort()
bList.sort()


if not n % 2 == 0:
    half = (n+1) // 2 - 1
    print(bList[half] - aList[half] + 1)
else:
    half = (n) // 2 - 1
    print(bList[half] + bList[half+1] - (aList[half] + aList[half+1]) + 1)

Buggy submission (verdict: Runtime Error):
n = int(input())

aList = []
bList = []
for i in range(n):
    a, b = map(int, input().split())
    aList.append(a)
    bList.append(b)

aList.sort()
bList.sort()

half = n // 2
if not n % 2 == 0:
    print(bList[half] - aList[half] + 1)
else:
    print(bList[half] + bList[half+1] - aList[half] + aList[half+1] + 1)
Problem p02688 (python)

Fixed submission:
def main():
    n,k=map(int,input().split())
    a=[0]*n
    for i in range(k):
        d=int(input())
        if d==1:
            a[int(input())-1]+=1
        else:
            tmp=list(map(int,input().split()))
            for j in tmp:
                a[j-1]+=1
    ans=0
    for i in range(n):
        if a[i]==0:
            ans+=1
    print(ans)

if __name__ =='__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n,k=map(int,input().split())
    a=[0]*n
    for i in range(k):
        d=int(input())
        tmp=input()
        for j in range(d):
            a[int(tmp[j*2])-1]+=1
    ans=0
    for i in range(n):
        if a[i]==0:
            ans+=1
    print(ans)

if __name__ =='__main__':
    main()
Problem p02847 (python)

Fixed submission:
s = input()
if s=='SUN':
  print(7)
elif s=='MON':
  print(6)
elif s=='TUE':
  print(5)
elif s=='WED':
  print(4)
elif s=='THU':
  print(3)
elif s=='FRI':
  print(2)
elif s=='SAT':
  print(1)

Buggy submission (verdict: Runtime Error):
a,b,x=map(int,input().split())
def an():
    if x>a*1e+9+b*10:
        print(int(1e+9))
        return
    i=int(1e+9)
    j=i
    max=int(1e+9)
    min=1
    while max-min>1:
        d=len(str(i))
        if a*i+b*d>x:
            max=i
        else:
            min=(i+j)//2
        i=(max+min)/2
    print(min)
an()

Buggy submission (verdict: Runtime Error):
a,b,x=map(int,input().split())
def an():
    if x>a*1e+9+b*10:
        print(int(1e+9))
        return
    i=int(1e+9)
    j=i
    cou=0
    while True:
        cou+=1
        if(cou>10000):break#整数除算で限界が来た時用
        d=len(str(i))
        if a*i+b*d>x:
            j=i
            i//=2
        elif a*i+b*d<x:
            i=(i+j)//2
        else:
            return
    for k in range(min(i,j),max(i,j)+1):
        d=len(str(k))
        if a*k+b*d==x:
            print(k)
            return
        if a*k+b*d>x:
            print(k-1)
            return
an()

Buggy submission (verdict: Runtime Error):
s = input()
if s=='SUN':
  print(7)
elif s='MON':
  print(6)
elif s=='TUE':
  print(5)
elif s=='WED':
  print(4)
elif s=='THU':
  print(3)
elif s=='FRI':
  print(2)
elif s=='SAT':
  print(1)

Buggy submission (verdict: Runtime Error):
s = input()
if s='SUN':
  print(7)
elif s='MON':
  print(6)
elif s='TUE':
  print(5)
elif s='WED':
  print(4)
elif s='THU':
  print(3)
elif s='FRI':
  print(2)
elif s='SAT':
  print(1)
Problem p02879 (python)

Fixed submission:
a,b = map(int, input().split())
ans=a*b
if a>=10 or b >=10:
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):

a,b = map(int, input().split())
ans=a*b
if:a>=10 or b >=10:
    print(-1)
else:
    print(ans)
Problem p02693 (python)

Fixed submission:
K = int(input())
S = input().split()
A = int(S[0])
B = int(S[1])

for i in range(A, B + 1):
    if i % K == 0:
        print("OK")
        exit()
print("NG")

Buggy submission (verdict: Runtime Error):
K = int(input())
A = int(input().split()[0])
B = int(input().split()[1])

for i in range(A, B + 1):
    if i % K == 0:
        print("OK")
        break
        exit()
print("NG")
Problem p02711 (python)

Fixed submission:
N = input()

if "7" in N:
    print("Yes")
else:
    print("No")

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

if "7" in N:
    print(Yes)
else:
    print(No)
Problem p02570 (python)

Fixed submission:
d,t,s=map(int,input().split())
print("Yes" if t*s>=d else "No")

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
li=[]
ans=0
if m!=0: 
    for i in range(m):
        a,b=map(int,input().split())
        if len(li)==0:
            li.append([a,b])
        else:
            flag=0
            for j in range(len(li)):
                if a in li[j] and b not in li[j]:
                	li[j].append(b)
                	flag=1
                elif a not in li[j] and b in li[j]:
                    li[j].append(a)
                    flag=1
                elif a in li[j] and b in li[j]:
                    break
                elif flag==0 and j==len(li)-1:
                    li.append([a,b])
        #print(li)
    ans=max([len(li[i]) for i in range(len(li))])
print(ans if m!=0 else 1)
Problem p02624 (python)

Fixed submission:
n=int(input())

#L=[n//i*(i+n//i*i)//2 for i in range(1,n+1)]
#print(sum(L))
ans=0
#for i in range(1,n+1):
#    for j in range(1,n+1):
#        if i%j==0:
#            ans+=i
#print(ans)
g=lambda x:(x*(n//x)*(n//x+1))//2
print(sum(g(i) for i in range(1,n+1)))

Buggy submission (verdict: Runtime Error):
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
n=int(input())
li=[]
f=make_divisors(n)
for i in range(1,n+1):
    li.append(i*f[i-1])
print(sum(li))

Buggy submission (verdict: Runtime Error):
import sympy
n=int(input())
li=[]
f=[sympy.divisor_count(i) for i in range(1,n+1)]

for i in range(1,n+1):
    li.append(i*f[i-1])
print(sum(li))

Buggy submission (verdict: Runtime Error):
import sympy
n=int(input())
li=[]
f=[sympy.divitor_count(i) for i in range(1,n+1)]
for i in range(1,n+1):
    li.append(i*f[i])
print(sum(li))
Problem p02699 (python)

Fixed submission:
s,w=map(int,input().split())
if w>=s:
    print("unsafe")
else:
    print("safe")

Buggy submission (verdict: Runtime Error):
s=input()
ans=0
for i in range(len(s)-4):
    for j in range(i+4,len(s)):
        if int(s[i:j+1])%2019==0:
            ans+=1
print(ans)
Problem p02711 (python)

Fixed submission:
N=str(input())
if "7" in N:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N=str(input())
if "7" in N:
  print("Yes")
else:
  print("No)

Buggy submission (verdict: Runtime Error):
N=input()
if "7" in N:
  print("Yes")
else:
  print("No)
Problem p02723 (python)

Fixed submission:
S=input()
if S[2] == S[3] and S[4] == S[5]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
X,Y,A,B,C=map(int,input().split())
p=sorted(list(map(int,input().split())))
q=sorted(list(map(int,input().split())))
r=sorted(list(map(int,input().split())))
for i in range(min(X,Y)):
  if p[A-X+i] > q[B-Y+i]:
    if r[-1] >= q[B-Y+i]:
      del q[B-Y+i]
      q.insert(B-Y+i,r[-1])
      del r[-1]
      r.insert(0,0)
      if r[-1] > p[A-X+i]:
        del p[A-X+i]
        p.insert(A-X+i,r[-1])
        del r[-1]
        r.insert(0,0)
  else:
    if r[-1] > p[A-X+i]:
      del p[A-X+i]
      p.insert(A-X+i,r[-1])
      del r[-1]
      r.insert(0,0)
      if r[-1] > q[B-Y+i]:
        del q[B-Y+i]
        q.insert(B-Y+i,r[-1])
        del r[-1]
        r.insert(0,0)
if X>Y:
  for j in range(X-Y):
    if p[A-X+Y+j] < r[-1]:
      del p[A-X+Y+j]
      p.insert(A-X+Y+j,r[-1])
      del r[-1]
      r.insert(0,0)
if X<Y:
  for j in range(Y-X):
    if q[B-Y+X+j] < r[-1]:
      del q[B-Y+X+j]
      q.insert(B-Y+X+j,r[-1])
      del r[-1]
      r.insert(0,0)
P=sorted(p)
Q=sorted(q)
sc=0
for k in range(X):
  sc+=P[A-X+k]
for l in range(Y):
  sc+=Q[B-Y+l]
print(sc)

Buggy submission (verdict: Runtime Error):
K,N=map(int,input().split())
A=list(map(int,input().split()))
List=[]
for i in range(N):
  b=abs(A[i]-A[i-1])
  List.append(b)
SL=sorted(List)
print(K-SL[-1])

Buggy submission (verdict: Runtime Error):
K,N=map(int,input().split())
A=list(map(int,input().split()))
d=0
for i in range(N-1):
  if d == 0 and A[i+1]-A[0] >= K/2:
    d=d+A[i]-A[0]+K-A[i+1]
if d == 0:
  d=d+A[N-1]-A[N-2]
print(d)

Buggy submission (verdict: Runtime Error):
K,N=map(int,input().split())
A=list(map(int,input().split()))
d=0
for i in range(N-1):
  b=A[i+1]-A[i]
  if d == 0 and A[i+1]-A[0] >= K/2:
    d=d+A[i]-A[0]+K-A[i+1]
if d == 0:
  d=d+A[N-1]
print(d)

Buggy submission (verdict: Runtime Error):
K,N=map(int,input().split())
A=list(map(int,input().split()))
d=0
for i in range(N-1):
  b=A[i+1]-A[i]
  if A[i+1]-A[0] >= K/2:
    d=d+A[i]-A[0]+K-A[i+1]
print(d)
Problem p02729 (python)

Fixed submission:
N,M=map(int,input().split())
print(int(N*(N-1)/2+M*(M-1)/2))

Buggy submission (verdict: Runtime Error):
N=int(input())
M=int(input())
print(N*(N-1)/2+M*(M-1)/2)
Problem p02753 (python)

Fixed submission:
S=input()
if S == "AAA" or S == "BBB":
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
N,A,B=map(int,input().split())
List=""
while len(List) < N:
    List=+="b"*A+"r"*B
if len(List) >= N:
  ans=List[:N]
  print(ans.count("b"))
Problem p02754 (python)

Fixed submission:
N,A,B=map(int,input().split())
print(N//(A+B)*A+min(A,N%(A+B)))

Buggy submission (verdict: Runtime Error):
N,A,B=map(int,input().split())
List=""
while len(List) < N:
    List+="b"*A+"r"*B
if len(List) >= N:
  ans=List[:N]
  print(ans.count("b"))

Buggy submission (verdict: Runtime Error):
N,A,B=map(int,input().split())
List=""
while len(List) < N:
    List=List+"b"*A
    List=List+"r"*B
if len(List) >= N:
  ans=List[:N]
  print(ans.count("b"))

Buggy submission (verdict: Runtime Error):
N,A,B=map(int,input().split())
List=""
while len(List) < N:
    List=List+"b"*A
  for j in range(B):
    List=List+"r"*B
if len(List) >= N:
  ans=List[:N]
  print(ans.count("b"))
Problem p02623 (python)

Fixed submission:
N, M, K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

a, b=[0], [0]
for i in range(N):
  a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])
    
ans, j=0, M
for i in range(N+1):
  if a[i]>K:
    break
  while b[j]>K-a[i]:
    j-=1
  ans=max(ans, i+j)
  
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,k = map(int,input().split())

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

# まずaを全部読む
# 全部読めたならbも読む
# 最後の本を捨てて、それがなければどこまでいけるかを試す

ans = 0
cost = 0
b_i = 0
while cost <= k:
  ans += 1
  if ans >= n:
    cost += b[n-ans]
    b_i += 1
  else:
    cost += a[ans]

max_ans = ans
if b_i == 0:
  for i in range(ans-1,-1,-1):
    ans -= 1
    cost -= a[i]
    while cost <= k and b_i < m:
      ans += 1
      cost += b[b_i]
      b_i += 1
    max_ans = max(max_ans, ans)
else:
  for i in range(n-1,-1,-1):
    ans -= 1
    cost -= a[i]
    while cost <= k and b_i < m:
      ans += 1
      cost += b[b_i]
      b_i += 1
    max_ans = max(max_ans, ans)
    
if not (a[0] >= k and b[0] >= k):
  print(max_ans)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
n,m,k = map(int,input().split())

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

# まずaを全部読む
# 全部読めたならbも読む
# 最後の本を捨てて、それがなければどこまでいけるかを試す

ans = 0
cost = 0
b_i = 0
while cost <= k:
  ans += 1
  if ans >= n:
    cost += b[n-ans]
    b_i += 1
  else:
    cost += a[ans]

max_ans = ans
if b_i == 0:
  for i in range(ans-1,-1,-1):
    ans -= 1
    cost -= a[i]
    while cost <= k and b_i < m:
      ans += 1
      cost += b[b_i]
      b_i += 1
    max_ans = max(max_ans, ans)
else:
  for i in range(n-1,-1,-1):
    ans -= 1
    cost -= a[i]
    while cost <= k and b_i < m:
      ans += 1
      cost += b[b_i]
      b_i += 1
    max_ans = max(max_ans, ans)
    
if not a[0] >= k and b[0] >= k:
  print(max_ans)
else:
  print(0)
Problem p02712 (python)

Fixed submission:
N = int(input())

_sum = N * (1+N)/2

if N >= 3:
  _min = 3
  _max = 3 * (N // 3)
  num = (_max - _min) / 3 + 1
  _sum -= num*(_min+_max)/2

if N >= 5:
  _min = 5
  _max = 5 * (N // 5)
  num = (_max - _min) / 5 + 1
  _sum -= num*(_min+_max)/2

if N >= 15:
  _min = 15
  _max = 15 * (N // 15)
  num = (_max - _min) / 15 + 1
  _sum += num*(_min+_max)/2

print(int(_sum))

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

_sum = N * (1+N)/2

if N >= 3:
  _min = 3
  _max = 3 * (N // 3)
  num = (_max - _min) / 3 + 1
_sum -= num*(_min+_max)/2

if N >= 5:
  _min = 5
  _max = 5 * (N // 5)
  num = (_max - _min) / 5 + 1
_sum -= num*(_min+_max)/2

if N >= 15:
  _min = 15
  _max = 15 * (N // 15)
  num = (_max - _min) / 15 + 1
  _sum += num*(_min+_max)/2

print(int(_sum))
Problem p02729 (python)

Fixed submission:
hoge = input().split()
N = int(hoge[0])
M = int(hoge[1])

if N == 1 and M == 1:
  print(0)
else:
  n = 0
  if N != 0:
    for i in range(N-1):
      n += 1+i
  else:
    n = 0
  if M != 0:
    m = (M * (M-1)) / 2
  else:
    m = 0
  print(int(n + m))

Buggy submission (verdict: Runtime Error):
hoge = input().split()
N = int(hoge[0])
M = int(hoge[1])

if N == 1 and m == 1:
  print(0)
else:
  n = 0
  if N != 0:
    for i in range(N-1):
      n += 1+i
  else:
    n = 0
  if M != 0:
    m = (M * (M-1)) / 2
  else:
    m = 0
  print(int(n + m))

Buggy submission (verdict: Runtime Error):
hoge = input().split()
N = int(hoge[0])
M = int(hoge[1])

if N == 1 and m == 1:
  print(0)
else:
  n = 0
  for i in range(N-1):
    n += 1+i
  m = (M * (M-1)) / 2
  print(int(n + m))

Buggy submission (verdict: Runtime Error):
hoge = input().split()
N = int(hoge[0])
M = int(hoge[1])

if N == 1 and m == 1:
  print(0)
else:
  n = 0
  for i in range(N-1):
    n += 1+i
  m = (M * (M-1)) / 2
  print(int(n + m))