Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
s=sum(a)
sunuke=0
arai=0
ans=10**18
for i in range(1,n):
    sunuke=sum(a[:i])
    arai=s-sunuke
    t=abs(sunuke-arai)
    ans=min(t,ans)
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
X = [0]*N

S = sum(A)
ans = 10**11

for i in range(N-1):
    X[i+1] = X[i] + A[i]

print(min(abs(S-2*X[i]) for i in range(1,N)))
Buggy python submission (verdict: Runtime Error):
# 
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
a,b,c = map(str, input().split())
ans = ''
ans = a[0:1]+b[0:1]+c[0:1]
ans = ans.upper()
pritn(ans)

Fixed submission:
# 
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
a,b,c = map(str, input().split())
ans = ''
ans = a[0:1]+b[0:1]+c[0:1]
ans = ans.upper()
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# ABC057 C - Digits in Multiplication
from itertools import combinations
def factorize(n):
    retlist = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            while temp%i==0:
                temp //= i
                retlist.append(i)
    if temp!=1:
        retlist.append(temp)

    if retlist==[]:
        retlist.append(n)

    return retlist

N = int(input())

ans = 10000000
L = []
L = factorize(N)
# print(L)

for i in range(1,len(L)+1):
    C = []
    C = list(combinations(L,i))
    # print(C)
    for c in C:
        a,b = 1,0
        for j in range(len(c)):
            a *= c[j]
        b = N//a
        a = str(a)
        b = str(b)
        # print('a:',a,'b:',b)
        ans = min(ans,max(len(a),len(b)))

print(ans)


Fixed submission:
# ABC057 C - Digits in Multiplication
from itertools import combinations
def factorize(n):
    retlist = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            while temp%i==0:
                temp //= i
                retlist.append(i)
    if temp!=1:
        retlist.append(temp)

    if retlist==[]:
        retlist.append(n)

    return retlist

N = int(input())

ans = 10000000
L = []
L = factorize(N)
# print(L)

for i in range(1,len(L)+1):
    C = []
    C = list(combinations(L,i))
    # print(C)
    for c in C:
        a,b = 1,0
        for j in range(len(c)):
            a *= c[j]
        b = N//a
        a = str(a)
        b = str(b)
        # print('a:',a,'b:',b)
        ans = min(ans,max(len(a),len(b)))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

p=1
mod=10**9+7

for i in range(1,N+1):
    p = p*i

print(p%mod)

Fixed submission:
N = int(input())

p=1
mod=10**9+7

for i in range(1,N+1):
    p = (p*i)%mod

print(p)
Buggy python submission (verdict: Runtime Error):
print(oteagedesita)

Fixed submission:
n,ma,mb = map(int,input().split())
a = []
b = []
c = []
for i in range(n):
    aa,bb,cc = map(int,input().split())
    a.append(aa)
    b.append(bb)
    c.append(cc)

inf = 10**18
dp = [[[inf]*(411) for j in range(411)] for i in range(n+1)]
for i in range(n+1):
    dp[i][0][0] = 0
for i in range(n):
    for j in range(400):
        for k in range(400):
            if dp[i][j][k] == inf:continue
            dp[i+1][j][k] = min(dp[i+1][j][k],dp[i][j][k])
            dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i])

ans = 10**18
for j in range(1,401):
    for k in range(1,401):
        if ma*k == mb*j:
            ans = min(ans,dp[n][j][k]) 
if ans == 10**18:
    print(-1)
else:
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split())
ans=0
for x in range(k+1):
    for y in range(k+1):
        z=s-x-y
        if x+y+z==s and 0<=z<=k:
            ans+=1
print(ans)



Fixed submission:
# ABC051 B - Sum of Three Integers
K,S = map(int,input().split())
ans = 0
for i in range(0,K+1):
    for j in range(0,K+1):
        k = S-i-j
        if 0<=k<=K:
                ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# ABC051 B - Sum of Three Integers
K,S = map(int,input().split())
ans = 0
for i in range(0,K+1):
    for j in range(0,K+1):
        for k in range(0,S-i-j+1):
            if i+j+k == S and 0<=k<=K:
                ans += 1
