Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import numba
@numba.njit
def main(N):
    x = 0
    for a in range(1, N+1):
        b=N//a
        x += a*b*(b+1)//2
    return x
N = int(input())
print(main(N))

Fixed submission:
import sys
import numba

@numba.njit
def main(N):
    x = 0
    for a in range(1, N+1):
        b=N//a
        x += a*b*(b+1)//2
    return x
 
N = int(input())
print(main(N))
Buggy python submission (verdict: Time Limit Exceeded):
import collections
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
d=collections.Counter(A)
for i in range(Q):
  B,C=map(int,input().split())
  if d[C] in d:
    d[C]+=d[B]
  else:
    d[C]=d[B]
  d[B]=0
  ans=0
  for j in d:
    ans += j*d[j]
  print(ans)

Fixed submission:
import collections
N=int(input())
A=list(map(int,input().split()))
s=sum(A)
Q=int(input())
d=collections.Counter(A)
for i in range(Q):
  B,C=map(int,input().split())
  s += d[B]*C - d[B]*B
  print(s)
  if C in d:
    d[C]+=d[B]
  else:
    d[C]=d[B]
  d[B]=0
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=sorted(list(map(int,input().split())))
l=len(A)
ans=0
for i in range(l):
  if i>0 and A[i-1]==A[i]:
    continue
  flag=0
  for j in range(l):
    if i==j:
      continue
    if A[j] > A[i]:
      break
    if A[i]%A[j]==0:
      flag=1
      break
  if flag==0:
    ans+=1
print(ans)


Fixed submission:
#https://at274.hatenablog.com/entry/2020/06/29/181102
import collections
N=int(input())
A=list(map(int,input().split()))
c=collections.Counter(A)
A=set(A)
MAX_A=10**6
X=[0]*(MAX_A + 1)#0-MAX_Aまでの整数がAの倍数で何回割られるか
for i in A:
  for j in range(i,MAX_A + 1,i):
    X[j]+=1

#割られた回数が1つしかないものはその数自身で割ったのでカウント
#ただし複数ある場合は除外
ans = len([a for a in A if (X[a] == 1) and (c[a] == 1)])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=sorted(list(map(int,input().split())))
l=len(A)
ans=0
for i in range(l):
  if i>0 and A[i-1]==A[i]:
    continue
  flag=0
  for j in range(l):
    if i==j:
      continue
    if A[j] > A[i]:
      break
    if A[i]%A[j]==0:
      flag=1
      break
  if flag==0:
    ans+=1
print(ans)


Fixed submission:
#https://at274.hatenablog.com/entry/2020/06/29/181102
import collections
N=int(input())
A=list(map(int,input().split()))
c=collections.Counter(A)
A=set(A)
MAX_A=10**6
X=[0]*(MAX_A + 1)#0-MAX_Aまでの整数がAの倍数で何回割られるか
for i in A:
  for j in range(i,MAX_A + 1,i):
    X[j]+=1

#割られた回数が1つしかないものはその数自身で割ったのでカウント
#ただし複数ある場合は除外
ans = len([a for a in A if (X[a] == 1) and (c[a] == 1)])
print(ans)

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

ans=0
for i in range(N):
  flag=0
  for j in range(N):
    if i==j:
      continue
    if A[j] > A[i]:
      break
    if A[i]%A[j]==0:
      flag=1
      break
  if flag==0:
    ans+=1
print(ans)


Fixed submission:
#https://at274.hatenablog.com/entry/2020/06/29/181102
import collections
N=int(input())
A=list(map(int,input().split()))
c=collections.Counter(A)
A=set(A)
MAX_A=10**6
X=[0]*(MAX_A + 1)#0-MAX_Aまでの整数がAの倍数で何回割られるか
for i in A:
  for j in range(i,MAX_A + 1,i):
    X[j]+=1

#割られた回数が1つしかないものはその数自身で割ったのでカウント
#ただし複数ある場合は除外
ans = len([a for a in A if (X[a] == 1) and (c[a] == 1)])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
ans=1
L=10**18
for i in range(N):
  ans*=A[i]

if ans > L:
  print(-1)
