Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,k,q=map(int,input().split())
diff=q-k
count=[0]*n
arr=[int(input()) for _ in range(n)]
ans=['No']*n
for i in range(n):
  count[arr[i]-1]+=1
for i in range(n):
  if count[i]>diff:
    ans[i]='Yes'
  print(ans[i])

Fixed submission:
n,k,q=map(int,input().split())
diff=q-k
count=[0]*n
arr=[int(input()) for _ in range(q)]
ans=['No']*n
for i in range(q):
  count[arr[i]-1]+=1
for i in range(n):
  if count[i]>diff:
    ans[i]='Yes'
  print(ans[i])

Buggy python submission (verdict: Runtime Error):
n,k,q=map(int,input().split())
diff=q-k
count=[0]*n
arr=list(map(int,input().split()))
ans=['No']*n
for i in range(n):
  count[arr[i]-1]+=1
for i in range(n):
  if count[i]>=diff:
    ans[i]='Yes'
  print(ans[i])

Fixed submission:
n,k,q=map(int,input().split())
diff=q-k
count=[0]*n
arr=[int(input()) for _ in range(q)]
ans=['No']*n
for i in range(q):
  count[arr[i]-1]+=1
for i in range(n):
  if count[i]>diff:
    ans[i]='Yes'
  print(ans[i])
Buggy python submission (verdict: Runtime Error):
n=int(input())
dic={}
for _ in range(n):
  s=input()
  s=sorted(s)
  if s not in dic:
    dic[s]=1
  else:
    dic[s]+=1
ans=0
for val in dic.values():
  ans+=val*(val-1)//2
print(ans)

Fixed submission:
n=int(input())
arr=[input() for _ in range(n)]
dic={}
check='abcdefghijklmnopqrstuvwxyz'
for s in arr:
  count=[0]*26
  for i in range(10):
    for j in range(26):
      if s[i]==check[j]:
        count[j]+=1
        break
  count=tuple(count)
  if count not in dic:
    dic[count]=1
  else:
    dic[count]+=1
ans=0
for val in dic.values():
  ans+=val*(val-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
import heapq

n,m=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(n)]
arr2=[[i,0] for i in range(1,m+1)]
arr.extend(arr2)
arr=sorted(arr,reverse=True,key=lambda x:x[1])
arr=sorted(arr,key=lambda x:x[0])
tmp=arr[0][0]
q=[]
ans=0
pos=0
while 1:
  a,b=arr[pos]
  if a>m:
    break
  if a==arr[pos+1][0]:
    heapq.heappush(q,-b)
  else:
    heapq.heappush(q,-b)
    ans-=heapq.heappop(q)
  pos+=1
print(ans)

Fixed submission:
import heapq

n,m=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(n)]
arr2=[[i,0] for i in range(1,m+5)]
arr.extend(arr2)
arr=sorted(arr,reverse=True,key=lambda x:x[1])
arr=sorted(arr,key=lambda x:x[0])
tmp=arr[0][0]
q=[]
ans=0
pos=0
while 1:
  a,b=arr[pos]
  if a>m:
    break
  if a==arr[pos+1][0]:
    heapq.heappush(q,-b)
  else:
    heapq.heappush(q,-b)
    ans-=heapq.heappop(q)
  pos+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import heapq

n,m=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(n)]
arr=sorted(arr,reverse=True,key=lambda x:x[1])
arr=sorted(arr,reverse=True,key=lambda x:x[0])
q=[]
tmp=0
cnt=0
for a,b in arr:
  if tmp!=a:
    tmp=a
    cnt=0
  if m-tmp<cnt:
    continue
  heapq.heappush(q,(-b,a))
  cnt+=1
ans=0
cnt=0
box=[0]*(m+1)
while len(q)!=0:
  if cnt>=m:
    break
  tmp,date=heapq.heappop(q)
  if box[date]==0:
    box[date]=1
    ans-=tmp
    cnt+=1
  else:
    pos=date
    while 1:
      if pos==m:
        break
      pos+=1
      if box[pos]==0:
        box[pos]=1
        ans-=tmp
        cnt+=1
        break