print(ans)

Fixed submission:
# ABC051 B - Sum of Three Integers
K,S = map(int,input().split())
ans = 0
for i in range(0,K+1):
    for j in range(0,K+1):
        k = S-i-j
        if 0<=k<=K:
                ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
a,op,b = map(int,input().split())
print(a+b if op =='+' else a-b)


Fixed submission:
a,op,b = map(str,input().split())
a = int(a)
b = int(b)
print(a+b if op =='+' else a-b)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
A.sort()
sum = 0
ans = 0
zeroflg = 0

for i in range(len(A)-2):
    if N%2 == 0 and A[0] == 1 and A[N-1] == N-1:
        if N == 2:
            if A[0] == A[1]:
                sum = 2**(N/2)
            else:
                zeroflg = 1
        elif N > 2:
            if A[0] == A[1]:
                if  i%2 == 0 and A[i + 2] - A[i] == 2 and A[i + 1] - A[i] == 0:
                    sum = 2**(N/2)
                elif i%2 == 1 and A[i + 2] - A[i] == 2 and A[i + 1] - A[i] == 2:
                    sum = 2**(N/2)
                else:
                    zeroflg = 1
            else:
                zeroflg = 1
    elif N%2 == 1 and A[0] == 0 and A[N-1] == N-1:
        if N == 1:
            sum = 2**(N//2)
        elif N > 1: 
            if i%2 == 0 and A[i + 2] - A[i] == 2 and A[i + 1] - A[i] == 2:
                sum = 2**(N//2)
            elif i%2 == 1 and A[i + 2] - A[i] == 2 and A[i + 1] - A[i] == 0:
                sum = 2**(N//2)
            else:
                zeroflg = 1

if zeroflg == 1:
    print(ans)
else:
    ans = int(sum)
    ans%(10**9+7)
    print(ans)


    

Fixed submission:
# ABC050 C - Lining Up
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
a.sort()

if n%2==0:
    for aa in a:
        if aa%2==0:
            print(0)
            exit()
    
    for i in range(n):
        if i%2==0:
            if a[i]!=a[i+1]:
                print(0)
                exit()
    print((2**(n//2))%mod)
else:
    for aa in a:
        if aa%2==1:
            print(0)
            exit()
    for i in range(n-1):
        if a[0]!=0:
            print(0)
            exit()
        if i%2==1:
            if a[i]!=a[i+1]:
                print(0)
                exit()
    print((2**(n//2))%mod)
Buggy python submission (verdict: Time Limit Exceeded):
# B - Exactly N points
n=int(input())

if n==1:
    print(1)
    exit()
t=0
acc=[]
for i in range(1,n+1):
    t+=i
    acc.append(t)
max_v=-1
for i in range(len(acc)-1):
    if acc[i]<n<=acc[i+1]:
        max_v=i+2
        break
ans=[]
ans.append(max_v)
cur=max_v
vv=acc[i+1]
vv-=cur
s=max_v

while vv and s<n:
    cur-=1
    if vv>cur and s+cur<=n:
        vv-=cur
        ans.append(cur)
        s+=cur
    elif vv<cur:
        continue
    elif vv==cur:
        vv-=cur
        ans.append(cur)
        s+=cur
for a in ans:
    print(a)


Fixed submission:
# B - Exactly N points
n=int(input())

if n==1:
    print(1)
    exit()
t=0
acc=[]
for i in range(1,n+1):
    t+=i
    acc.append(t)
max_v=-1
for i in range(len(acc)-1):
    if acc[i]<n<=acc[i+1]:
        max_v=i+2
        break
ans=[]
ans.append(max_v)
cur=max_v
vv=acc[i+1]
vv-=cur
s=max_v

while vv and s<n:
    cur-=1
    if vv>cur and s+cur<=n:
        vv-=cur
        ans.append(cur)
        s+=cur
    elif vv<cur:
        continue
    elif vv==cur:
        vv-=cur
        ans.append(cur)
        s+=cur
for a in ans:
    print(a)
Buggy python submission (verdict: Runtime Error):
# ABC044 B - 美しい文字列 / Beautiful Strings
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

S = si()
SS = set()
for s in S:
    SS.add(s)

for ss in SS:
    if S.count(SS)%2==1:
        print('No')
        exit()
print('Yes')


Fixed submission:
# ABC044 B - 美しい文字列 / Beautiful Strings
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

S = si()
SS = set()
for s in S:
    SS.add(s)

for ss in SS:
    if S.count(ss)%2==1:
        print('No')
        exit()
print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
# D - いろはちゃんとマス目
def combmod(n,k,mod):
    a = 1
    b = 1
    for i in range(k):
        a = a * (n-i) % mod
        b = b * (i+1) % mod
    return a * pow(b, mod-2, mod) % mod

h,w,a,b=map(int,input().split())

mod=10**9+7
ans=0
for i in range(b,w):
    ans+=combmod(i+h-1-a,i,mod)*combmod(w-1-i+a-1,a-1,mod)
    ans%=mod
print(ans)


Fixed submission:
# D - いろはちゃんとマス目
def cmb1(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

h,w,a,b=map(int,input().split())

# 前処理
mod=10**9+7 #出力の制限
n=10**6
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 = 0
for i in range(b, w):
    ans+=cmb1(i+h-1-a,i,mod)*cmb1(w-1-i+a-1,a-1,mod)
    ans%=mod
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
a,b,c,d=0,1e10,-1e10,1e10
for i in range(N):
  A,B=int(input().pulit())
  a=max(a,A+B)
  b=min(b,A+B)
  c=max(c,A-B)
  d=min(d,A-B)
print(max(abs(a-b),abs(c-d))

Fixed submission:
N=int(input())
a,b,c,d=0,1e10,-1e10,1e10
for i in range(N):
  A,B=input().split()
  A=int(A)
  B=int(B)
  a=max(a,A+B)
  b=min(b,A+B)
  c=max(c,A-B)
  d=min(d,A-B)
print(max(abs(a-b),abs(c-d)))
Buggy python submission (verdict: Runtime Error):
N=int(input())
a,b,c,d=0,0,0,0
for i in range(N):
  A=input()
  if A=="AC":
    a+=1
  elif A=="WA":
    b+=1
  elif A=="TLE":
    c+=1
  else:
    d+=1
print("AC x" a)
print("WA x" b)
print("TLE x" c)
print("RE x" d)

Fixed submission:
N=int(input())
a,b,c,d=0,0,0,0
for i in range(N):
  A=input()
  if A=="AC":
    a+=1
  elif A=="WA":
    b+=1
  elif A=="TLE":
    c+=1
  else:
    d+=1
print("AC x",a)
print("WA x",b)
print("TLE x",c)
print("RE x",d)

Buggy python submission (verdict: Runtime Error):
N=input()
a,b,c,d=0,0,0,0
for i in range(N):
  A=input()
  if A=="AC":
    a+=1
  elif A=="WA":
    b+=1
  elif A=="TLE":
    c+=1
  else:
    d+=1
print("AC x" a)
print("WA x" b)
print("TLE x" c)
print("RE x" d)

Fixed submission:
N=int(input())
a,b,c,d=0,0,0,0
for i in range(N):
  A=input()
  if A=="AC":
    a+=1
  elif A=="WA":
    b+=1
  elif A=="TLE":
    c+=1
  else:
    d+=1
print("AC x",a)
print("WA x",b)
print("TLE x",c)
print("RE x",d)
Buggy python submission (verdict: Runtime Error):
a,b=list(map(int,input().split()))
if a%2==0&&b%2==0:
  if (b-a)%4==0:
    print(b)
  else:
    print(b^1)
elif a%2==0:
  if (b-a)%4==1:
    print(0)
  else:
    print(1)
elif b%2==0:
  if (b-a)%4==1:
    print(a^b^1)
  else:
    print(a^b)
else:
  if (b-a)%4==0:
    print(a)
  else:
    print(a^1)

Fixed submission:
a,b=map(int,input().split())
if a%2==0 and b%2==0:
  if (b-a)%4==0:
    print(b)
  else:
    print(b^1)
elif a%2==0:
  if (b-a)%4==1:
    print(1)
  else:
    print(0)
elif b%2==0:
  if (b-a)%4==1:
    print(a^b)
  else:
    print(a^b^1)
else:
  if (b-a)%4==0:
    print(a)
  else:
    print(a^1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = 0
mod = 10**9 + 7
num = a[0]
for i in range(n-1):
    cnt = sum(a) - num
    cnt %= mod
    ans += a[i]*cnt
    ans %= mod
    num += a[i+1]
    num %= mod
print(ans%mod)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 0
mod = 10**9 + 7
num = sum(a)%mod
for i in range(n-1):
    num -= a[i]
    num %= mod
    ans += a[i]*num
    ans %= mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
cnt = 0
while n>0:
    ans += n%10
    n //= 10
if ans%9 == 0:
    print("Yes")
else:
    print("No")

Fixed submission:
n = str(input())
ans = 0
for i in range(len(n)):
    ans += int(n[i])
if ans%9 == 0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
front = 0
rear = sum(a)
ans = 10**100
for i in range(n-1):
    front += a[i]
    rear -= a[i]
    ans = min(ans,abs(front - rear))
print(ans)

Fixed submission:
n , d = map(int,input().split())
import math

ans = 0
cnt = 0
for i in range(n):
    a,b = map(int,input().split())
    if math.sqrt(a**2 + b**2) <= d:
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = [1]*n
for i in range(k):
    ans[0] *= a[i]
for i in range(n-k):
    ans[i+1] = ans[i] * a[i+k] // a[i]
    if ans[i+1] > ans[i]:
        print("Yes")
    else:
        print("No")

Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n-k):
    if a[i+k] > a[i]:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = [0]*(n+1)
ans[0] = 1
for i in range(k):
    ans[0] *= a[i]

for i in range(n-k):
    ans[i+1] = ans[i] * a[i+k] //a[i]
    if ans[i+1] > ans[i]:
        print("Yes")
    else:
        print("No")

Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n-k):
    if a[i+k] > a[i]:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = [0]*(k+2)
ans[0] = 1
for i in range(k):
    ans[0] *= a[i]
print(ans[0])
for i in range(n-k):
    #print(i,ans)
    ans[i+1] = ans[i] * a[i+k] //a[i]
    if ans[i+1] > ans[i]:
        print("Yes")
    else:
        print("No")

Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n-k):
    if a[i+k] > a[i]:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Runtime Error):
import operator
import functools
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = [0]*(k+2)
seki = functools.partial(functools.reduce, operator.mul)
ans[0] = seki(a[:k])
for i in range(n-k):
    #print(i,ans)
    ans[i+1] = ans[i] * a[i+k]
    ans[i+1] //= a[i]
for i in range(n-k):
    if ans[i+1] > ans[i]:
        print("Yes")
    else:
        print("No")

Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n-k):
    if a[i+k] > a[i]:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
st = 0
go = k
cnt = sum(a[:go])
for i in range(n-k):
    st += 1
    go += 1
    if cnt < sum(a[st:go]):
        print("Yes")
    else:
        print("No")
    cnt = sum(a[st:go])

Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n-k):
    if a[i+k] > a[i]:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = 1
for i in range(n):
    ans *= a[i]
if ans > 10**18:
    print(-1)
else:
    print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 1
b = 0
for i in range(n):
    if a[i] == 0:
        b = 1
        print(0)
if b == 0:
    for i in range(n):
        ans *= a[i]
        if ans > 10**18:
            print(-1)
            break
    else:
        print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
for i in range(n-1):
    print(a.count(i+1))
print(0)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = [0]*(n-1)
for i in range(n-1):
    ans[a[i]-1] += 1
for i in range(n-1):
    print(ans[i])
print(0)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
if n >= k:
    print(min(n%k,abs(n%k-k)))
else:
    print(min(n,abs(k%n)))

Fixed submission:
n,k = map(int,input().split())
rest = n%k
print(min(rest,k-rest))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
s = [str(input()) for _ in range(n)]
num = Counter(s).most_common()[0][1]
ans = []
for i in range(len(Counter(s).most_common())):
    if Counter(s).most_common()[i][1] == num:
        ans.append(Counter(s).most_common()[i][0])
ans.sort()
for i in range(len(ans)):
    print(ans[i])

Fixed submission:
from collections import Counter
n = int(input())
s = [str(input()) for _ in range(n)]
num = Counter(s)
ans = []
ma = max(num.values())
for i in sorted(num):
    if num[i] == ma:
        print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(n):
    ans = p[:i+1]
    if min(ans) != p[i]:
        count += 1
print(n-count)

Fixed submission:
n = int(input())
p = list(map(int,input().split()))
count = 0
mi = n+1
for i in range(n):
    mi = min(mi,p[i])
    if mi == p[i]:
        count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(n):
    for j in range(i+1):
        if p[i] > p[j]:
            break
    else:
        count += 1
print(count)

Fixed submission:
n = int(input())
p = list(map(int,input().split()))
count = 0
mi = n+1
for i in range(n):
    mi = min(mi,p[i])
    if mi == p[i]:
        count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for _ in range(n)]
for i in range(n):
    ans = a[:i] + a[i+1:]
    print(max(ans))
    ans = []

Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]
ans = sorted(a)
max1 = ans[-1]
max2 = ans[-2]
for i in a:
    if i == max1:
        print(max2)
    else:
        print(max1)
Buggy python submission (verdict: Runtime Error):
l,r = map(int,input().split())
if r-l+1 >= 2019:
    print(0)
else:
    ans = 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            ans = min(i*j%2019,ans)
print(ans)

Fixed submission:
l,r = map(int,input().split())
ans = 2019
if r-l+1 >= 2019:
    print(0)
else:
    for i in range(l,r):
        for j in range(i+1,r+1):
            ans = min( (i*j) % 2019, ans)
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
l,r = map(int,input().split())
min = 20000
for i in range(l,r,1):
    for j in range(l+1,r+1,1):
        if min >= (i*j)%2019:
            min = (i*j)%2019
print(min)

Fixed submission:
l,r = map(int,input().split())
ans = 2019
if r-l+1 >= 2019:
    print(0)
else:
    for i in range(l,r):
        for j in range(i+1,r+1):
            ans = min( (i*j) % 2019, ans)
    print(ans)
Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())
lcm = c*d // math.gcd(c,d)
A = ((a-1) // c) + ((a-1) // d) - ((a-1) // lcm) 
B = (b // c) + (b // d) - (b // lcm)
ans = B-A
print( b-a+1-ans )

Fixed submission:
import fractions
a,b,c,d = map(int,input().split())
lcm = c*d // fractions.gcd(c,d)
A = ((a-1) // c) + ((a-1) // d) - ((a-1) // lcm) 
B = (b // c) + (b // d) - (b // lcm)
ans = B-A
print(b-a+1-ans)

Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())
lcm = c*d // math.gcd(c,d)
A = ((a-1) // c) + ((a-1) // d) - ((a-1) // lcm) 
B = (b // c) + (b // d) - (b // lcm)
sum = B-A
print( b-a+1-sum )

Fixed submission:
import fractions
a,b,c,d = map(int,input().split())
lcm = c*d // fractions.gcd(c,d)
A = ((a-1) // c) + ((a-1) // d) - ((a-1) // lcm) 
B = (b // c) + (b // d) - (b // lcm)
ans = B-A
print(b-a+1-ans)

Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())
lcm = c*d // math.gcd(c,d)
A = ((a-1) // c) + ((a-1) // d) - ((a-1) // lcm) 
B = (b // c) + (b // d) - (b // lcm)
sum = B-A  #割り切れる個数
print( b-a+1-sum )

Fixed submission:
import fractions
a,b,c,d = map(int,input().split())
lcm = c*d // fractions.gcd(c,d)
A = ((a-1) // c) + ((a-1) // d) - ((a-1) // lcm) 
B = (b // c) + (b // d) - (b // lcm)
ans = B-A
print(b-a+1-ans)
Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n = map(int,input().split())
cnt = 0
for i in range(0,n//r + 1):
    for j in  range(0,n//g + 1):
        if (n - i*r - j*g)%b == 0 and (n - i*r - j*g)/b >= 0:
            cnt += 1
print(cnt)

Fixed submission:
r,g,b,n = map(int,input().split())
cnt = 0
for i in range(0,n+1,r):
    for j in range(0,n+1-i,g):
        if (n - i - j)%b == 0 and (n - i - j)%b >= 0:
            cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n = map(int,input().split())
cnt = 0
for i in range(0,n+1,r):
    for j in  range(0,n+1,g):
        if (n - i - j)%b == 0 and (n - i - j)/b >= 0:
            cnt += 1
print(cnt)

Fixed submission:
r,g,b,n = map(int,input().split())
cnt = 0
for i in range(0,n+1,r):
    for j in range(0,n+1-i,g):
        if (n - i - j)%b == 0 and (n - i - j)%b >= 0:
            cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n = map(int,input().split())
cnt = 0
for i in range(0,n+1,r):
    for j in  range(0,n+1,g):
        ch = (n- i - j)/b
        if ch.is_integer() == True and ch >= 0:
            cnt += 1
print(cnt)

Fixed submission:
r,g,b,n = map(int,input().split())
cnt = 0
for i in range(0,n+1,r):
    for j in range(0,n+1-i,g):
        if (n - i - j)%b == 0 and (n - i - j)%b >= 0:
            cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
cnt = 0
l3 = abs(a[-3])
l2 = abs(a[-2])
l1 = abs(a[-1])
last = l3 + l2 + l1
if n == 2 and sum(a) >= 0:
    print(abs(sum(a)))
elif n == 2:
    print(max(abs(a[0]),abs(a[1])))
else:
    for i in range(n-3):
        if a[i] < 0:
            a[i] *= -1
            a[i+1] *= -1
        cnt += a[i]
    # +,+,+ or +,-,- or -,-,+ or -,+,-
    #print(cnt,a[-3],a[-2],a[-1])
    if (a[-3] >= 0 and a[-2] >= 0 and a[-1] >= 0) or (a[-3] >= 0 and a[-2] <= 0 and a[-1] <= 0) or (a[-3] <= 0 and a[-2] <= 0 and a[-1] >= 0) or (a[-3] <= 0 and a[-2] >= 0 and a[-1] <= 0):
        print(cnt+last)
    elif (a[-3] <= 0 and a[-2] >= 0 and a[-1] >= 0): # -,+,+
        print(cnt + last - 2*min(l1,l2,l3))
    else:
        print(cnt + last - 2*min(l1,l2))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
num = 0
mi = 10**9
for i in range(n):
    num += abs(a[i])
    if abs(mi) >= abs(a[i]):
        mi = a[i]
cnt = 0
for i in range(n):
    if a[i] < 0:
        cnt += 1
if cnt%2 == 1:
    print(num-2*abs(mi))
else:
    print(num)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n)]
ab.sort()
ans = 0
cnt = 0
i = 0
while cnt < m:
    ans += ab[i][0]*ab[i][1]
    cnt += ab[i][1]
    i += 1
print(ans - (cnt - m)*ab[i][0])

Fixed submission:
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n)]
ab.sort()
ans = 0
cnt = 0
i = 0
while cnt < m:
    ans += ab[i][0]*ab[i][1]
    cnt += ab[i][1]
    i += 1
print(ans - (cnt - m)*ab[i-1][0])

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n)]
ab.sort()
ans = 0
cnt = 0
i = 0
while cnt < m:
    ans += ab[i][0]*ab[i][1]
    cnt += ab[i][1]
    i += 1
print(num - (cnt - m)*ab[i][0])

Fixed submission:
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n)]
ab.sort()
ans = 0
cnt = 0
i = 0
while cnt < m:
    ans += ab[i][0]*ab[i][1]
    cnt += ab[i][1]
    i += 1
print(ans - (cnt - m)*ab[i-1][0])