else:
  print(ans)



Fixed submission:
N=int(input())
A=sorted(list(map(int,input().split())))
ans=1
L=10**18

if A[0]==0:
  print(0)
  exit()

for i in range(N):
  ans*=A[i]
  if ans > L:
    print(-1)
    exit()

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
A,B,N=map(int,input().split())

s=0
if B<=N+1:
  x=B-1
  s=(A*x)//B - A*(x//B)
else:
  for x in range(1,N+1):
    p = (A*x)//B - A*(x//B)
    if p<s:
      break
    if p>s:
      s=p
print(s)

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

s=0
if B<=N:
  x=B-1
  s=(A*x)//B - A*(x//B)
else:
  x=N
  s=(A*x)//B - A*(x//B)
print(s)

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

s=0
if B<=N:
  x=B-1
  s=(A*x)//B - A*(x//B)
else:
  for x in range(1,N+1):
    p = (A*x)//B - A*(x//B)
    if p<s:
      break
    if p>s:
      s=p
print(s)

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

s=0
if B<=N:
  x=B-1
  s=(A*x)//B - A*(x//B)
else:
  x=N
  s=(A*x)//B - A*(x//B)
print(s)

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

s=0
for x in range(1,N+1):
  p = (A*x)//B - A*(x//B)
  if p<s:
    break
  if p>s:
    s=p
print(s)

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

s=0
if B<=N:
  x=B-1
  s=(A*x)//B - A*(x//B)
else:
  x=N
  s=(A*x)//B - A*(x//B)
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
S=str(input())
N=len(S)
counter=[0]*2019
counter[0]=1
ans=0
for i in range(1,N+1):
    s=S[-i:]
    r=int(s)%2019
    counter[r]+=1
for i in counter:
    ans += i*(i-1)//2
print(ans)

Fixed submission:
#https://mirucacule.hatenablog.com/entry/2020/04/27/090908
#https://drken1215.hatenablog.com/entry/2020/04/29/171300

S=str(input())[::-1]#逆順で格納
N=len(S)
counter=[0]*2019
counter[0]=1
ans=0
num,d=0,1
for c in S:
    num += int(c) * d
    num %= 2019
    d *= 10
    d %= 2019
    counter[num]+=1
for i in counter:
    ans += i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S=str(input())
N=len(S)
s=[0]*(N+1)
s[0]=0
counter=[0]*2019
counter[0]=1
ans=0
for i in range(1,N+1):
    s[i]=S[-i:]
    r=int(s[i])%2019
    counter[r]+=1
for i in counter:
    ans += i*(i-1)//2
print(ans)

Fixed submission:
#https://mirucacule.hatenablog.com/entry/2020/04/27/090908
#https://drken1215.hatenablog.com/entry/2020/04/29/171300

S=str(input())[::-1]#逆順で格納
N=len(S)
counter=[0]*2019
counter[0]=1
ans=0
num,d=0,1
for c in S:
    num += int(c) * d
    num %= 2019
    d *= 10
    d %= 2019
    counter[num]+=1
for i in counter:
    ans += i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=str(input())
l=len(N)
 
ans=0
for i in range(l):
    for j in range(i+4,l+1):
        if int(N[i:j])%2019==0:
            ans+=1
 
print(ans)

Fixed submission:
#https://mirucacule.hatenablog.com/entry/2020/04/27/090908
#https://drken1215.hatenablog.com/entry/2020/04/29/171300

S=str(input())[::-1]#逆順で格納
N=len(S)
counter=[0]*2019
counter[0]=1
ans=0
num,d=0,1
for c in S:
    num += int(c) * d
    num %= 2019
    d *= 10
    d %= 2019
    counter[num]+=1
for i in counter:
    ans += i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=str(input())
l=len(N)

ans=0
for i in range(l):
    for j in range(i+4,l+1):
        if int(N[i:j])%2019==0:
            ans+=1

print(ans)

Fixed submission:
#https://mirucacule.hatenablog.com/entry/2020/04/27/090908
#https://drken1215.hatenablog.com/entry/2020/04/29/171300