print(ans)

Fixed submission:
import heapq

n,m=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(n)]
arr2=[[i,0] for i in range(1,m+5)]
arr.extend(arr2)
arr=sorted(arr,reverse=True,key=lambda x:x[1])
arr=sorted(arr,key=lambda x:x[0])
tmp=arr[0][0]
q=[]
ans=0
pos=0
while 1:
  a,b=arr[pos]
  if a>m:
    break
  if a==arr[pos+1][0]:
    heapq.heappush(q,-b)
  else:
    heapq.heappush(q,-b)
    ans-=heapq.heappop(q)
  pos+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def div(n):
  ret=[]
  for i in range(1,int(n**0.5)+1):
    if n%i==0:
      ret.append(i)
      if i!=n//i:
        ret.append(n//i)
  return ret

n,k=map(int,input().split())
arr=list(map(int,input().split()))
arr=sorted(arr)
s=sum(arr)
ans=1
d=div(s)
for val in d:
  arr=sorted(arr,key=lambda x:x%val)
  for i in range(n-1):
    pcnt=0
    ncnt=0
    for j in range(n):
      if j<=i:
        ncnt+=arr[j]%val
      else:
        pcnt+=(val-arr[j]%val)
    if ncnt!=pcnt:
      continue
    else:
      if pcnt<=k:
        ans=max(ans,val)
print(ans)

Fixed submission:
def div(n):
  ret=[]
  for i in range(1,int(n**0.5)+1):
    if n%i==0:
      ret.append(i)
      if i!=n//i:
        ret.append(n//i)
  return ret

n,k=map(int,input().split())
arr=list(map(int,input().split()))
arr=sorted(arr)
s=sum(arr)
ans=1
d=div(s)
for val in d:
  arr=sorted(arr,key=lambda x:x%val)
  parr=[]
  narr=[]
  for num in arr:
    narr.append(num%val)
    parr.append(val-num%val)
  for i in range(n-1):
    parr[i+1]+=parr[i]
    narr[i+1]+=narr[i]
  for i in range(n-1):
    ncnt=narr[i]
    pcnt=parr[-1]-parr[i]
    if ncnt!=pcnt:
      continue
    else:
      if pcnt<=k:
        ans=max(ans,val)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
arr=list(map(int,input().split()))
pos=[[] for _ in range(2*10**5+1)]
pos[0].append(-1)
arrpos=[0]*n
for i in range(n):
  pos[arr[i]].append(i)
  arrpos[i]=len(pos[arr[i]])
ans=[]
tmp=[0]
cnt=0
while len(tmp)!=0:
  p=pos[tmp[0]][0]+1
  ntmp=[]
  flag=True
  while p<n:
    if arrpos[p]<len(pos[arr[p]]):
      p=pos[arr[p]][arrpos[p]]+1
    else:
      ntmp.append(arr[p])
      if len(pos[arr[p]])!=1:
        flag=False
      p+=1
  ans.append(ntmp)
  tmp=ntmp
  cnt+=1
  if flag==True:
    break
for i in range(1,len(tmp)+1):
  ans.append(tmp[i:])
print(*ans[k%len(ans)-1])

Fixed submission:
import collections

n,k=map(int,input().split())
arr=list(map(int,input().split()))
pos=[[] for _ in range(max(arr)+1)]
for i in range(2*n):
  pos[arr[i%n]].append(i)
edge=[[] for _ in range(n)]
cnt=collections.defaultdict(int)
for i in range(n):
  s=pos[arr[i]][cnt[arr[i]]]
  g=pos[arr[i]][cnt[arr[i]]+1]
  edge[s].append((g+1)%n)
  edge[s].append((g+1)//n)
  cnt[arr[i]]+=1
start=0
loop=0
for _ in range(n):
  loop+=edge[start][1]
  start=edge[start][0]
  if start==0:
    break
k%=loop
if k==0:
  print('')
else:
  k-=1
  start=0
  loop=0
  for _ in range(n):
    if loop==k:
      break
    loop+=edge[start][1]
    start=edge[start][0]
  s=set()
  q=collections.deque()
  for i in range(start,n):
    if arr[i] not in s:
      s.add(arr[i])
      q.append(arr[i])
    else:
      while 1:
        tmp=q.pop()
        s.discard(tmp)
        if tmp==arr[i]:
          break
  print(*list(q))

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
arr=list(map(int,input().split()))
pos=[[] for _ in range(2*10**5+1)]
pos[0].append(-1)
arrpos=[0]*n
for i in range(n):
  pos[arr[i]].append(i)
  arrpos[i]=len(pos[arr[i]])
ans=[]
tmp=[0]
cnt=0
while len(tmp)!=0:
  p=pos[tmp[0]][0]+1
  ntmp=[]
  flag=True
  while p<n:
    if arrpos[p]<len(pos[arr[p]]):
      p=pos[arr[p]][arrpos[p]]+1
    else:
      ntmp.append(arr[p])
      if len(pos[arr[p]])!=1:
        flag=False
      p+=1
  ans.append(ntmp)
  tmp=ntmp
  cnt+=1
  if flag==True:
    break
for i in range(1,len(tmp)+1):
  ans.append(tmp[i:])
print(*ans[k%len(ans)-1])

Fixed submission:
import collections

n,k=map(int,input().split())
arr=list(map(int,input().split()))
pos=[[] for _ in range(max(arr)+1)]
for i in range(2*n):
  pos[arr[i%n]].append(i)
edge=[[] for _ in range(n)]
cnt=collections.defaultdict(int)
for i in range(n):
  s=pos[arr[i]][cnt[arr[i]]]
  g=pos[arr[i]][cnt[arr[i]]+1]
  edge[s].append((g+1)%n)
  edge[s].append((g+1)//n)
  cnt[arr[i]]+=1
start=0
loop=0
for _ in range(n):
  loop+=edge[start][1]
  start=edge[start][0]
  if start==0:
    break
k%=loop
if k==0:
  print('')
else:
  k-=1
  start=0
  loop=0
  for _ in range(n):
    if loop==k:
      break
    loop+=edge[start][1]
    start=edge[start][0]
  s=set()
  q=collections.deque()
  for i in range(start,n):
    if arr[i] not in s:
      s.add(arr[i])
      q.append(arr[i])
    else:
      while 1:
        tmp=q.pop()
        s.discard(tmp)
        if tmp==arr[i]:
          break
  print(*list(q))
Buggy python submission (verdict: Runtime Error):
import collections
import bisect

n=int(input())
arr=[int(input()) for _ in range(n)]
num=1
ans=collections.deque([arr[0]])
print(ans)
for i in range(1,n):
  tmp=ans.popleft()
  if arr[i]<=tmp:
    ans.appendleft(tmp)
    ans.appendleft(arr[i])
  else:
    ans.appendleft(tmp)
    pos=bisect.bisect_right(ans,arr[i])
    ans[pos-1]=arr[i]
  print(ans)
print(ans)

Fixed submission:
#quoted LIS from https://qiita.com/python_walker/items/d1e2be789f6e7a0851e5
import bisect

n=int(input())
arr=[int(input()) for _ in range(n)][::-1]
LIS=[arr[0]]
for i in range(1,n):
  if arr[i]>=LIS[-1]:
    LIS.append(arr[i])
  else:
    LIS[bisect.bisect_right(LIS,arr[i])]=arr[i]
print(len(LIS))

Buggy python submission (verdict: Runtime Error):
import bisect

n=int(input())
arr=[int(input()) for _ in range(n)][::-1]
LIS = [arr[0]]
for i in range(1,n):
  print(LIS)
  if arr[i] >= LIS[-1]:
    LIS.append(arr[i])
  else:
    LIS[bisect.bisect_left(LIS, arr[i])] = arr[i]
print(len(LIS))

Fixed submission:
#quoted LIS from https://qiita.com/python_walker/items/d1e2be789f6e7a0851e5
import bisect

n=int(input())
arr=[int(input()) for _ in range(n)][::-1]
LIS=[arr[0]]
for i in range(1,n):
  if arr[i]>=LIS[-1]:
    LIS.append(arr[i])
  else:
    LIS[bisect.bisect_right(LIS,arr[i])]=arr[i]
print(len(LIS))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
arr=[int(input()) for _ in range(n)]
ans=[-1]*(n+1)
num=1
ans[0]=arr[0]
for i in range(1,n):
  for j in range(num):
    if ans[j]<arr[i]:
      ans[j]=arr[i]
      break
  else:
    ans[num]=arr[i]
    num+=1
print(num)

Fixed submission:
#quoted LIS from https://qiita.com/python_walker/items/d1e2be789f6e7a0851e5
import bisect

n=int(input())
arr=[int(input()) for _ in range(n)][::-1]
LIS=[arr[0]]
for i in range(1,n):
  if arr[i]>=LIS[-1]:
    LIS.append(arr[i])
  else:
    LIS[bisect.bisect_right(LIS,arr[i])]=arr[i]
print(len(LIS))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
arr=[int(input()) for _ in range(n)]
ans=0
while 1:
  tmp=[]
  if len(arr)==0:
    break
  val=arr[0]
  for i in range(1,len(arr)):
    if arr[i]>val:
      val=arr[i]
    else:
      tmp.append(arr[i])
  arr=tmp
  ans+=1
print(ans)

Fixed submission:
#quoted LIS from https://qiita.com/python_walker/items/d1e2be789f6e7a0851e5
import bisect

n=int(input())
arr=[int(input()) for _ in range(n)][::-1]
LIS=[arr[0]]
for i in range(1,n):
  if arr[i]>=LIS[-1]:
    LIS.append(arr[i])
  else:
    LIS[bisect.bisect_right(LIS,arr[i])]=arr[i]
print(len(LIS))
Buggy python submission (verdict: Time Limit Exceeded):
import collections

n,m=map(int,input().split())
g=[[] for _ in range(n+1)]
for _ in range(m):
  a,b=map(int,input().split())
  g[a].append(b)
s,t=map(int,input().split())
check=[0]*(n+1)
q=collections.deque()
q.append([s,0])
ans=0
while len(q)!=0:
  v,c=q.popleft()
  if v==t:
    ans=c
    break
  for i in g[v]:
    for j in g[i]:
      for k in g[j]:
        if check[k]==0:
          q.append([k,c+1])
          check[k]=1
if ans==0:
  print(-1)
else:
  print(ans)

Fixed submission:
import collections

n,m=map(int,input().split())
g=[[] for _ in range(n+1)]
for _ in range(m):
  a,b=map(int,input().split())
  g[a].append(b)
s,t=map(int,input().split())
check=[[0]*3 for _ in range(n+1)]
check[s][0]=1
q=collections.deque()
q.append([s,0])
ans=0
while len(q)!=0:
  v,c=q.popleft()
  if v==t and c%3==0:
    ans=c//3
    break
  for i in g[v]:
    if check[i][(c+1)%3]==0:
      q.append([i,c+1])
      check[i][(c+1)%3]=1
if ans==0:
  print(-1)
else:
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import collections

n,m=map(int,input().split())
g=[[] for _ in range(n+1)]
for _ in range(m):
  a,b=map(int,input().split())
  g[a].append(b)
s,t=map(int,input().split())
check=[0]*(n+1)
q=collections.deque()
q.append([s,0])
ans=0
while len(q)!=0:
  v,c=q.popleft()
  if v==t:
    ans=c
    break
  for i in g[v]:
    for j in g[i]:
      for k in g[j]:
        if check[k]==0:
          q.append([k,c+1])
          check[k]=1
if ans==0:
  print(-1)
else:
  print(ans)

Fixed submission:
import collections

n,m=map(int,input().split())
g=[[] for _ in range(n+1)]
for _ in range(m):
  a,b=map(int,input().split())
  g[a].append(b)
s,t=map(int,input().split())
check=[[0]*3 for _ in range(n+1)]
check[s][0]=1
q=collections.deque()
q.append([s,0])
ans=0
while len(q)!=0:
  v,c=q.popleft()
  if v==t and c%3==0:
    ans=c//3
    break
  for i in g[v]:
    if check[i][(c+1)%3]==0:
      q.append([i,c+1])
      check[i][(c+1)%3]=1
if ans==0:
  print(-1)
else:
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
mod=10**9+7
n,k=map(int,input().split())
coef=[]
for i in range(1,int(n**0.5)+1):
  coef.append((n//i)-(n//(i+1)))
coef+=[1]*(n-sum(coef))
coef=coef[::-1]
nn=len(coef)
dp=[[0]*nn for _ in range(k+1)]
dp[0][0]=1
for i in range(1,k+1):
  tmp=0
  for j in range(nn-1,-1,-1):
    tmp+=dp[i-1][(nn-1)-j]
    dp[i][j]=coef[j]*tmp
    dp[i][j]%=mod
print(sum(dp[k])%mod)

Fixed submission:
mod=10**9+7
n,k=map(int,input().split())
coef=[]
for i in range(1,int(n**0.5)+1):
  coef.append((n//i)-(n//(i+1)))
coef+=[1]*(n-sum(coef))
coef=coef[::-1]
nn=len(coef)
dp=[[0]*nn for _ in range(k+1)]
dp[0][0]=1
for i in range(1,k+1):
  tmp=0
  for j in range(nn-1,-1,-1):
    tmp+=dp[i-1][(nn-1)-j]
    tmp%=mod
    dp[i][j]=coef[j]*tmp
    dp[i][j]%=mod
print(sum(dp[k])%mod)
Buggy python submission (verdict: Runtime Error):
n=int(input())
arr=[list(map(int,input().split())) for _ in range(n)]
cnt={}
for i in range(n):
  for j in range(n):
    if i==j:
      continue
    p=arr[i][0]-arr[j][0]
    q=arr[i][1]-arr[j][1]
    if (p,q) not in cnt:
      cnt[(p,q)]=1
    else:
      cnt[(p,q)]+=1
ans=n-max(cnt.values())
print(ans)

Fixed submission:
n=int(input())
arr=[list(map(int,input().split())) for _ in range(n)]
arr=sorted(arr,key=lambda x:x[1])
arr=sorted(arr,key=lambda x:x[0])
ans=n
for i in range(n):
  for j in range(i+1,n):
    p,q=arr[j][0]-arr[i][0],arr[j][1]-arr[i][1]
    cnt=0
    flag=[0]*n
    for k in range(n):
      if flag[k]==1:
        continue
      flag[k]=1
      a,b=arr[k][0],arr[k][1]
      while 1:
        for l in range(n):
          if flag[l]==1:
            continue
          if a+p==arr[l][0] and b+q==arr[l][1]:
            flag[l]=1
            a=arr[l][0]
            b=arr[l][1]
            break
        else:
          break
      cnt+=1
    ans=min(ans,cnt)
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
arr=set([int(input()) for _ in range(m)])
dp=[0]*(n+1)
if 1 not in arr:
  dp[1]=1
if 2 not in arr:
  dp[2]=dp[1]+1
for i in range(3,n+1):
  if i not in arr:
    dp[i]=(dp[i-1]+dp[i-2])%1000000007
print(dp[n]%1000000007)

Fixed submission:
n,m=map(int,input().split())
arr=set([int(input()) for _ in range(m)])
dp=[0]*(n+1)
if 1 not in arr:
  dp[1]=1
if n>=2:
  if 2 not in arr:
    dp[2]=dp[1]+1
for i in range(3,n+1):
  if i not in arr:
    dp[i]=(dp[i-1]+dp[i-2])%1000000007
print(dp[n]%1000000007)
Buggy python submission (verdict: Time Limit Exceeded):
l=input()
dp=[[0,0] for _ in range(len(l))]
if l[-1]=='1':
  dp[-1][0]=1
  dp[-1][1]=2
else:
  dp[-1][0]=1
  dp[-1][1]=0
for i in range(len(l)-2,-1,-1):
  if l[i]=='0':
    dp[i][0]=dp[i+1][0]+dp[i+1][1]
    dp[i][1]=0
  else:
    dp[i][0]=(3**(len(l)-i-1))%(10**9+7)
    dp[i][1]=(2*(dp[i+1][0]+dp[i+1][1]))%(10**9+7)
print((dp[0][0]+dp[0][1])%(10**9+7))

Fixed submission:
def qpow(b,t,m):
  f=format(t,'b')[::-1]
  arr=[b]
  tmp=b
  for i in range(1,len(f)):
    tmp=(tmp**2)%m
    arr.append(tmp)
  ans=1
  for i in range(len(f)):
    if f[i]=='1':
      ans=(ans*arr[i])%m
  return ans    

l=input()
dp=[[0,0] for _ in range(len(l))]
if l[-1]=='1':
  dp[-1][0]=1
  dp[-1][1]=2
else:
  dp[-1][0]=1
  dp[-1][1]=0
for i in range(len(l)-2,-1,-1):
  if l[i]=='0':
    dp[i][0]=dp[i+1][0]+dp[i+1][1]
    dp[i][1]=0
  else:
    dp[i][0]=qpow(3,len(l)-i-1,10**9+7)
    dp[i][1]=(2*(dp[i+1][0]+dp[i+1][1]))%(10**9+7)
print((dp[0][0]+dp[0][1])%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
event=[]
for _ in range(n):
  s,t,x=map(int,input().split())
  event.append([s-x,1,x])
  event.append([t-x,-1,x])
event=sorted(event,key=lambda x:x[0])
event.append([10**10,1,10**10])
pos=[int(input()) for _ in range(q)]
sx=set()
cnt=0
m=10**10
ans=[]
for p in pos:
  while event[cnt][0]<=p:
    s,f,x=event[cnt]
    cnt+=1
    if f==1:
      sx.add(x)
      m=min(m,x)
    else:
      sx.remove(x)
      if m==x:
        if len(sx)==0:
          m=10**10
        else:
          m=min(sx)
  if sx:
    ans.append(m)
  else:
    ans.append(-1)
for i in ans:
  print(i)

Fixed submission:
from bisect import bisect_left

n,q=map(int,input().split())
work=[list(map(int,input().split())) for _ in range(n)]
work=sorted(work,key=lambda x:x[2])
pos=[int(input()) for _ in range(q)]
ans=[-1]*q
checked=[-1]*q
for s,t,x in work:
  l=bisect_left(pos,s-x)
  r=bisect_left(pos,t-x)
  while l<r:
    if checked[l]==-1:
      checked[l]=r
      ans[l]=x
      l+=1
    else:
      l=checked[l]
for i in ans:
  print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
event=[]
for _ in range(n):
  s,t,x=map(int,input().split())
  event.append([s-x,1,x])
  event.append([t-x,-1,x])
event=sorted(event,key=lambda x:x[0])
event.append([10**10,1,10**10])
pos=[int(input()) for _ in range(q)]
sx=set()
cnt=0
m=10**10
ans=[]
for p in pos:
  while event[cnt][0]<=p:
    s,f,x=event[cnt]
    cnt+=1
    if f==1:
      sx.add(x)
      m=min(m,x)
    else:
      sx.remove(x)
      if m==x:
        if len(sx)==0:
          m=10**10
        else:
          m=min(list(sx))
  if len(sx)==0:
    ans.append(-1)
  else:
    ans.append(m)
for i in ans:
  print(i)

Fixed submission:
from bisect import bisect_left

n,q=map(int,input().split())
work=[list(map(int,input().split())) for _ in range(n)]
work=sorted(work,key=lambda x:x[2])
pos=[int(input()) for _ in range(q)]
ans=[-1]*q
checked=[-1]*q
for s,t,x in work:
  l=bisect_left(pos,s-x)
  r=bisect_left(pos,t-x)
  while l<r:
    if checked[l]==-1:
      checked[l]=r
      ans[l]=x
      l+=1
    else:
      l=checked[l]
for i in ans:
  print(i)
Buggy python submission (verdict: Time Limit Exceeded):
r,b,g,n=map(int,input().split())
cnt=0
for i in range(n//r+1):
  for j in range(n//b+1):
    if r*i+b*j==n:
      cnt+=1
    elif (n-r*i-b*j)%g==0 and (n-r*i-b*j)//g>=1:
      cnt+=1
print(cnt)

Fixed submission:
r,b,g,n=map(int,input().split())
cnt=0
for i in range(n//r+1):
  for j in range(n//b+1):
    if r*i+b*j==n:
      cnt+=1
    elif (n-r*i-b*j)%g==0 and (n-r*i-b*j)//g>=1:
      cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
def gcd(a,b):
  a,b=max(a,b),min(a,b)
  if b==0:
    return a
  else:
    return gcd(b,a%b)
  
n=int(input())
arr=list(map(int,input().split()))
if n==2:
  print(max(arr[0],arr[1]))
elif n==3:
  print(max(gcd(arr[0],arr[1]),gcd(arr[1],arr[2]),gcd(arr[2],arr[0])))
else:
  ans1=[]
  for i in range(n):
    ans1.append(gcd(gcd(arr[0],arr[1]),arr[i]))
  ans1=sorted(ans1)
  ans2=[]
  for i in range(n):
    ans2.append(gcd(gcd(arr[2],arr[3]),arr[i]))
  ans2=sorted(ans2)
  finans1=ans1[1]
  finans2=ans2[1]
  finalans=max(finans1,finans2)
  print(finalans)

Fixed submission:
a,b,t=map(int,input().split())
ans=0
for i in range(t//a):
  ans+=b
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
ans=10**10
ans1=n-s.count('#')
ans2=n-s.count('.')
for i in range(n):
  tmp=s[:i].count('#')+s[i+1:].count('.')
  if tmp<ans:
    ans=tmp
print(min(ans,ans1,ans2))

Fixed submission:
n=int(input())
s=input()+'?'
ans=10**10
arr=[0]*n
ans1=n-s.count('#')
ans2=n-s.count('.')
if s[0]=='.':
  arr[0]=1
for i in range(1,n):
  if s[i]=='.':
    arr[i]=arr[i-1]+1
  else:
    arr[i]=arr[i-1]
for i in range(1,n):
  tmp=(i-arr[i-1])+(arr[-1]-arr[i])
  if tmp<ans:
    ans=tmp
print(min(ans,ans1,ans2))

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()+'?'
white=s.count('.')
black=s.count('#')
ans1=n-black
ans2=n-white
index=s.index('.')
ans3=index+s[index+1:].count('.')
print(min(ans1,ans2,ans3))

Fixed submission:
n=int(input())
s=input()+'?'
ans=10**10
arr=[0]*n
ans1=n-s.count('#')
ans2=n-s.count('.')
if s[0]=='.':
  arr[0]=1
for i in range(1,n):
  if s[i]=='.':
    arr[i]=arr[i-1]+1
  else:
    arr[i]=arr[i-1]
for i in range(1,n):
  tmp=(i-arr[i-1])+(arr[-1]-arr[i])
  if tmp<ans:
    ans=tmp
print(min(ans,ans1,ans2))
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
list=[a,b,c,d,e]
list2=[a%10,b%10,c%10,d%10,e%10]
worst=10
worstnum=0
flag=0
count=0
for i in range(5):
  if list2[i] != 0:
    if list2[i] < worst:
      worst = list2[i]
      flag = i
      worstnum=list[i]
  list[i] += 10-list[i]%10
for i in range(5):
  if i = flag:
    count += worstnum
  else:
    count += list[i]
print(count)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
list=[a,b,c,d,e]
worst=10
flag=0
ans=0
for i in range(5):
  if list[i]%10 != 0:
    if list[i]%10 < worst:
      worst = list[i]%10
      flag=i
for i in range(5):
  if i == flag:
    ans += list[i]
  elif list[i]%10 == 0:
    ans += list[i]
  else:
    ans += (list[i] + 10-list[i]%10)
print(ans)

Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
list=[a,b,c,d,e]
list2=[a%10,b%10,c%10,d%10,e%10]
worst=10
worstnum
flag=0
count=0
for i in range(5):
  if list2[i] != 0:
    if list2[i] < worst:
      worst = list2[i]
      flag = i
  list[i] += 10-list[i]%10
for i in range(5):
  if i = flag:
    count += worstnum
  else:
    count += list[i]
print(count)
  

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
list=[a,b,c,d,e]
worst=10
flag=0
ans=0
for i in range(5):
  if list[i]%10 != 0:
    if list[i]%10 < worst:
      worst = list[i]%10
      flag=i
for i in range(5):
  if i == flag:
    ans += list[i]
  elif list[i]%10 == 0:
    ans += list[i]
  else:
    ans += (list[i] + 10-list[i]%10)
print(ans)
Buggy python submission (verdict: Runtime Error):
import heapq

a,b,c,k=map(int,input())
arr1=list(map(int,input().split()))
arr1=sorted(arr1,reverse=True)
arr2=list(map(int,input().split()))
arr2=sorted(arr2,reverse=True)
arr3=list(map(int,input().split()))
arr3=sorted(arr3,reverse=True)
heap=[]
heapq.heappush(heap,(-(arr1[0]+arr2[0]+arr3[0]),0,0,0))
s={(0,0,0)}
for _ in range(k):
  v,i,j,k=heapq.heappop(heap)
  if i+1<a and (i+1,j,k) not in s:
    s.add((i+1,j,k))
    heapq.heappush(heap,(-(arr1[i+1]+arr2[j]+arr3[k]),i+1,j,k))
  if j+1<b and (i,j+1,k) not in s:
    s.add((i,j+1,k))
    heapq.heappush(heap,(-(arr1[i]+arr2[j+1]+arr3[k]),i,j+1,k))
  if k+1<c and (i,j,k+1) not in s:
    s.add((i,j,k+1))
    heapq.heappush(heap,(-(arr1[i]+arr2[j]+arr3[k+1]),i,j,k+1))
  print(-v)

Fixed submission:
import heapq

a,b,c,k=map(int,input().split())
arr1=list(map(int,input().split()))
arr1=sorted(arr1,reverse=True)
arr2=list(map(int,input().split()))
arr2=sorted(arr2,reverse=True)
arr3=list(map(int,input().split()))
arr3=sorted(arr3,reverse=True)
heap=[]
heapq.heappush(heap,(-(arr1[0]+arr2[0]+arr3[0]),0,0,0))
s={(0,0,0)}
for _ in range(k):
  v,i,j,k=heapq.heappop(heap)
  if i+1<a and (i+1,j,k) not in s:
    s.add((i+1,j,k))
    heapq.heappush(heap,(-(arr1[i+1]+arr2[j]+arr3[k]),i+1,j,k))
  if j+1<b and (i,j+1,k) not in s:
    s.add((i,j+1,k))
    heapq.heappush(heap,(-(arr1[i]+arr2[j+1]+arr3[k]),i,j+1,k))
  if k+1<c and (i,j,k+1) not in s:
    s.add((i,j,k+1))
    heapq.heappush(heap,(-(arr1[i]+arr2[j]+arr3[k+1]),i,j,k+1))
  print(-v)
Buggy python submission (verdict: Runtime Error):
s=input()
dic={A:'T',T:'A',C:'G',G:'C'}
print(dic[s])

Fixed submission:
s=str(input())
if s=='A':
  print('T')
elif s=='T':
  print('A')
elif s=='G':
  print('C')
elif s=='C':
  print('G')