S=str(input())[::-1]#逆順で格納
N=len(S)
counter=[0]*2019
counter[0]=1
ans=0
num,d=0,1
for c in S:
    num += int(c) * d
    num %= 2019
    d *= 10
    d %= 2019
    counter[num]+=1
for i in counter:
    ans += i*(i-1)//2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))

for i in range(1,N+1):
  print(A.count(i))

Fixed submission:
from collections import Counter

N=int(input())
A=list(map(int,input().split()))
B=set(A)
C=Counter(A)
for i in range(1,N+1):
  if i not in B:
    print(0)
  else:
    print(C[i])
Buggy python submission (verdict: Runtime Error):
N=int(input())
if N[0]==7 or N[1]==7 or N[2]==7:
  print('Yes')
else:
  print('No')

Fixed submission:
N = list(str(input()))
if int(N[0]) == 7 or int(N[1]) == 7 or int(N[2]) == 7:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)


K=int(input())

S=0
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      S+=gcd(i,j,k)

print(S)

Fixed submission:
import math

K=int(input())

f=[]

for i in range(1,K+1):
  for j in range(1,K+1):
    s=math.gcd(i, j)
    f.append(s)

S=0
for i in range(1,K+1):
  for j in f:
    S+=math.gcd(i,j)

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


count=0
for i in range(N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k] and j-i != k-j:
        count+=1
print(count)

Fixed submission:
N=int(input())
S=str(input())
ans=S.count('R')*S.count('G')*S.count('B')

for i in range(N-2):
  for j in range(i+1,N-1):
    if S[i]==S[j]:
      continue
    if 2*j - i < N:
      if S[2*j - i] != S[i] and S[2*j - i] != S[j]:
        ans-=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import copy
import itertools
N=int(input())
A=list(map(int,input().split()))
dp={}

for k in range(N):
  if A[k] in dp:
    print(dp[A[k]])
  else:
    B=copy.copy(A)
    B.remove(A[k])
    p=itertools.combinations(B,2)
    c=0
    for i in p:
      if i[0]==i[1]:
        c+=1
    dp[A[k]]=c
    print(c)

Fixed submission:
import collections
N=int(input())
A=list(map(int,input().split()))
c=collections.Counter(A)

#全体の数列について答えを求めるnC2=n(n-1)/2
ALL=0
for i in c.values():
  if i>1:
    ALL += i*(i-1)//2

#各要素が影響する分を求める
for i in A:
  if c[i]>2:
    print(ALL-c[i]+1)
  elif c[i]==2:
    print(ALL-1)
  else:
    print(ALL)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
import collections
def kaijyou(k):
  N=1
  for i in range(k,0,-1):
    N*=i
  return N

def combinations(n,r):
  return int(kaijyou(n)/(kaijyou(r)*kaijyou(n-r)))

N=int(input())
A=list(map(int,input().split()))
B=sorted(set(A))
dp=[]

for i in B:
  C=copy.copy(A)
  C.remove(i)
  c=collections.Counter(C)
  e=c.values()
  f=0
  for k in e:
    f+=combinations(k,2)
  dp.append(f)
for i in A:
  print(dp[B.index(i)])

Fixed submission:
import collections
N=int(input())
A=list(map(int,input().split()))
c=collections.Counter(A)

#全体の数列について答えを求めるnC2=n(n-1)/2
ALL=0
for i in c.values():
  if i>1:
    ALL += i*(i-1)//2

#各要素が影響する分を求める
for i in A:
  if c[i]>2:
    print(ALL-c[i]+1)
  elif c[i]==2:
    print(ALL-1)
  else:
    print(ALL)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
import collections
def kaijyou(k):
  N=1
  for i in range(k,0,-1):
    N*=i
  return N

def combinations(n,r):
  return int(kaijyou(n)/(kaijyou(r)*kaijyou(n-r)))

N=int(input())
A=list(map(int,input().split()))
B=sorted(set(A))
d=[]
dp=[]

for i in B:
  C=copy.copy(A)
  C.remove(i)
  c=collections.Counter(C)
  d.append(c)

for i in d:
  e=i.values()
  f=0
  for k in e:
    f+=combinations(k,2)
  dp.append(f)
for i in A:
  print(dp[B.index(i)])

Fixed submission:
import collections
N=int(input())
A=list(map(int,input().split()))
c=collections.Counter(A)

#全体の数列について答えを求めるnC2=n(n-1)/2
ALL=0
for i in c.values():
  if i>1:
    ALL += i*(i-1)//2

#各要素が影響する分を求める
for i in A:
  if c[i]>2:
    print(ALL-c[i]+1)
  elif c[i]==2:
    print(ALL-1)
  else:
    print(ALL)
Buggy python submission (verdict: Time Limit Exceeded):
N,A,B=map(int,input().split())

b=0
r=0
while N>0:
    N-=A
    b+=A
    if N<=0:
        b+=N
        break

    N-=B
    r+=B
    if N<=0:
        break

print(b)

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

C=A+B
d=N//C
N -= C*d

b=0
r=0
while N>0:
    N-=A
    b+=A
    if N<=0:
        b+=N
        break

    N-=B
    r+=B
    if N<=0:
        break

print(b+d*A)

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

b=0
r=0
while b+r<N:
    for i in range(A):
        b+=1
        if b+r==N:
            break
    for j in range(B):
        r+=1
        if b+r==N:
            break
print(b)

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

C=A+B
d=N//C
N -= C*d

b=0
r=0
while N>0:
    N-=A
    b+=A
    if N<=0:
        b+=N
        break

    N-=B
    r+=B
    if N<=0:
        break

print(b+d*A)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
X = [-1] * N#[-1,-1,-1.....]
for i in range(M):
    s, c = map(str, input().split())
    if s == 1 and N > 1 and c==0:
        print(-1)
        exit()#プログラム終了 １桁目が0で２桁以上あるため-1
    if X[s-1] < 0:#もしリストにまだ数字が入っていなかったらCを代入
        X[s-1] = c
    
    #もしすでにリストに数字が入っている場合は-1を出力する
    elif X[s-1] != c:
        print(-1)
        exit()
#このfor文でリストが完成する

if X[0] < 0 :#もし1桁目の数字が指定されていないなら
    X[0] = 1 if N>1 else 0#もし2桁以上ならならX[0]=1、違うならX[0]=0 
print("".join([str(x) if x >= 0 else "0" for x in X]))
#リストを文字列に変換する。もし指定されていない桁の数字があるなら0を代入する

Fixed submission:
N, M = map(int, input().split())
X = [-1] * N#[-1,-1,-1.....]
for _ in range(M):
    s, c = map(int, input().split())
    if s == 1 and N > 1 and c==0:
        print(-1)
        exit()#プログラム終了 １桁目が0で２桁以上あるため-1

#もしリストにまだ数字が入っていなかったらCを代入
    if X[s-1] < 0:
        X[s-1] = c
    
#もしすでにリストに数字が入っている場合は-1を出力する
    elif X[s-1] != c:
        print(-1)
        exit()
#このfor文でリストが完成する

if X[0] < 0 :#もし1桁目の数字が指定されていないなら
    X[0] = 1 if N>1 else 0#もし2桁以上ならならX[0]=1、違うならX[0]=0 
print("".join([str(x) if x >= 0 else "0" for x in X]))
#リストを文字列に変換する。もし指定されていない桁の数字があるなら0を代入する
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=[str(input()) for i in range(N)]

SA=list(set(S))
l=len(SA)
d=[0]*l
for i in range(l):
  d[i]=S.count(SA[i])
  S.remove(SA[i])

m=max(d)
sm=[]
for i in range(l):
  if d[i]==m:
    sm.append(SA[i])

sm.sort()
for i in sm:
  print(i)

Fixed submission:
import collections
N=int(input())
S=[]
for i in range(N):
   S.append(str(input())) 
c=collections.Counter(S)
c_sorted=sorted(c.items(),key=lambda x:x[0])
s=max(c.values())
for i in c_sorted:
    if i[1]==s:
        print(i[0])

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=[str(input()) for i in range(N)]

SA=list(set(S))
d=[0]*len(SA)
for i in range(len(SA)):
  d[i]=S.count(SA[i])

MAX=[i for i, v in enumerate(d) if v == max(d)]

SB=[]
for i in MAX:
  SB.append(SA[i])

SB.sort()
for i in SB:
  print(i)

Fixed submission:
import collections
N=int(input())
S=[]
for i in range(N):
   S.append(str(input())) 
c=collections.Counter(S)
c_sorted=sorted(c.items(),key=lambda x:x[0])
s=max(c.values())
for i in c_sorted:
    if i[1]==s:
        print(i[0])
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))

a=0

for i in range(N):
  if A.count(A[0])>=2:
    print("NO")
    a=1
    break
  else:
    del A[0]

if a==0:
  print("YES")

 

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

if len(A) == len(set(A)):
  print("YES")
else:
  print("NO")

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

a=0
i=-1
j=0
while True:
  i+=1
  if A.count(A[i])>=2:
    print("NO")
    a=1
    break
  else:
    A.remove(A[i])
    j+=1
    i-=1
    if j==N:
      break

if a==0:
  print("YES")

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

if len(A) == len(set(A)):
  print("YES")
else:
  print("NO")

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

a=0
i=-1
while True:
  i+=1
  if A.count(A[i])>=2:
    print("NO")
    a=1
    break
  else:
    A.remove(A[i])
    i-=1
    
if a==0:
  print(A)
  print("YES")

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

if len(A) == len(set(A)):
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
P=list(map(int,input().split()))
L=[]
def E(n):
  e=0
  for i in range(1,n+1):
    e+=i
  e = e/n
  return e

l=sum(P[0:K])
k=0
for i in range(1,N-K+1):
  l = l-P[i-1]+P[i-1+K]
  if l>k:
    k=l
    L=P[i:i+K]

A=0
for i in range(K):
  A+=E(L[i])
print(A)

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


l=sum(P[0:K])
k=l
for i in range(N-K):
  l = l-P[i]+P[i+K]
  if l>k:
    k=l

print((k+K)/2)

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
P=list(map(int,input().split()))
L=[]
def E(n):
  e=0
  for i in range(1,n+1):
    e+=i
  e = e/n
  return e

k=0
for i in range(N-K+1):
  l=sum(P[i:i+K])
  if l>k:
    k=l
    L=P[i:i+K]

A=0
for i in range(K):
  A+=E(L[i])
print(A)

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


l=sum(P[0:K])
k=l
for i in range(N-K):
  l = l-P[i]+P[i+K]
  if l>k:
    k=l

print((k+K)/2)
Buggy python submission (verdict: Runtime Error):
import itertools
n=int(input())
a=[list(map(int,input().split())) for i in range(n)]
b=[]
for i in a:
	ma=i[0] + i[1]
	mi=i[0] - i[1]
	c=[mi,ma]
	b.append(c)


while True:
	count=[]
	for i in range(n):
		count.append(0)
	p=0
	d=list(itertools.combinations(range(n), 2))
	for i in d:
		p+=1
		if b[i[0]][0]<b[i[1]][0]<b[i[0]][1] or b[i[0]][0]<b[i[1]][1]<b[i[0]][1]:
			count[i[0]]+=1
			count[i[1]]+=1
	del b[count.index(max(count))]
	del b[count.index(max(count))]
	print(count)
	n-=1
	if sum(count)==0:
		break
print(len(count))

Fixed submission:
N=int(input())
xl=[]
for i in range(N):
  x,l=map(int,input().split())
  xl.append([x-l,x+l])

XL=sorted(xl,key=lambda x:x[1])

w=1
robot=XL[0]
for i in XL:
  if robot[1] <= i[0]:
    w+=1
    robot=i
print(w)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n=int(input())
a=[list(map(int,input().split())) for i in range(n)]
b=[]
for i in a:
	ma=i[0] + i[1]
	mi=i[0] - i[1]
	c=[mi,ma]
	b.append(c)


while True:
	count=[]
	for i in range(n):
		count.append(0)
	p=0
	d=list(itertools.combinations(range(n), 2))
	for i in d:
		p+=1
		if b[i[0]][0]<b[i[1]][0]<b[i[0]][1] or b[i[0]][0]<b[i[1]][1]<b[i[0]][1]:
			count[i[0]]+=1
			count[i[1]]+=1
	del b[count.index(max(count))]
	n-=1
	if sum(count)==0:
		break
print(len(count))

Fixed submission:
N=int(input())
xl=[]
for i in range(N):
  x,l=map(int,input().split())
  xl.append([x-l,x+l])

XL=sorted(xl,key=lambda x:x[1])

w=1
robot=XL[0]
for i in XL:
  if robot[1] <= i[0]:
    w+=1
    robot=i
print(w)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[list(map(int,input().split())) for i in range(n)]
b=[]
for i in a:
	ma=i[0] + i[1]
	mi=i[0] - i[1]
	c=[mi,ma]
	b.append(c)


while True:
	count=[]
	for i in range(n):
		count.append(0)
	p=0
	for i in b:
		p+=1
		for j in b:
			if i==j:
				continue
			if i[0]<j[0]<i[1] or i[0]<j[1]<i[1]:
				count[p-1]+=1
	del b[count.index(max(count))]
	n-=1
	if sum(count)==0:
		break

print(len(count))

Fixed submission:
N=int(input())
xl=[]
for i in range(N):
  x,l=map(int,input().split())
  xl.append([x-l,x+l])

XL=sorted(xl,key=lambda x:x[1])

w=1
robot=XL[0]
for i in XL:
  if robot[1] <= i[0]:
    w+=1
    robot=i
print(w)
Buggy python submission (verdict: Time Limit Exceeded):
A,B,K=map(int,input().split())

for i in range(K):
  if A>=1:
    A=A-1
  elif B>=1:
    B=B-1
  elif A==0 and B==0:
    break

print(A,B)

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

if K>=A+B:
  A,B=0,0
elif K<A+B:
  if K>A:
    A,B=0,B-K+A
  if K<=A:
    A,B=A-K,B

print(A,B)

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

for i in range(K):
  if A>=1:
    A=A-1
  elif B>=1:
    B=B-1
  elif A==0 and B==0:
    pass

print(A,B)

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

if K>=A+B:
  A,B=0,0
elif K<A+B:
  if K>A:
    A,B=0,B-K+A
  if K<=A:
    A,B=A-K,B

print(A,B)
Buggy python submission (verdict: Runtime Error):
from sympy import nextprime

X=int(input())
print(nextprime(X))


Fixed submission:
import math

P_lst=[2]
for i in range(1000):
  flag=0
  for j in P_lst:
    if (i+3)%j==0:
      flag=1

  if flag==0:
    P_lst.append(i+3)

X=int(input())

while X<=200000:
  if X==2:
    print(2)
    break
  flag=0
  x=math.sqrt(X)
  for k in P_lst:
    if X%k==0:
      break
    if x<k:
      flag=1
      break
  if flag==1:
    print(X)
    break
  X=X+1
Buggy python submission (verdict: Runtime Error):
N = input()
S = input()
T = input()

A=0
P=""
while A < int(N):
  P+=S[A]+T[A]
  A=A+1

print(P)

Fixed submission:
N = input()
S,T=map(str,input().split())

A=0
P=""
while A < int(N):
  P+=S[A]+T[A]
  A=A+1

print(P)
Buggy python submission (verdict: Runtime Error):
import math

a,b=map(int,input().split())
print(int(a*b/math.gcd(a,b)))


Fixed submission:
import fractions

A,B=map(int,input().split())
f=A*B//fractions.gcd(A,B)
print(f)
Buggy python submission (verdict: Time Limit Exceeded):
N=input()
M=int(N)
f=1
while 2<=M:
  if M<2:M=1
  f *= M
  M -= 2
B=str(f)
A=len(B)-len(B.rstrip('0'))
print(A)

Fixed submission:
n=int(input())

if n%2!=0:
  print(0)
else:
  A=0
  m=10
  while n//m>0:
    A+=n//m
    m*=5
  print(A)

Buggy python submission (verdict: Runtime Error):
N=input()
M=int(N)
f=1
while 2<=M:
  if M<2:M=1
  f *= M
  M -= 2

A=len(f)-len(f.rstrip('0'))
print(A)

Fixed submission:
n=int(input())

if n%2!=0:
  print(0)
else:
  A=0
  m=10
  while n//m>0:
    A+=n//m
    m*=5
  print(A)
Buggy python submission (verdict: Runtime Error):
import math
a,b,x=map(int,input().split())
h=x/(a**2)
if x >= (b*a**2)/2:
  beta=math.atan((a/2)/(b-h))
  alfa=(math.pi)/2 - beta
else:
  alfa=math.atan(b/(2*x/(a*b)))
print(math.degrees(alfa))

Fixed submission:
import math
a,b,x=map(int,input().split())
L=b*a**2
if L==x:
  alfa=0
elif x >= L/2:
  h=x/(a**2)
  beta=math.atan((a/2)/(b-h))
  alfa=(math.pi)/2 - beta
else:
  alfa=math.atan(b/(2*x/(a*b)))
print(math.degrees(alfa))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n=int(input())
l=list(map(int,input().split()))
c=itertools.combinations(l,3)
ans=0
for i in c:
  if 2*max(i) < i[0]+i[1]+i[2]:
    ans+=1
print(ans)

Fixed submission:
from bisect import bisect_left
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n):#一番短い棒
  for j in range(i+1,n):#二番目に短い棒
    #1+2番目の棒の長さより短く、2番目に短い棒より長い棒の範囲を探す
    ans += bisect_left(l,l[i]+l[j])-(j+1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n=int(input())
l=list(map(int,input().split()))
c=itertools.combinations(l,3)
ans=0
for i in c:
  if 2*max(i) < i[0]+i[1]+i[2]:
    ans+=1
print(ans)

Fixed submission:
from bisect import bisect_left
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n):#一番短い棒
  for j in range(i+1,n):#二番目に短い棒
    #1+2番目の棒の長さより短く、2番目に短い棒より長い棒の範囲を探す
    ans += bisect_left(l,l[i]+l[j])-(j+1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N=int(input())
L=list(map(int,input().split()))
 
p=itertools.combinations(L,3)
q=itertools.combinations(L,2)
d={}
for i in q:
  d[i]=i[0]+i[1]
s=0
for i in p:
  x=d[i[0],i[1]]
  y=d[i[1],i[2]]
  z=d[i[0],i[2]]
  if i[0]<y and i[1]<z and i[2]<x:
    s += 1
 
print(s)

Fixed submission:
from bisect import bisect_left
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n):#一番短い棒
  for j in range(i+1,n):#二番目に短い棒
    #1+2番目の棒の長さより短く、2番目に短い棒より長い棒の範囲を探す
    ans += bisect_left(l,l[i]+l[j])-(j+1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N=int(input())
L=list(map(int,input().split()))
 
p=itertools.combinations(L,3)
q=itertools.combinations(L,2)
d={}
for i in q:
  if i not in d:
    d[i]=i[0]+i[1]
s=0
for i in p:
  x=d[i[0],i[1]]
  y=d[i[1],i[2]]
  z=d[i[0],i[2]]
  if i[0]<y and i[1]<z and i[2]<x:
    s += 1
 
print(s)

Fixed submission:
from bisect import bisect_left
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n):#一番短い棒
  for j in range(i+1,n):#二番目に短い棒
    #1+2番目の棒の長さより短く、2番目に短い棒より長い棒の範囲を探す
    ans += bisect_left(l,l[i]+l[j])-(j+1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N=int(input())
L=list(map(int,input().split()))

p=itertools.combinations(L,3)

s=0
for i in p:
  if i[0]<i[1]+i[2] and i[1]<i[0]+i[2] and i[2]<i[1]+i[0]:
    s += 1

print(s)

Fixed submission:
from bisect import bisect_left
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n):#一番短い棒
  for j in range(i+1,n):#二番目に短い棒
    #1+2番目の棒の長さより短く、2番目に短い棒より長い棒の範囲を探す
    ans += bisect_left(l,l[i]+l[j])-(j+1)
print(ans)